There’s No Such Thing as Clean Code
steveonstuff.com
There’s No Such Thing as Clean Code
1–10 of 395 posts
Re: There’s No Such Thing as Clean Code
#2Exactly
The same code snippet might be good in one context and an annoyance in another context
Here's where "generic rules" fail. Like python's avoidance of lambdas and favouring just having functions. Well, but, depending on the context, they make a lot of sense.
"Oh but lambdas are less readable" not if you need 20 different short functions and you need to combine them. Too implicit and it's hard to read, too explicit it gets boring and also hard to read.
Re: There’s No Such Thing as Clean Code
#3> But these traits are in some ways at odds with each other. The most simple code is probably not the most testable. All those interfaces and injected dependencies make for convenient testing, but have a cost in terms of simplicity. Exactly The same code snippet might be good in one context and an annoyance in another context Here's where "generic rules" fail. Like python's avoidance of lambdas and favouring just hav…
Re: There’s No Such Thing as Clean Code
#4> But these traits are in some ways at odds with each other. The most simple code is probably not the most testable. All those interfaces and injected dependencies make for convenient testing, but have a cost in terms of simplicity. Exactly The same code snippet might be good in one context and an annoyance in another context Here's where "generic rules" fail. Like python's avoidance of lambdas and favouring just hav…
20 short functions definitely sound as though they should be explicit. Named, documented, testable. 1 or 2 you could get away with being implicit. 20 requires a lot of understanding as to what's going on!
Re: There’s No Such Thing as Clean Code
#5In my opinion there's nothing wrong with calling code clean, we don't have to analyze every line of code we write. There's just too many things to consider and viewpoints to take, we'd be trapped in analysis paralysis forever, as you can continue it to no end. There's never a point where the analysis will be "done". You just have to be able to recognize when the analysis reaches a point of diminishing returns, and when moving on is the better option. Sometimes just calling it "clean" is enough.
Re: There’s No Such Thing as Clean Code
#6Re: There’s No Such Thing as Clean Code
#7> But these traits are in some ways at odds with each other. The most simple code is probably not the most testable. All those interfaces and injected dependencies make for convenient testing, but have a cost in terms of simplicity. Exactly The same code snippet might be good in one context and an annoyance in another context Here's where "generic rules" fail. Like python's avoidance of lambdas and favouring just hav…
20 short functions definitely sound as though they should be explicit. Named, documented, testable. 1 or 2 you could get away with being implicit. 20 requires a lot of understanding as to what's going on!
My solution: array of lambdas
Your solution: array of references to functions named f1 .. f20.
Which is cleaner?
Re: There’s No Such Thing as Clean Code
#8Earlier quoted context omitted.
20 short functions definitely sound as though they should be explicit. Named, documented, testable. 1 or 2 you could get away with being implicit. 20 requires a lot of understanding as to what's going on!
Wait until you work on a 100k line code base where someone enforced this kind of thing
Re: There’s No Such Thing as Clean Code
#9Coding 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…
Re: There’s No Such Thing as Clean Code
#10Maintaining low viscosity (resistance to local change) is a super useful concept for me when thinking about clean code and good architecture.
I think it's a pretty good signifier of elegance, decoupling, lack of spaghetti etc.
1: http://iihm.imag.fr/blanch/ens/2010-2011/M1/EIHM/cours/1998-...