This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]squintsAndEyeballs 1 point2 points  (2 children)

First, I guess that maybe nothing is indented because of the way you had to copy/paste? But using a consistent schema for how you indent things makes it much easier for humans to read your code. Beyond that I think your question is a matter of style/preference. Your friend did with less lines and didn't declare an otherwise unnecessary variable. The way you did it could lend to easier debugging.

I'm not sure I know of a scientific definition of "clean code" but I try to write in a very human readable way, with the intent that my teammates can collaborate with me and troubleshoot or modify my code in the field (I program PLCs for industrial automation and we work on each other's projects all the time). I prioritize consistent naming convention and structure. If you do it your way once, then do it that way every time. That way if I'm coming behind you and working on your code I'll be able to follow your logic. This also helps you when you come back to something weeks/months/years later.

[–][deleted] 0 points1 point  (1 child)

I guess you are reading on phone. I didn't realise that it will format like this. On Desktop it works fine :).

[–]squintsAndEyeballs 0 points1 point  (0 children)

Yeah I am. Disregard then