Live data from Hacker News

There’s No Such Thing as Clean Code

steveonstuff.com

251–260 of 395 posts

Re: There’s No Such Thing as Clean Code

#251
post #153

So True ! After 25+ years of coding, I know one thing. I STILL don't know how to "code correctly". And apart from a few gifted individuals (Rob Pike, Fabrice Bellard Bobby Bingham [ffMpeg team] etc) I'm HIGHLY suspicious of ppl and programmers who claim "they can program correctly" and that "this xyz is the correct way/stack/method/arch". Background:CS grad, start coding at around 13 (thank you dad !) I am well verse…

The more code I've written, the less I care about code quality. I think the things I could point to in my coding practice which would make the code I write now better than the code I wrote 10 years ago would be: - I minimize interdependencies (changing a line of code should not affect something un-related) - I go for abstractions later, only when I need them, rather than trying to think of the perfect abstraction/des…

> The more code I've written, the less I care about code quality. .. - I minimize interdependencies (changing a line of code should not affect something un-related) - I go for abstractions later, only when I need them, rather than trying to think of the perfect abstraction/design pattern which will solve the problem in the most elegant or clever way

It's funny, but those points you are describing are measures of code quality to me. The less interdependencies the higher I value the code, same for abstractions, most of the time it is the simpler the better. Except in those cases where they are explicitly required.

Re: There’s No Such Thing as Clean Code

#252
post #246

Earlier quoted context omitted.

This is my experience as well. It takes a long time to grok what the program does and how it does it because of all the layers of indirection, even when the program is fairly simple. While this style might make small changes easy if you understand the code, the inertia to larger changes because of the layers of indirection is immense .

Wow that's on-point, agree that in many past projects "inertia to larger changes" is exactly how I would describe so-called Clean Code. It's that small changes like adding getters and setters give an easy-to-follow PR, a false sense of accomplishment for both the author and the reviewer, and ton of dopamine with that. While important changes, that actually deliver business value or repay technical debt, become increa…

Yeah, you can't eliminate essential complexity by narrowing your view, it will just obscure the big picture.

Re: There’s No Such Thing as Clean Code

#253
post #203

Earlier quoted context omitted.

When can you rebuild at zero cost? I have made similar avoidable mistakes of not thinking it through enough, could have saved me a lot of rewriting, which was pretty expensive

Rewriting is incredibly cheap! And you learn a lot from the failed attempts. Again to the house analogy, if you could just build 3 vestibules to see how they fit with just a little typing, that would be far and away preferable to committing to everything on paper before hand.

That really depends on what you're working on and to what degree it's coupled to the system it's a part of. A form on a web application, or an API endpoint? Sure, rewriting it is probably trivial. A new process scheduler for Linux? The caching system in an HTTP server? Maybe writing the code will be easy (though probably not), but building any confidence that it doesn't break something that's unexpectedly load bearing will be anything but cheap. And if what you're rewriting that started out as "just code and see what happens" it's going to be more expensive still.

Which isn't to say that rewriting can't be cheap, but some intentional design (or at least diligent maintenance and refactoring) must have gone into the system to support that style of development. At which point you're back to targeting "quality," even if it's no longer a focus of on the smaller scale.

Re: There’s No Such Thing as Clean Code

#254
post #153

So True ! After 25+ years of coding, I know one thing. I STILL don't know how to "code correctly". And apart from a few gifted individuals (Rob Pike, Fabrice Bellard Bobby Bingham [ffMpeg team] etc) I'm HIGHLY suspicious of ppl and programmers who claim "they can program correctly" and that "this xyz is the correct way/stack/method/arch". Background:CS grad, start coding at around 13 (thank you dad !) I am well verse…

The more code I've written, the less I care about code quality. I think the things I could point to in my coding practice which would make the code I write now better than the code I wrote 10 years ago would be: - I minimize interdependencies (changing a line of code should not affect something un-related) - I go for abstractions later, only when I need them, rather than trying to think of the perfect abstraction/des…

very important lesson, more than that actually

there's a lot of artistry, poetry, idealism in programming, but as a daily money making activity it just doesn't cut it. You have to reach goals as easily as possible (dry,yagni) fast without painting yourself in corners as much as you can (low coupling, min interdependencies). Finding the right variability points.

it's something school don't do well (saying this humbly) yet crucial

ps: I disagree with the article title. k&r, mccarthy's lisp, prolog, and many other have very clean general and beautiful code.

Re: There’s No Such Thing as Clean Code

#255

Earlier quoted context omitted.

When start off with "wrong" higher level design concepts, neither of those is trivial. If you're writing a function implementation without thinking about design, well you might be right.

I sometimes wonder if there is a miscommunication. I’m scratching my head sometimes like “how can rewriting/refactoring an entire 10-20k project take negligible time?” Maybe some people have very small projects compared to what I work on? Or maybe they are talking about the design of a single small component? I inherited a codebase that needed some refactoring because it was written “to just get it shipped”. If compl…

[deleted]

Re: There’s No Such Thing as Clean Code

#256

Earlier quoted context omitted.

I agree. What I'm saying is that private is a poor default.

Why? I think it's pretty reasonable to only expand APIs deliberately.

Because most things in healthy programs aren't APIs, but just plain data: records, sum types and composites thereof (arrays, stacks, queues, whatever).

Fred Brooks:

> Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious.

In that situation, having to sprinkle "public"/"pub" all over them is very noisy and unproductive. It's the worst with Rust's enums, which require you to declare the visibility of variants and enclosed types of variants separately, so you see a couple "pub"-s per line of an enum definition.

That may be an argument for separate keywords for plain data, and for "APIs", although I'm not sure how I feel about it. Underneath it's just coupling of data with functions. Some languages have separate keywords for those, some don't.

Re: There’s No Such Thing as Clean Code

#257

The fact that everyone can come up with his own definition of what "clean" is supposed to mean regarding code, tells us something very important about it: It has no intrinsic, defined meaning in the context of code. Saying code is "clean" is like saying food is "tasty"...its a personal opinion, not a defined term.

And yet we all agree, spoiled food tastes terrible.

Yes we do, but "this tastes terrible" still doesn't tell me what that means without additional context. It could be terrible because its spoiled. It could be terrible because the person doesn't like that food.

Same with "clean code". I think alot of people would agree that a 10000 line program where all the code lives in the main function is not "clean". But that doesn't mean this is what someone means when he says "this isn't clean code".

Re: There’s No Such Thing as Clean Code

#258
Wow, this post has triggered some emotion from me. I find it incredibly traumatic working with “engineers” that have this point of view. The pain individuals like this inflict on others is real! What they are really saying is that they don’t care about their fellow developers, their productivity nor happiness.

This view will lead to “good enough” code that always appears to “work” but fails easily and creates more work for everyone else.

God forbid you actually care about a project and get stuck working with someone like this on it. You’re going to have some sleepless nights.

Re: There’s No Such Thing as Clean Code

#259

Wow, this post has triggered some emotion from me. I find it incredibly traumatic working with “engineers” that have this point of view. The pain individuals like this inflict on others is real! What they are really saying is that they don’t care about their fellow developers, their productivity nor happiness. This view will lead to “good enough” code that always appears to “work” but fails easily and creates more wo…

yes, these contentless articles are just well receieved because they validate the laziness of some while invoking emotion from others.

@author - "clean code" means improvement relative to some starting point. there, problem solved.

Re: There’s No Such Thing as Clean Code

#260

Wow, this post has triggered some emotion from me. I find it incredibly traumatic working with “engineers” that have this point of view. The pain individuals like this inflict on others is real! What they are really saying is that they don’t care about their fellow developers, their productivity nor happiness. This view will lead to “good enough” code that always appears to “work” but fails easily and creates more wo…

I don't see how you can read the article and come away with this opinion. The author's not saying that you shouldn't make quality code, he's saying that no one agrees on the definition of clean so you should use more descriptive language.
Post reply on HN