7 programming techniques that quietly make you elite

Programming requires a varied skill set, from low-level coding to high-level tasks like communication. The following tips have helped me improve during my programming career.
Avoid premature optimization
Beginners write inefficient code and advanced programmers write optimized code. But real experts know when to optimize their code and when not to.
In truth, there really is no such thing as “optimized code”: code can be optimized for speed, for memory usage, or for several other factors. But when we talk about premature optimization, we’re usually talking about attempts to optimize for speed, which usually comes at a different cost.
The cost may be related to memory usage, the size of your program, or the overall design and maintainability of the program. Optimization often requires techniques that are much more difficult to master than the alternative, which can make the code harder for others to understand, or even confusing for you in the future!
Try to avoid optimizing your code too early in its lifecycle; At least avoid making it the central point. Test your code, measure its performance, and understand which parts of it can benefit from optimization.
Collaborate with others
Most of the ways you can improve as a programmer involve collaboration to some extent. Even if you’re working entirely alone on a codebase, you’ll need to collaborate with other versions of yourself: the you who’s tired, who’s moving on from another project, or who has more knowledge than the current you.
But best practices aren’t just a matter of self-interest: the vast majority of programmers will end up working on code with others at some point.
Working together is a complex soft skill, so don’t feel bad if it seems difficult at first.
Whether it’s pair programming, working with a project manager on GitHub, or using an AI assistant, practice makes perfect. You will learn to accept suggestions from others, explain your own approach, and respect differing opinions.
It’s not just a general skill. Tools like GitHub and Slack can make a big difference, especially if you take full advantage of them. Being able to write clearly understandable code (or prose) can make you a valuable addition to any team.
When it comes to programming, you’re never short of tools to learn. Whether it’s fundamentals, like your language and tech stack, or small utilities that make your day go more smoothly, you should always be on the lookout for extra help.
This technique isn’t even necessarily about using the best tools, but about using them in the best way. Instead of worrying about your choice between Vim and VSCode, choose one (after doing your research!) and get to know it well. Really good.
I still remember how enlightening it was to see a colleague, a Vim master, at work early in my career. They flipped through files with ease, navigating in ways I couldn’t even understand, making drastic changes with the press of a key. And that was nothing compared to the colleague who used Emacs!
Finding a tool that makes you a better programmer is exciting because it’s often cheap and gives you an instant, permanent upgrade.
Write appropriately sized programs
The Unix philosophy states that software should “do one thing and do it well.” This approach is not dependent on Unix, so you can apply it anywhere else and you will likely see benefits.
Writing smaller programs means they are easier to maintain and can help you accomplish a wider range of tasks. You can combine small tools to work together, using features like pipes and redirection, which helps reduce reliance on a monolithic application.
Fix the current problem
The problem you are trying to solve is closely related to the size of the program. Sometimes you can influence this by breaking the task into smaller parts and solving each with a separate program.
Often, however, you will have a clearly defined task, but the details can influence your focus. It’s easy to aim either too specifically or too broadly. The first approach can result in code that is too closely tied to a single problem, which is then difficult to adapt if the problem evolves. This can lead to costly rewrites, which not only take time and effort, but also increase the risk of introducing bugs.
Meanwhile, overgeneralizing the problem can create a task that goes far beyond what you actually need. It’s tempting to keep generalizing, trying to solve an increasingly useful or interesting challenge, and end up working on a “program to solve all problems”, which is far removed from your true priority.
Write functions of the appropriate length
In the same spirit, the constituent elements of your code (the functions) must also be of a reasonable length. We’ve all had to deal with programs that consist of one giant function, and they’re much harder to follow, reason about, and modify.
Conversely, it’s possible to go too far: if each function is just a single statement, you’ll end up with code that’s just as confusing and confusing as the opposite extreme.
Personally, I like a feature that fits on one screen, so I can review everything it does without scrolling back and forth. I find this is generally a useful guideline for keeping functions manageable, although it obviously depends on your screen size, font size, and line length, among other factors. Some languages, for example, lend themselves to more verbose or concise code, so be sure to use your own judgment.
Know how to write a pure function
When it comes to functions, the one thing that has made me appreciate well-written code more than anything is the use of pure functions.
A pure function is, simply put, a function that does nothing other than return consistent output. Here is an example:
int max(int a, int b)
{
return a > b ? a : b;
}
This function only returns one value, and every time you call max(1, 2) you will get the same result. On the other hand, here is an example of an impure function:
function print_random(array) {
const n = array.random();
console.log(n);
return n;
}
This code has a side effect: it prints to the console and it can return different results even with the same input.
Pure functions are much easier to combine because they are more predictable. They are also much easier to test, since you can check their expected result. This doesn’t mean that every function you write must (or even can) be pure, but you should look for opportunities to purify your code base and make it more reliable.




