Course contentsShow
← Data Science
Lesson 2073 of 2,14547. Reproducible ResearchFree lesson

Naming Conventions for Files and Functions

Adopt consistent, descriptive naming patterns that make code self-documenting and easy to navigate.

Naming Conventions for Files and Functions

What you'll learn: How to use consistent, descriptive naming patterns that make your code self-documenting and instantly understandable.

The Core Idea

Good names are like good signposts—they tell you exactly where you are and what to expect without reading lengthy documentation. In reproducible research, your file and function names should communicate purpose at a glance, making it trivial for collaborators (including future-you) to navigate your project.

Think of naming conventions as a shared language. Just as you wouldn't randomly switch between English and French mid-sentence, you shouldn't mix camelCase, snake_case, and PascalCase throughout your project.

Naming Files

Use descriptive, hierarchical patterns:

01_load_raw_data.py
02_clean_customer_records.py
03_engineer_features.py
04_train_model.py

Number prefixes indicate execution order. Verb-noun combinations (load_data, clean_records) clarify action and target.

Avoid vague names like: script.py, analysis.R, final_FINAL_v2.py

Naming Functions

Be specific and consistent:

def calculate_customer_churn_rate(df):
    # clear what it does, what it expects
    pass

def load_config_from_yaml(filepath):
    # verb-object pattern, includes input type hint
    pass

Avoid: process(), do_stuff(), helper1()

Standards to Adopt

  • Python: snake_case for files and functions
  • R: snake_case or camelCase (pick one, stick with it)
  • Boolean functions: is_valid(), has_missing_values()
  • Constants: MAX_ITERATIONS, DEFAULT_THRESHOLD

Key Takeaway: Consistent, descriptive naming transforms your codebase into self-documenting prose that anyone can read without a decoder ring—essential for reproducible research.