Skip to content

Latest commit

 

History

History
62 lines (47 loc) · 1.47 KB

naming-convention.md

File metadata and controls

62 lines (47 loc) · 1.47 KB

Pattern: Inconsistent naming style in codebase

Issue: -

Description

Mixed naming styles across identifiers (variables, functions, classes, interfaces) makes code harder to read and maintain. Each type of identifier should follow consistent conventions for casing (camelCase, PascalCase, UPPER_CASE), prefixes, and special characters like underscores.

Examples

Example of incorrect code:

// Mixed casing styles
const my_variable = 'value';
const MyVariable = 'value';
const MYVARIABLE = true;

// Inconsistent interface prefixes
interface UserData {}
interface ICarData {}

// Inconsistent private member marking
class Example {
  private _secret = 'hidden';
  private visible = 'also hidden';
  
  // Boolean without verb prefix
  ready = false;
}

// Mixed casing in type parameters
type Handler<t> = (value: t) => void;
type Processor<Type> = (data: Type) => Type;

Example of correct code:

// Consistent camelCase for variables
const myVariable = 'value';
const userCount = 42;

// PascalCase for type-like structures
interface UserData {}
interface CarData {}

// Consistent private member marking
class Example {
  private _secret = 'hidden';
  private _visible = 'also hidden';
  
  // Boolean with verb prefix
  isReady = false;
}

// Consistent PascalCase with T prefix for type parameters
type Handler<T> = (value: T) => void;
type Processor<TData> = (data: TData) => TData;

// UPPER_CASE for constants
const MAX_RETRY_COUNT = 3;
const DEFAULT_TIMEOUT = 1000;