Even with forty years of programming experience under my belt, the only thing I'm really certain about is that there are definitely better programmers out there than me. But I'm not giving up, and I continue to try and improve my programming skills. Here are five things I believe will help anyone become a better programmer. Some are from my own experience; others I've picked up from the web and my fellow programmers.
Find Which Learning Method Works for You
We all learn in different ways. For instance, I'm not a great fan of video learning, and would much rather learn from a book or website. And I’m sure I’m not alone in that opinion: for many folks, a 30-minute video (or even longer) is just too slow. That’s why some of the most popular programming videos on YouTube tend to be rather short—between five and 12 minutes, in many instances. If you have a hard time learning from videos, I suggest you go old-school and read. Back when I started out, compilers came with extensive paper manuals you could read from start to finish. Now all software documentation seems to be online, where you can read it at your own pace. If you’re just not a fan of passive learning—whether video- or text-based—here’s another method that might work: coding competitions. You don’t have to win, but putting your skills against others in a fast-paced environment will often teach you a few new tricks. And if you do win—hey, there’s often a cash prize. Several websites such as Project Euler
and others can all challenge you. Whatever educational method you select, make sure you leave your comfort zone. You need to plunge into the unknown to become a better programmer. Even if you have years of experience, there’s still more to learn.
Simplify Your Code
It’s insightful to read code produced by someone else—so long as the code in question is well-written and easy to follow. If you’re having trouble writing and maintaining code, examining how an experienced programmer handled a similar task is a good way to pick up some pointers. Oftentimes, you’ll find that these pros did as much as possible to simplify their code. Here are some solid simplification tips I’ve picked up over the years: Remove obvious copy-and-paste code.
If you see the same code in different places, it may well be a candidate for becoming a function or method in a class. Split large blocks of code into smaller ones.
Again, you can reduce these huge blocks into functions or methods, even if they’re only called once: a block of code with a meaningful name is easier to follow. You won’t always have the ability to reduce code to single-purpose functions, but it is something that you can aim for. Use refactoring tools to make variable names more descriptive.
Also, add meaningful comments. Start with the simpler functions, so you can understand them, and aim to have at least one line of comment at the top of every function, class, and method.
Learn a Different Programming Language
Again, improving as a programmer means stepping outside your comfort zone. For example, if you know object-oriented languages, try a functional one. For C#, the obvious functional language is F#. Likewise, if you only program desktop apps, try learning mobile or web development; if you know C#, you can use Xamarin for mobile development or ASP.NET MVC for web. I know desktop C# and Xamarin but not ASP.NET MVC, which I recently started an online course to learn. While it probably won’t help your programming, I encourage Windows developers to learn how to use Linux. You can install it on an old PC or your Windows box; if you want to program websites, try setting up an Apache web server on Linux. My preferred method to learn a new programming language is to convert an existing utility or small program. Because you already know what it does and how it works, and you have the output or test results, it really eases your learning curve with the new language. For example, I learned Z80 assembler programming by taking the source code for an existing Z80 editor/Assembler and writing a 6502 cross assembler from it. I didn't have a debugger, which is possibly a little extreme, but it worked for me.
Explore Different Ways to Do Things
This may well be the hardest of these five things to do. When facing a programming problem, my instinct is always to latch onto a particular way of solving it. But there are usually more ways to solve it; once you’ve conquered the problem with your usual method, step outside your comfort zone by re-doing it via a method that’s either faster or uses less memory. It may prove frustrating at first, but it could make you into a more versatile programmer.
Step Through Your Code in a Debugger
You would think that all programmers do this; but during my career, I've met at least two who didn't, and they let a bug slip through to be found by a client. ("Test in Production," I've heard it called, but it’s not a career-friendly move.) If you are confident that your software is bug-free, you could follow the method of Donald Knuth
, a famous computer scientist: He mailed reward checks to anyone who found a bug in software he’d written. Not willing to take that risk? Step through your code. You’ll have a better understanding of what’s going on, identify weak areas in your thinking, and learn what to do (or not do) the next time you build a similar piece of software.
Do I practice these tips? For the most part, yes. As any programmer knows, it’s difficult to find the time to learn and grow when you’re so busy just doing your work. Nonetheless, it’s important to reserve the time to try new things out; keeping your skills as honed as possible is the best way to not only retain your job, but also do the projects that you actually want to do.