Ah, the Holy grail of programming. You should learn, because learning is what makes the difference:
- Know the language you are working with. Read manuals. Read all the stuff you can about it. Learn the language inside and out. Doubt what you read, make experiments. This is important: To really learn, you need to test and experiment for yourself. Make up your own mind.
- Check parameters in every function. Learn defensive programming. Make sure your code is solid, in the sense that it is almost impossible to use incorrectly, it is impossible to break.
- Learn best practices. This is different than mere manuals, because manuals have all the important information, everything you can do with the language, but they don’t distinguish between: “this is a good practice” and “this is going to be bring you problems down the road.”
- Learn design patterns. The idea of design patterns is to make your code more dynamic, in the sense that changing requirements can be accepted. See GoF design patterns. If you have time also read the anti patterns.
- Learn object orientation. It is a way to order your code, not a way to “model the world”—that is the wrong approach. You need written requirements and work from there. A design is comprised of design decisions. Number requirements. For every requirement there must be at least one design decision that at least conceptually solves the requirement. Create a prototypes for every design decision to show it works. Use source control to store prototypes.
- Automated unit testing. Unit test everything. This is what makes the difference between wannabes and real programmers.
- Learn make, ant, maven, gradle, or whatever tool you can use to make one step compilation.
- Avoid memory leaks.
- Avoid resource leaks.
- Use issue trackers to store your backlog. That way you can always remember what is missing or how you solved things. If you are using Scrum, Kanban or XP, you can always copy issues from the issue tracker into sticky notes. You will end up doing it anyhow, because looking at a scrum board makes it so much easier to see what is missing.
- Dry and not wet: dry = don’t repeat yourself, wet = write everything twice. No repeated code, period.
- Methods no longer than 10 lines.
- Classes contain no more than 10 methods and 3 instance variables.
- According to Bertrand Meyer, when your design is too complex, you need more classes.
- One responsibility per class, and only one class per responsibility. That responsibility should go in a comment at the beginning of said class.
Different languages have different rules and best practices. You should look for the best practices in the language you are using.
And question things. Make sure those ideas are really the best ones, the only way to learn is to try.
This question originally appeared on Quora: How do I become a good coder and what should the ideal characteristics of a good coder? Answer by Guillermo Schwarz has spent over twenty years developing software.