I am currently reading the famous book "clean code" by Robert C.Martin... this book transformed and is transforming my whole coding experience, now I am able to understand my own code when I go back to it, before I couldn't lol :).. but there are always cases that I can't apply the clean code principles exactly and purely...so I am wondering whether this clean code issue is like a standard that cannot be followed 100% all the times...but if followed 70% or 80% it is acceptable... or whether I lack enough practice writing clean code?
Coding should be like poetry. Other wise you will be feeling bore after some time. Forgot about writing clean code.
I honestly believe the statement "clean code" is relative to your programming experience at that particular time.
As you get more experienced in programming you learn new and better ways to write or refactor your old code.
I do believe as a programmer you do your best to write code right based on the best principles you know at that particular time. One should avoid writing code that just works but code that works and beautiful too,
You code need to be understandable for every coder that need to work with it. More than clean code, and nice principles it's important to follow a nice code structure, making different classes for different proposes, following SOLID and make all understandable without a single comment in the most of the cases.
More than clean code o shit code, the important thing is if you need to come to the same code in 6 months, you still need to understand the code, and if you need to do something "rare" or "strange" while coding and make sense for the actual situation is nice not no fit to the clean code, but also fit into sense common.
Pragmatism is the most important aspect, in my opinion. Sometimes you need to write something that will need to be maintained by other people or by yourself in the somewhat distant future, in which case your coding practices are really important. Sometimes some logic is so complex that it needs to be expressed cleanly in order to be understood by other developers. Sometimes none of these things apply and it simply doesn't matter.
Personally, I try to keep my code as clean as I can, but I don't allow myself to obsess - or it becomes entirely unproductive.
There's a reason many don't consider programming a wholly exact science. There's a shade of art to it, like in every other type of writing.
One can try to follow every set of guidelines one finds but there are always cases where such guidelines become hindrances or they might just not fit completely with other guidelines. The more "legible" one's code becomes, the more differences with others' code one notices, making "what's entirely clean code" a subjective question.
And, more than guidelines, I feel one learns better from reading generally accepted code; and what's important is that the code is maintainable, if it fits the problem at hand, it makes sense and the average programmer could get up to speed with minimal pain, it's good to go.
Emil Moe
Senior Data Engineer
I like to develop clean code, but I also need to deliver on time. So sometimes I'm struggling and the final product is more important than my perfectionism.
However, I do evaluate on myself and if I need to solve the problem again, I make sure to create a snippet or some kind of package, so next time I don't have to write myself out of that problem once again.
No it's impossible to write clean and perfect code all the time if you want to make a business. But as long as it's maintainable and performing, then you are good. You should adapt a habit of coding for refactoring, meaning you only solve your specific issue but you structure allows you to easily refactor it later when new requirements appear.