Live data from Hacker News

It's probably time to stop recommending Clean Code (2020)

qntm.org

201–210 of 216 posts

Re: It's probably time to stop recommending Clean Code (2020)

#201
post #114

Earlier quoted context omitted.

I think you can easily roll an analogy with having a plan documented on 5 napkins, bits sprinkled over 127 emails, a few doodles on a white board, 93 photos on your phone, some files in some folder and 20% in your head. You could start execution right away! Every bit of information is readily available, sure, the numbers in those emails might change in the process but you can just document those changes on additional…

That makes sense. But how do you retain your sanity and job satisfaction if you’re not an early part of that first phase?

I suppose you could keep your eyes more on what you've done rather than what needs to be done?

Re: It's probably time to stop recommending Clean Code (2020)

#202

Earlier quoted context omitted.

If you say the book “covers correctness and understandability in nearly every paragraph” then I’m convinced we must be talking about different books. For example, the book presents a rule for class names: > Classes and objects should have noun or noun phrase names like Customer, WikiPage, Account, and AddressParser. Avoid words like Manager, Processor, Data, or Info in the name of a class. A class name should not be…

Let’s say my site has a download image feature that embeds per-user digital licenses into downloaded images at download time. This might take some processing so there is a queue and an abstraction representing the downloaded file. There are also several endpoints serving different types of image files. What shall I call the unit of code orchestrating these download processes, if not ImageDownloadManager?

How about ImageDownloader?

Re: It's probably time to stop recommending Clean Code (2020)

#203
post #99

My experience is that I run into a lot of relatively junior programmers who are concerned about clean code. Is my code clean? How do I organize my code? How do I make it clean? Should we clean up this code? I almost never want to use the word “clean” when I’m talking about code. These days, when someone asks me to review code, and they start talking about “clean” code, I shift the discussion to two points—code should…

> Like, “you shouldn’t use boolean flags as parameters, you should use enums” becomes “I can‘t understand the meaning of true/false at the call site, so let’s use an enum instead”. That's not the reason to use enums instead of parameters for functions, rarely will you not be able to understand what the bool arg means in: create_user(..., is_admin: bool) If you don't then you need a better IDE. The reason to use enums…

If you tried to check in code with a 2-member enum I would try and stop you ("don't reinvent booleans"). Honestly this is totally fine early stage code, but I could try and mollify you with two functions, which feels more YAGNI. If we end up being wrong about that, we probably need more of a role/rights system than an enum will provide (I bet, for instance, you'll have a lot of business logic per-role that shouldn't just get stuffed in a single function).

This is what drives me nuts about seemingly simple rules like this: they let you feel like you can turn off your brain. You check all the boxes Clean Code tells you to and you feel like you're done. But you need to think systemically, and little simple maxims like "don't use bool flags" or "enums > bool flags" let engineers miss the forest for the trees over and over again.

Re: It's probably time to stop recommending Clean Code (2020)

#204
post #83

Earlier quoted context omitted.

Clarity! That's my goal for my code: https://m.youtube.com/watch?v=6sNmJtoKDCo

IMHO, that was an excellent talk, well presented and insightful. I found your argument starting around 28:00 interesting. I’m not familiar with the specific tools you’re using and their idioms, so it’s possible that I’m missing some context here. As a general principle, I like to make it very clear where code is doing I/O and what is happening with any data involved. If this function receives data in one format, tran…

Ah, the talker is not me, I'm just a fan of the concept

Re: It's probably time to stop recommending Clean Code (2020)

#205
post #26

Slightly offtopic but I have summarized my own 20 years of clean coding experience into a system: https://www.fabianzeindl.com/posts/the-codequality-pyramid

I like that post of yours. If there's one thing I slightly disagree with, it's that I would put Code Performance below Test Performance, but that's because my personal experience ([1]) has been that code performance affects test performance more than anything else. But still, this is an excellent model, and I'm bookmarking it. Thanks! [1]: https://gavinhoward.com/2019/08/why-perfect-software-is-near...

Thank you, let me know if you have suggestion and how whether you can apply it to your work.

Re: It's probably time to stop recommending Clean Code (2020)

#206
post #76

Earlier quoted context omitted.

I like that post of yours. If there's one thing I slightly disagree with, it's that I would put Code Performance below Test Performance, but that's because my personal experience ([1]) has been that code performance affects test performance more than anything else. But still, this is an excellent model, and I'm bookmarking it. Thanks! [1]: https://gavinhoward.com/2019/08/why-perfect-software-is-near...

I think that in terms of "what to strive for", the pyramid makes sense in a generalist way. And, code performance is, as you say, part of test performance. If the tests take too long, perhaps the code needs to be improved. OTOH, I have got a few test suites that run for 30 minutes or more, just because the search space is so big. But that's code that only needs to be tested once.

> And, code performance is, as you say, part of test performance. If the tests take too long, perhaps the code needs to be improved.

Yes. I mentioned this is in the last section. When test-performance is alright, typically you don't need to optimize code anymore.

For me, optimizations in the "code performance" category are for example trading off a generalist API for a more complicated tweaked version that reaches into details and enables caching. The kinds of optimizations game developers do where they make the code less general and pretty, but more performant.

> OTOH, I have got a few test suites that run for 30 minutes or more, just because the search space is so big. But that's code that only needs to be tested once.

What are these suites testing?

Re: It's probably time to stop recommending Clean Code (2020)

#207

Earlier quoted context omitted.

IMHO, that was an excellent talk, well presented and insightful. I found your argument starting around 28:00 interesting. I’m not familiar with the specific tools you’re using and their idioms, so it’s possible that I’m missing some context here. As a general principle, I like to make it very clear where code is doing I/O and what is happening with any data involved. If this function receives data in one format, tran…

Ah, the talker is not me, I'm just a fan of the concept

Ah, sorry, I misunderstood. In any case, it seems we probably agree! :-)

Re: It's probably time to stop recommending Clean Code (2020)

#208
post #8

A common theme not only in software but other industries: Beware of people selling you advice. They are the ones who will breed dogmatic illogical cargo-cults of people whose only rebuttal when questioned is some variant of "because someone who sold me this book that claims it'll make my code better said so", and that can't be a good thing in general. but we assume that Martin doesn't literally mean that every functi…

Have you worked with 5000 line functions? Just trying to set breakpoints in them at meaningful points is a nightmare. Give me 1000 5-line functions any day - providing of course they have sensible names (and ideally don't cause unexpected side-effects etc., though when a function is 5-lines long, that's fairly easy to spot; in a 5000-line function, fuhgeddaboudit. My personal guideline is "it should fit on a screen"…

The first thing I do when refactoring spaghetti messes is to remove all useless and counter-productive functions and abstractions, so I can actually get one single, huge function containing all the process.

Only from there it becomes possible to have the broad view, reorganize and (re-)factorize the code again properly.

So if I had to choose between both, I'd take the 5000 lines function any time, since it makes my job easier.

Re: It's probably time to stop recommending Clean Code (2020)

#209

Earlier quoted context omitted.

> It would be prudent to include some data to substantiate your insinuation [0] https://www.businessinsider.com/boeing-outsourced-737-max-re... [1] https://www.bloomberg.com/news/articles/2019-06-28/boeing-s-...

https://news.ycombinator.com/item?id=20353342#20355864 . Hope this link works . This discussion was 2 years ago. Still my word holds good . Boeing management didn’t give crap about engineers opinion be it 30$ per hour or 5$ per hour.

Boeing asserted that no "critical flight software" was outsourced, but it specifically didn't label the MCAS as "critical flight software" when describing it to the FAA.

What we know was outsourced is "flight test software" which sounds a lot like something that should have caught the 737 MAX failure...

Re: It's probably time to stop recommending Clean Code (2020)

#210
post #76

Earlier quoted context omitted.

I think that in terms of "what to strive for", the pyramid makes sense in a generalist way. And, code performance is, as you say, part of test performance. If the tests take too long, perhaps the code needs to be improved. OTOH, I have got a few test suites that run for 30 minutes or more, just because the search space is so big. But that's code that only needs to be tested once.

> And, code performance is, as you say, part of test performance. If the tests take too long, perhaps the code needs to be improved. Yes. I mentioned this is in the last section. When test-performance is alright, typically you don't need to optimize code anymore. For me, optimizations in the "code performance" category are for example trading off a generalist API for a more complicated tweaked version that reaches in…

> What are these suites testing?

One is testing all permutations of actions on some observability thingy: does everyone get the updates they requested in the correct order, basically, but suppose you have 3 "clients" that can connect and disconnect at arbitrary moments, and we're testing a single insert-like operation on the initial empty data, there are already dozens of combinations.

Another one is some operation on two arbitrary JSON objects and an inverse, and I wanted to make sure that it works for things that look like normal looking objects, small and large, and for "random" objects. Fuzzing with hierarchical data. This code is in JS because it has to run in the browser, so it is not super fast.

Post reply on HN