Six language-independent ways to write better code
Résumé:
- Plan for extensibility
There are many simple suggestions that can help extensibility: Don’t code specific solutions — code generic, reusable libraries. Don’t assume the length or size of anything will be constant. Version all your user-data files. Use encapsulation.
By far the most time spent in any stage of the software life-cycle will be spent in the maintenance phase — so it is imperative to design your software in a way that encourages easy maintenance — and that means designing for extensibility. - Don’t use magic numbers
- Document why, not what
If your code really needs a comment to explain what the code is doing, your code probably needs to be refactored or simplified, not commented. - Don’t reinvent the wheel
- Work incrementally
- Find someone willing to criticize your work
Conclusion
Doing the right thing now will give you more time in the future to continue doing the right thing.