I wrote this set of programming principles for my team to follow back in 2012. I’m sure there are many like it, but this one is mine. May you find it useful.
Try to write expressive code.
Beware code bloat - adhere to the YAGNI principle
Practicing Behaviour-Driven Development can help with both of these aims.
Do less: Before writing a new piece of functionality, go and look for similary solutions that already exist and extend them.
Namespace your classes, and code to an interface (this is an implementation of the Design by Contract principle), and make your interfaces (both programming interfaces and user-interfaces) as simple as possible.
Try to learn and comply with all 5 principles of SOLID (watch this great video).
Learn as many Design Patterns as you can to inform your coding, but beware of implementing them blindly. Developers can be over-zealous in their use of Design Patterns and may end up over-engineering a solution.
Some useful design patterns:
- MVC (obviously)
- The observer pattern (events)
- The adapter pattern (for useful abstraction of layers - like the data layer)
- The factory method pattern (although be careful: Creating multiple factory classes is often overengineering)
Try to learn an IDE with advanced features. These can really save you a lot of time:
- Syntax highlighting
- Auto-complete for function, class and method names
- Code navigation help - e.g. jump to class declaration
- Collapsing of code blocks
- Overviews of code, e.g. a list of all methods within a class
- Debugging tools like break points