Additions to https://github.com/piotrplenik/clean-code-php
💡 Cognitive Load is what matters https://github.com/zakirullin/cognitive-load
if (error) unhappy path;
happy path;
🖱️ https://szymonkrajewski.pl/why-should-you-return-early/
An array is a dumb container of unknown data. Arrays should be used to store lists: keyless elements of the same type. BTW strings are containers of unknown bytes.
🖱️ https://github.com/CuyZ/Valinor
The base value of an array is not null
but []
.
String manipulation including concatenation is the job of low level libraries as it is highly error prone.
💡 Creating messages for UI and logs is not string manipulation.
Explicit is better than implicit.
❌ if (state !== null)
✔️ if (state instanceof Resolver)
Have low-level libraries connect different languages.
- Main language + SQL: ORM
- Main language + HTML: template engine
- Main language + JavaScript: JSON
- Main language + CSS: use CSS classes and CSS variables
-
Abstraction: strive to make deeper layers do the work, write less project-specific code.
-
Be explicit! Implicit things need more brain work thus are error prone.
-
There are only two hard things in Computer Science: cache invalidation and naming things.
— Phil Karlton
Gain knowledge of things, so you can name them.
Please consider supporting my work, as formulating the conclusions above takes at least several months.
Thank you!