Skip to content

ReDevCafe/commit-rule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Variables and Method Naming:

  1. Keep names concise and readable — Avoid variable and method names exceeding 40 characters to maintain clarity.
  2. Use descriptive names — Names should convey meaning without requiring additional comments.
  3. Casing for accessibility:
    • Public members: use PascalCase → Example: FooName
    • Private & Protected members: Use camelCase → Example: fooName
    • Constants: Use UPPER_CASE_WITH_UNDERSCORES → Example: MAX_BUFFER_SIZE

Conditions:

  1. Avoid deeply nested if statements

    • Instead of:

      if(a == b)
      {
      	c();
      }
    • Use:

      if(a != b) return;
      c();
  2. Use early exits to improve readability

    • Bad:

      if(a > 0)
      {
      	if(b > 0)
      	{	
      		c();
      	}
      }
    • Good:

      if(a > 0) return;
      if(b > 0) return;
      c();
  3. Use ternary operators where appropriate, but avoid complexity

    • Example:

      int result = (a > b) ? a : b;

Loops:

  1. Prefer pre-increment (++i) over post-increment (i++) in loops where possible for better performance:

    • Instead of:

      for (int i = 0; i < n; i++)
    • Use:

      for (int i = 0; i < n; ++i)
  2. Use break and continue wisely

    • Avoid unnecessary loop iterations with continue:

      for (int i = 0; i < n; ++i)
      {
      	char* obj = arr[i];
      	
      	if(!obj) continue;
      	process(obj); 
      }

Functions & Methods:

  1. Keep functions short and focused

    • Each function should ideally perform one task only
    • If a function exceeds 100-120 lines, consider refactoring
  2. Use meaningful parameter names:

    • Bad:
    void process(int a, int b) { ... }
    • Good:
    void process(int width, int height) { ... }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors