Back to all reviewers

Descriptive balanced naming

ollama/ollama
Based on 8 comments
Go

Choose identifier names that clearly communicate their purpose while maintaining an appropriate balance between brevity and clarity. **Guidelines:**

Naming Conventions Go

Reviewer Prompt

Choose identifier names that clearly communicate their purpose while maintaining an appropriate balance between brevity and clarity.

Guidelines:

  1. Use descriptive names that reflect types and purpose:
    // Poor: Using abbreviated or generic names
    cap, err := GetModel(n.String())
       
    // Good: Name reflects the actual type
    model, err := GetModel(n.String())
    
  2. Avoid abbreviations unless universally understood:
    // Poor: Unnecessary abbreviation
    type RopeOpts struct {}
       
    // Good: Full word for clarity
    type RopeOptions struct {}
    
  3. Balance verbosity - aim for 1-2 word components:
    // Too verbose
    var templateToolPrefix, templateToolPrefixFound := ToolPrefix(model.Template.Template)
       
    // Better balance
    prefix, found := toolPrefix(model.Template.Template)
    
  4. Be consistent with naming patterns:
    // Inconsistent with other handlers
    func (s *Server) version(w http.ResponseWriter, r *http.Request)
       
    // Consistent with other handler naming
    func (s *Server) VersionHandler(c *gin.Context)
    
  5. Avoid single-letter variables outside of short-lived scopes like simple loops.

  6. In environment variables and constants, spell words completely:
    // Poor: Ambiguous abbreviation
    OLLAMA_GPU_DEVS
       
    // Good: Clear, fully spelled out
    OLLAMA_GPU_DEVICES
    

When choosing names, prioritize clarity for future readers over saving a few keystrokes now.

8
Comments Analyzed
Go
Primary Language
Naming Conventions
Category

Source Discussions