Programming is full of acronyms
Nobody likes to hear that their code is stupid. It is offending. Donāt say it. But honestly: Most of the code being written around the globe is an unmaintainable, unreusable mess.
Donāt Repeat Yourself and stay DRY
KISS is teling you to Keep It Simple, Stupid!
What makes code STUPID?
- Singleton
- Tight coupling
- Untestability
- Premature Optimization
- Indescriptive Naming
- Duplication
SOLID deciphers to:
- Single responsibility principle
- Open/closed principle
- Liskov substitution principle
- Interface segregation principle
- Dependency inversion principle
GRASP stands for General Responsibility Assignment Software Principles, which are the following:
- Information Expert
- Creator
- Controller
- Low Coupling
- High Cohesion
- Polymorphism
- Pure Fabrication
- Indirection
- Protected Variations
Some lessons and conclusions
Unit testing is important. If you donāt test your code, you are bound to ship broken code. But still most people donāt properly cover their code with tests. Whenever you donāt write unit tests because you ādonāt have timeā the real cause probably is that your code is bad. If your code is good you can test it in no time. Only with bad code unit testing becomes a burden.
Name your classes, methods, variables properly, so that people actually know what you mean. Iām not arguing about variables like $i, those are short, but still self-explanatory. The problem is functions like the ones named above. Functions like strpbrk or variables like $yysstk may be obvious the author, but also only to the author.
Programmers are lazy animals, so it would be only natural to type as little code as possible. Still duplication prevails. The most common reason for duplication is following the second STUPID principle: Tight Coupling. If your code is tightly coupled, you just canāt reuse it. And here comes your duplication.
Source: Donāt be STUPID: GRASP SOLID