News for hackers. Stuff that matters.
Re:Cognitive Biases in Software Development by ravenstine on Tuesday March 31, 2020 @02:55AM (#22735444)
I think what's worse than that obsession, and perhaps is actually what you meant, is the concept of "elegant" code.

Elegant code is easily just as bad as spaghetti code. I can't even begin to quantify how many hours of my life were wasted because someone thought it was more important to make something elegant rather than understandable. I get that it's satisfying to make something that "makes sense" if you've built a mental model of the problem from the beginning, but if it's incomprehensible to others(without serious devotion to figuring out what is going on) then it might as well be crap in the first place. At least spaghetti code can be fairly easy to hack because there's usually lots of duplication and specialized code, making it straight forward to step through with a debugger and make a change without mysteriously borking the entire app. Elegant code, ironically, can be more flimsy because it's usually written assuming that the system stays perfect, and changes to the system reveal single points of failure.

Clean code can be written without necessarily going overboard with elegance to the point where it's not easy to understand. Even dirty code can be workable given documentation(can just be comments explaining what things do) and consistency.

Re:Cognitive Biases in Software Development by collyw on Tuesday March 31, 2020 @09:07AM (#22737098)
I always thought "elegant" code was clean, concise and understandable.

Edit: Stack Exchange seems to agree that readability is part of what makes code elegant. https://softwareengineering.stackexchange.com/questions/9791...

Re:Cognitive Biases in Software Development by UK-Al05 on Tuesday March 31, 2020 @03:45AM (#22735635)
Clean code has always meant to simple, easy to understand, not elegant.
Re:Cognitive Biases in Software Development by collyw on Wednesday April 01, 2020 @05:54AM (#22747148)
I don't think they are mutually exclusive.

In a recent interview question I was asked to find the largest three numbers in python list. My first attempt looped through the starting list, comparing the number to the previous minimum number in the result list - replacing the number if it was larger. I needed a get_minimum(function). It was the obvious solution that came to my head at thr time.

An hour later I realized a far more elegant solution was to sort the list and slice the last three elements. It felt far more elegant to me and was as easy to understand as the initial obvious solution that came into my head.

(Though this is why I dislike these type of interview questions. the first solution in an interview situation is not always the best or final one)