I just saw on a blog called Panopticon Central, I saw an entry called Seven Rules for Beginning Programmers. I had to continue the list with some rules (caveat emptor #12 below) of my own.
- Write automatable unit & integration tests and run them on every build. Do not declare yourself to have a successful build until not only everything compiles but also all tests run successfully.
- Make judicious but appropriate use of interfaces.
- Don't overuse inheritance; it leads to brittle hierarchies. Always prefer composition.
- Layer software appropriately. Recognize that even when using an object-oriented language, some artifacts, like service layers & strategies, are procedural in nature.
- Understand the difference between persistent domain objects and data transfer objects, and combine the two only when you understand the tradeoffs.
- Avoid anemic domain models.
- Understand source control, branching & merging.
- Understand aspect-oriented programming, and how it complements object-oriented programming via modularization of cross-cutting concerns.
- Always pay attention to advances in new or existing programming languages, techniques, and ideas.
- Understand dependency injection, inversion of control and how it makes your code less coupled.
- Always keep your business logic independent of the environment in which it will run.
These last two apply to life, not just programming:
- Know the difference between a rule and a guideline.
- When faced with a choice, the one that it is more emotionally difficult for you to choose is often the right one.