A Professional Craftsman Journey #5
When I first started out using a computer, I had to look at keys on the keyboard for whatever thing I wanted to do, I was a gamer, so looking at keys was not an option.
Sooner I joined the MMOs (Online Games) fan-base and started to play action-based games like Battlefield, Warframe, Tera, and another bunch of stuff that made me enjoy my childhood and my teenage period.
Of course, I had to drop down the habit of looking at the keyboard when typing to either talk to one of my teammates when we were under attack or try to warn somebody before we lose one man in our team, this gave me confidence.
Same with coding, I used to type a lot, and quickly, and whenever I made an error, I'd just clear the text and retype it again, this game me a sense of mastery to my craft, where whenever I feel that I made an error, I'd just fix it, this is what I called a Spidey-sense or an error-sense as Uncle Bob calls it
Being able to sense your errors is important, like really important, not just in typing, but in everything. Having an error sense means that you are rapidly close to the feedback loop, and learn from errors all more quickly.
So as I've experienced and like what Uncle Bob mentions in his book "Clean Coder", the key to mastery is confidence and error-sense
So, let's talk about some rules and principles that define who a clean coder is...
these principles and rules don't describe the code, but the coder himself, like his mood, his behavior, his attitude all while writing code, they describe his own mental, moral, and emotional context for writing code, they are the root for confidence and error-sense
As we all know, coding is an act that requires tons of concentration and it generally exhausts people, even tho we spend most of our time sitting on a desk, punching some keys to an editor of some sort, and generally trying to teach a computer something so that he may help us, seems simple, huh? well not quite right, in this act you exert a lot of brainpower every day for 8 hours, and if you followed my post about how professionals spend more time than anyone to improve themselves, you know that I spend a lot more than just 8 hours a day.
so what are the principles here?
First, your code must work. You must understand what problems you are solving and understand how to solve them. you must ensure that the code you write is a faithful representation of that solution. you must handle every detail of that solution while remaining true and consistent with the language, platform, current architecture, and all the rules of the current system
Your code must solve the problems requested by your client, often sometimes the client's requirements don't actually doesn't solve the client's problems, but it's up to you to figure out how you can negotiate with your customer, to truly deliver something that makes his life better
Your code must fit well into existing systems. It should not increase its rigidity, fragility, nor its opacity, the dependencies must be well-managed, in short, your code must follow SOLID principles
Your code must be readable by other programmers, either existing ones in the team, or newcomers, this is not simply writing nice comments everywhere around, rather it requires good craftsmanship skills to help you design the code in a way that reveals your intent. This is hard to do. Indeed, this may be the most difficult thing a programmer can master
3 AM Code
Often we find ourselves tempted to work extra hours, or maybe our client wants to see a feature done quickly, I discussed in my previous post why this is wrong, but in this section, I'll write more about why this is absolutely wrong, in this post, I'll write more about why exceeding your daily 8 hours is a complete waste of time.
So why is it a waste of time to stay up till 3 AM coding is wrong? Quite often when we do this, we enter a state of frenzy, a state where you think that you are the best coder in the world, nobody can beat you, that you will gain massive riches and compliments from your manager.
but what happens next morning when you finally hit that deploy button and go to sleep?
people are furious with you, and not to mention that you need to refactor, clean tons of code that was not well-thought, and you even ask yourself, what the heck were you thinking of when writing this mess
This is not how professional people work, they don't spend mad hours on the computer, they don't keep themselves awake until sunshine to meet a deadline, rather they discipline themselves with rules, they know very well that Dedication and professionalism is more about discipline rather than hours
Make sure that your sleep, health, and lifestyle are tuned so that you can spend 8 good hours per day