11 rules for writing better code
Briefly

The article emphasizes the importance of not hard-coding values in programming, advocating for the use of constants that clarify their intent. It illustrates how hard-coded values lead to less flexible and maintainable code by providing a specific example of encryption algorithms. The author also touches on the debate around over-engineering, suggesting that preparing for future needs by using interfaces can sometimes appear excessive but is often necessary. Lastly, it challenges the YAGNI (You Aren't Gonna Need It) principle, arguing that failing to anticipate future requirements can lead to a complex and cumbersome implementation later.
Don't hard-code anything, as it limits flexibility. Instead, use constants that explain their purpose to enhance understanding and maintainability of the code.
Over-engineering can sometimes be proper engineering. While simplicity is essential, creating interfaces in advance prepares for future needs.
The YAGNI principle, while sound in theory, can lead to complications if you don’t account for features you know you’ll eventually need.
Every object created inside a class represents a hard-coded implementation. Utilizing dependency injection prevents this and enhances adaptability.
Read at InfoWorld
[
|
]