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?
- Tight coupling
- Premature Optimization
- Indescriptive Naming
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
- Low Coupling
- High Cohesion
- Pure Fabrication
- 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