At Xojo we’re a company of programmers who work with programmers and after 21 years or so, we like to think we know our stuff. In honor of International Programmer’s Day today, we’d like to offer our experience in the form of a listicle. 😉
Whether you’re new to programming or an experienced developer, there are some things you’ll just never find in a reference manual. We’re passionate about writing good code and these are our 10 tips to be a better programmer.
1. Be curious – ask questions and seek answers
Computers aren’t magical. They do things in a methodical and predictable way. If you are curious about why they are doing what they are doing, you can learn a lot.
2. Be methodical
Computers follow the steps we tell them in our code one after the other (even in multithreaded programs although there can be fun side effects in this case). They start at the beginning and work their way along until they either finish, the user quits them or maybe – unfortunately- they crash. But they just do what we tell them.
3. Read the docs
No matter how many times you do something if you have problems read the documentation. You may learn something new from them even if you’ve been doing it for years. (This ties into point #1 as well). Documentation is there to help you learn how to use things.
4. Try things out
It usually can’t hurt… well, unless you’re writing something that may wipe out data on a hard drive, etc. In that case, you should have “testing” set up to be able to try out ideas – version control systems can help here.
5. Don’t be afraid to get help
Ask colleagues, friends, forums or wherever else you can get help AFTER you’ve read the docs. Being self-reliant and self-sufficient is, in many ways, the mark of a good programmer. They try out things and exhaust the resources they have ready access to before they come asking for help in emails lists and forums. Members appreciate it when they can say, “Did you try …” and the reply is, “I tried everything like ….” with a long of things already tried. Often we see forums, Twitter and Facebook are used as the first thing consulted without having looked over docs or existing samples and examples.
6. Learn from those who have come before you
The best thing a person can start out doing is maintenance work, you’ll learn good habits and those bad habits to avoid in code. And applying steps 1 to 5 along the way will result in learning a lot more. And hopefully you’ll have a good mentor!
7. Be a mentor
Sharing what you know with those less experienced helps you become better at what you do. You HAVE to know your subject VERY well in order to teach someone. Teaching is the best way to learn, even if you’re not that good, but answering questions (and maybe researching the answer) will only help you too.
8. Learn about design patterns
9. Review code, acquire ideas, refactor, and then do it again and again and again
Code is never “done”. It always needs to evolve, be updated, or rewritten. Get in the habit of reviewing your code with other programmers you work with. Even when you think it’s perfect, a different set of eyes can often find something you hadn’t considered or an optimization. A code review revealed a great one for me that I wrote about here.
10. Be brave
Don’t be afraid to tackle hard problems or to fail. It’s how we learn.
Bonus Tip: Look at various programming languages
Even check out ones you’ll likely never use! It helps you gain perspective on how other languages approach solutions and problems. Sometimes that perspective is whats needed to figure out how to solve a problem.