clean code commandments
Mini essays,  Books,  Code

Another clean code bullet points to remember

Some thoughts after reading a lot of stuff lately and working on totally diferent things. It is just another clean code bullet points compilation to remember or recall every know and then.

  1. Complexity is the main problem in software design: Managing and reducing complexity is crucial for creating maintainable software. Three main issues caused by complexity: change amplification, cognitive load, and unknown unknowns.
  2. Two main sources of complexity: dependencies and obscurity. Dependencies make it hard to understand and modify code, while obscurity hides important information.
  3. “Deep modules” with simple interfaces that hide complex implementations, reducing cognitive load.
  4. Strategic & Tactical Programming: Tactical programming (quick fixes) and strategic programming (long-term design). Strategic programming focuses on reducing complexity over time. Critique of Agile: Agile methodologies are encouraging tactical coding over strategic thinking, advocating for a focus on abstractions rather than just features.
  5. But on the other hand iterative software design is good, where decisions are revisited and refined over time, rather than decided one-time upfront.
  6. Developers should allocate 10-20% of their time to strategic design to improve long-term outcomes that wshoul be beneficial 99% of time. Encapsulating complexity through modular design allows developers to work on parts of a system without needing to understand its entirety.
  7. Encourages thoughtful commenting and documentation practices, focusing on clarity rather than excessive comments. Any standard is better then none. Naming Conventions: Choosing meaningful names is crucial; if naming is difficult, it may indicate underlying complexity in the code where a comment might help.
  8. Reccommendation of code reviews to identify and address complexity issues, ecourage design principles are applied.
  9. Done not optimize prematurely, suggesting a balanced approach to performance and simplicity.Usually simple approach is always more performant.
  10. Encourages a philosophical approach to software design, where developers constantly think about and refine their design practices to manage complexity effectively.
  11. Red flags can look like :
    Shallow modules, classes, objects
    Information leakage
    Temporal decomposition
    Overexposure
    Pass-through methods
    Repetition
    Special generic mixture
    Cojoined methods
    Vague names
    Nonobvious code and functions
  12. Define errors out of existence for simplification.
  13. Comment should describe non obvious things or make a nice highlight of the code
  14. Put the most important things in the center, hide anything else ( especially the implementation ).
  15. Remember that You (in general) write the code to make someone else understand it as easily as possible. Including You in one year.

I know that nobody is capable to remember about all of it all the time. God knows it cannot implemented anyways. I love how people dance cause inventing 3 layers of abstraction to avoid simplicity 🙂
Let us remember the most noble truth of them all…

Common sense…

Like a brain, remember to use it.

Piotr Kowalski