Live data from Hacker News

There’s No Such Thing as Clean Code

steveonstuff.com

71–80 of 395 posts

Re: There’s No Such Thing as Clean Code

#71
post #59

The Uncle Bob Martin definition of "clean code" from his book "Clean Code: A Handbook of Agile Software Craftsmanship" is a set of rules that absolutely are not at odds with one another. If you follow them you will end up with code that's really nice to read and easier to maintain, and, most importantly, that you can confidently change. There's a decent summary here - https://gist.github.com/wojteklu/73c6914cc446146b…

> is a set of rules that absolutely are not at odds with one another Yes, if you take them as general guidelines, not dogmatic rules with variable interpretations The latter is exactly what his fans do > 2 .Keep it simple stupid > 2. Prefer polymorphism to if/else or switch/case. No, not at odds with one another...

Yeah, polymorphism is in no way simple in lots of languages/frameworks. It's actually quite complex in many common languages/frameworks. This is absolutely contradictory in my opinion, but I welcome disagreement :)

Re: There’s No Such Thing as Clean Code

#72
post #59

The Uncle Bob Martin definition of "clean code" from his book "Clean Code: A Handbook of Agile Software Craftsmanship" is a set of rules that absolutely are not at odds with one another. If you follow them you will end up with code that's really nice to read and easier to maintain, and, most importantly, that you can confidently change. There's a decent summary here - https://gist.github.com/wojteklu/73c6914cc446146b…

> is a set of rules that absolutely are not at odds with one another Yes, if you take them as general guidelines, not dogmatic rules with variable interpretations The latter is exactly what his fans do > 2 .Keep it simple stupid > 2. Prefer polymorphism to if/else or switch/case. No, not at odds with one another...

They aren't. This is why pattern matching and typeclasses (to use the Haskell words, though I know other words are in use as well) have become increasingly popular features in languages.

Re: There’s No Such Thing as Clean Code

#73
post #59

The Uncle Bob Martin definition of "clean code" from his book "Clean Code: A Handbook of Agile Software Craftsmanship" is a set of rules that absolutely are not at odds with one another. If you follow them you will end up with code that's really nice to read and easier to maintain, and, most importantly, that you can confidently change. There's a decent summary here - https://gist.github.com/wojteklu/73c6914cc446146b…

> is a set of rules that absolutely are not at odds with one another Yes, if you take them as general guidelines, not dogmatic rules with variable interpretations The latter is exactly what his fans do > 2 .Keep it simple stupid > 2. Prefer polymorphism to if/else or switch/case. No, not at odds with one another...

Hmm...polymorphism is almost invariably simpler than if/else or switch/case, so not seeing the contradiction.

Re: There’s No Such Thing as Clean Code

#74
post #27
post #5

Coding is a highly subjective and creative endeavor. "Clean code" is akin to "well written" for writers. Sure, you can analyze and even be able to define some good practices, but because we are always creating something new that has never done before, and the field is infinitely complex, no rules can be set in stone and applied across everything. In my opinion there's nothing wrong with calling code clean, we don't h…

Writing is a great metaphor: there aren't any hard-and-fast rules and there's certainly a subjective quality to it... but also, some writing is clearly better and some writing is clearly worse. Maybe there is no such thing as "good" writing because writing can be "good" in different ways or because we can never fully define what "good" means, but that doesn't mean that all writing is equal or that "everything is a tr…

> some writing is clearly better and some writing is clearly worse This is a presumption, and one that I don't share

Like music and other forms of art, different styles appeal differently to different audiences. Many people find the language that 8 year olds write in to be terrible, and some people find it endearing and honest and meaningful. Software is no different in my opinion

Audience always matters

Re: There’s No Such Thing as Clean Code

#75
Sadly there seems to be nothing so attractive to a new(ish) programmer than a shiny silver bullet wrapped neatly into some popular or fashionable term, or better yet a three letter acronym.

Our industry features codebases that approach “big balls of mud” as complexity increases. Last week it was called “agile”, this week “clean code”. Perhaps “agile microserviced functionally hexagonal clean code” (AMFHCC™) next?

Re: There’s No Such Thing as Clean Code

#76
post #63
post #29

Clean code is code that does what you expect it to do without many surprises. It is simple, not clever. Effortless to follow. Each part handles one idea at a time, at the same abstraction level. Doesn't force you to mentally juggle many balls at the same time. The code often tells you a story, it communicates how the programmer (author) described the problem, the solutions and the trade-offs. Very similar to writing.…

What you can easily follow though is largely a function of your programming background. An experienced Haskell programmer will have no issue following all kinds of “.” and “$” usages, but one who is not experienced with Haskell, even if they learn what the syntax means, will have trouble following it.

I think how clearly you write and comment can matter just as much. I'm proud to say I've had situations where people with near zero programing experience were able to make some quick changes to get programs I'd written in perl working again following sudden changes. I think the more you know the easier it gets, but a reasonably capable end user with little to no experience in programing can surprise you if you take the time to try keeping things as easy to follow as possible. I do it because I can't trust myself to remember what I was doing even with projects completed only a few months ago.

Re: There’s No Such Thing as Clean Code

#77

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.

But there is agreed-upon tasty food, so there is some kind of intrinsic, shared meaning of the word, which is also true of code.

It's not objective, but there is a consensus among peers.

Honestly, it is like art, but these analogies kind of fall flat since we're not all "artists" in the traditional sense, usually. The reality is, for a painter, there are things that come close to objectively "good" works, a lot more so than for the layperson, and an experienced painter can walk you through all the different "types" of "good" art, just like an experienced coder can walk you through all the different "types" of "good" code.

Just because we can't write down in a few pithy words what "clean code" is doesn't mean it doesn't exist, it just further confirms something we've all known for a long time now; code is art.

Re: There’s No Such Thing as Clean Code

#78
Since others are reflecting on the merits of the article in ways I agree with, here's some articles I've collected from recent discussions on "clean code". Some even try to ditch the term or argue against it, others give context to the meaning. Would love to see others if anyone has any!

https://bitfieldconsulting.com/golang/crisp-code

https://overreacted.io/goodbye-clean-code/

https://www.cyclic.sh/posts/write-shitty-code

https://qntm.org/clean

Re: There’s No Such Thing as Clean Code

#79

Earlier quoted context omitted.

> is a set of rules that absolutely are not at odds with one another Yes, if you take them as general guidelines, not dogmatic rules with variable interpretations The latter is exactly what his fans do > 2 .Keep it simple stupid > 2. Prefer polymorphism to if/else or switch/case. No, not at odds with one another...

Hmm...polymorphism is almost invariably simpler than if/else or switch/case, so not seeing the contradiction.

Is that view not subjective though? Might someone think that if/else is simpler?
Post reply on HN