https://github.com/szepeviktor/very-clean-code
How to code without future problems ⚪
https://github.com/szepeviktor/very-clean-code
clean-code cleancode code-style coding-standards php
Last synced: 6 months ago
JSON representation
How to code without future problems ⚪
- Host: GitHub
- URL: https://github.com/szepeviktor/very-clean-code
- Owner: szepeviktor
- License: unlicense
- Created: 2022-12-04T09:55:18.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-08T14:15:56.000Z (9 months ago)
- Last Synced: 2025-03-29T21:32:15.862Z (7 months ago)
- Topics: clean-code, cleancode, code-style, coding-standards, php
- Homepage: https://github.com/stars/szepeviktor/lists/theory
- Size: 16.6 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Very clean code
[](https://twitter.com/intent/tweet?text=Found%20useful%20policies%20of%20%40szepeviktor&url=https%3A%2F%2Fgithub.com%2Fszepeviktor%2Fvery-clean-code)
[](https://github.com/stars/szepeviktor/lists/theory)Additions to https://github.com/piotrplenik/clean-code-php
💡 Cognitive Load is what matters https://github.com/zakirullin/cognitive-load
## 🟢 Happy and unhappy path
```
if (error) unhappy path;happy path;
```🖱️ https://szymonkrajewski.pl/why-should-you-return-early/
## 🟢 Arrays versus objects
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
## 🟢 Base value of an array
The base value of an array is not `null` but `[]`.
## 🔴 String manipulation
String manipulation including concatenation is the job of low level libraries as it is highly error prone.
:bulb: Creating messages for UI and logs is not string manipulation.
## 🟢 Write positive conditions
Explicit is better than implicit.
```
❌ if (state !== null)
✔️ if (state instanceof Resolver)
```## 🔴 Mixing programming languages
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## Principles
- 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.
## Support my thinking
Please consider supporting my work, as formulating the conclusions above takes at least several months.
[](https://github.com/sponsors/szepeviktor)
Thank you!