DEV Community

Discussion on: What is Perfect Code in your heart?

Collapse
 
sdiamante13 profile image
Steven Diamante

Nothing in life is perfect... including code. Writing code is like writing an essay in school. You start with a rough draft and then write another draft and then maybe another. Developers should make the thing work and then refactor the code until they are satisfied it can be read and understood by others. But it will never be perfect. You should be proud of the code you write. You should look at it with the thought if I saw this code in a month would I understand what is going on within a few minutes. Better yet, if another developer saw this code would they be able to understand what's going on here. Clean code > Perfect code

Collapse
 
peteryuan profile image
PeterYuan

I can't agree with you anymore, that's absolutely right about clean code's importance. though i know there is no perfect. But as a coder ,i always request myself, do my best to code less, that means i will try my best to remove any useless code from program, until i can't remove anything. That's my "perfect" standard, just like write essay, less words to express your meaning and make others understand.Of course, works rightly too.

Collapse
 
djnitehawk profile image
Dĵ ΝιΓΞΗΛψΚ • Edited

in addition to everything you guys mentioned, I always try to think of it from a performance perspective as well. how well this code will scale, am I doing unnecessary allocations, am I blocking threads, am I doing unnecessary context switching, needless locking, etc. also I try not to hypnotise myself with popular design/code patterns just because they're hip. if I ever pick something up, I always ask myself the question WHY? and if I can't come up with a good answer, straight to the trash bin it goes. the only principle i follow religiously is KISS. if you can understand your own code after 5 years then you've done a good enough job.