4 ms·
Over the past few years I have grown disillusioned by the seemingly hyper focus on clean code concept. It seems perfectly logical to have readable code. But t
by sidcool 7y ago
Over the past few years I have grown disillusioned by the seemingly hyper focus on clean code concept. It seems perfectly logical to have readable code. But the excess that we programmers do with the concept.
- Gibbon1 7y agoBefore I worked on firmware I worked on PCB layout. Thing you learn from that is you can keep fucking with the layout forever and it is simply pointless from a business perspective. Spend an extra day 'cleaning up' the layout. Well sweet now your delivery slipped a day. Also experience with redactoring away a wart only to find there is now a wart somewhere else.
- saberdancer 7y agoDifference with PCB is that it is normally one off job. If you are building a one off application or a script, clean code is not very important. If you are building a system that will be used for years and needs to be extensible than it makes much more sense. Just like it would make sense if you got your PCB back and needed to change features or add new ones.
- devurand 7y agoExactly. I did layout for awhile. Some boards you knew weren't going to come back. Customer was just paying for us to turn a schematic and BOM into a board with the least amount of cost possible. Quoted low. You could let the autorouter have at it. But other boards (especially finicky high clock speed chip tester boards) would definitely be coming back. Sure you could let the autorouter do its thing, but when that board came back for a rev, I'd have to fuck with all of that laziness to make space for new components or reduce the layer count.
- tartoran 7y agoSometimes clean code also means simple, less bloated with features that promise but don’t deliver and smaller sized projects in general
- ravenstine 7y agoI 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.
- UK-Al05 7y agoClean code has always meant to simple, easy to understand, not elegant.
- collyw 7y agoI 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)
- collyw 7y ago