Software
  • Introduction
  • Code craft
    • Clean code
    • Reusable code
    • Refactoring
    • Code smells
  • Service craft
  • Software Principles
  • Big Data
    • Introduction
    • Data modelling
  • Patterns
    • Enterprise patterns
    • Software patterns
  • Agile & proj management
    • Scrum vs Kanban
    • Kanban
    • Scrum
  • Conflict management
  • Reading
  • Software Architecture
    • Architecture components
Powered by GitBook
On this page
  • How to write it
  • How to enforce it

Was this helpful?

  1. Code craft

Clean code

Clean code that is easy to understand, maintain, and adapt

How to write it

  • Meaningful name for variables. Avoid Manager, Proxy, Data …

    • Use verbs for function names and nouns for classes and attributes

  • Small functions. Rule of nesting levels (max 3 levels)

  • Small function arguments. No more than 3, or encapsulate them into other

  • Single resposability

  • Tested/testable code

  • Use 1 formatting style

  • Comments are appreciated for complex functions (see function complexity)

  • Comments should address the logic/business, not the implementation

  • Don't reinvent the wheel just because you can

  • Don't use a library/framework just because you want to play with it. Side projects exist for a reason

  • Keep it DRY and SOLID (or shorter: keep it simple)

How to enforce it

  • Define coding guidelines

  • Code reviews / pair programming

  • Code analysis tooling (Sonar, linters, compiler configurations)

PreviousCode craftNextReusable code

Last updated 4 years ago

Was this helpful?