Pattern: Inconsistent naming style in codebase
Issue: -
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.
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;