1. Apply Clean Code guidelines ✨

  • 📖 Readable code: Write code that’s easy to read and understand. Use meaningful names and consistent formatting.
  • 🔧 Small functions: Functions should be small and do one thing only.
  • 🚨 Error handling: Handle exceptions gracefully using try-catch blocks and provide meaningful error messages.
  • ♻️ Avoid code duplication: Extract reusable code into functions or classes.

2. Coding standards 📝

🔤 Naming conventions

Follow consistent naming conventions for classes, methods, variables, and resources:

  • 📦 Classes: PascalCase
  • 🔧 Methods & variables: camelCase
  • 🔒 Constants: UPPER_SNAKE_CASE
  • 📁 Resources: Use prefixes for clarity (e.g., activity_main.xml, ic_launcher.png)

🎨 Code formatting & linter

Adhere to Kotlin coding conventions. Use detekt for automatic code style checking and static analysis checking. Here’s the detekt.yml configuration we use for our projects:

# Naming rules
naming:
  ConstructorParameterNaming:
    active: false
  VariableNaming:
    active: false

# Style rules
style:
  ForbiddenComment:
    active: false
  MaxLineLength:
    active: true
    maxLineLength: 120

# Complexity rules
complexity:
  TooManyFunctions:
    ignorePrivate: true

🗒️ Documentation

Comments and documentation: Write clear comments where necessary, but favor self-explanatory code. Use KDoc for documenting complex functions and classes.

3. Apply the SOLID principles 🛠️

  • Single responsibility principle: Each class or function should have one responsibility.
  • Open/closed principle: Code should be open for extension but closed for modification. Use interfaces and abstract classes to add functionality without altering existing code.
  • Liskov substitution principle: Subtypes must be substitutable for their base types without affecting correctness.
  • Interface segregation principle: Use small, specific interfaces rather than large, general ones.
  • Dependency inversion principle: Depend on abstractions rather than concrete implementations.