You should be able to develop your code and design sense to the point where you can look at anyone’s code (including your own) and intuitively know if it’s good or not. This is a critical skill to have if you are responsible for doing code and design reviews.
Here’s some suggestions based on what I’ve done.
Table of Contents
Study design patterns and antipatterns
It’s important to know what you should do (via positiva) and what you should NOT do (via negativa).
Studying design patterns is a way to understand what people have typically done to solve a particular design problem. These are good to know. For this my suggestion is:
- Read some design patterns book. I liked Head First Design Patterns.
On the flip-side it’s important to know what NOT to do. Instead of focusing on applying design patterns to every single problem and overengineering your code, it’s a good idea to learn about antipatterns and refactoring.
I suggest reading these two books:
Study good code, code smells, and refactoring
Read the following books:
- Code Complete. This is hands down the best coding book I’ve ever read. It covers everything you need to know.
- Clean Code
- Programming Pearls
Lots and lots of practice
- Do coding katas. I prefer CodeWars. Here is my method:
Note: It’s ok to give up on a problem, but make sure to go look at other peoples’ solutions to understand what you weren’t able to solve.
- Do refactoring katas. What I do:
- Clone a repo
- Refactor the code little by little. Look for small, easy wins at first. As you refactor small things, larger refactorings will become apparent.
- Diff the original code with the refactored code so you can see how you’ve improved it
Use different languages and write different types of programs. Don’t get too comfortable!
The main point of this article is to help you improve your code and design intuition. A good way to do this is by getting out of your comfort zone.
Here’s some ideas: