| ▲ | Solid and Clean Code never felt solid or clean to me(devz.cl) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 points by DanielVZ 6 hours ago | 54 comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | jdlshore 4 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
I clicked the link hoping for a critique of the ideas in SOLID and Clean Code, but what I got was an ironically long-winded critique of Bob Martin’s speaking style. Martin and I have our differences, but this article isn’t really useful. Martin has a brand and a style. A lot of people find it engaging and entertaining. If you don’t, that’s fine, there’s plenty of other ways to learn about the ideas that are more concise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | ah1508 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
What I dislike about the term "clean" code is that it dismiss objective criteria. "I did it like that because it's cleaner" is a non sense. A program must be maintenable, efficient, observable, testable, scalable, performant, readable, secured. Each criteria can be objectively measured in a kind of radar diagram and can be maximized as long as it does not sacrifice another criteria. Form follows function. Even "simple" (from KISS) is too vague, fortunately in the conference "simple made easy" Rich Hickey defines what is simple: not interleaved. simple comes from sin plex, the opposite of con plex. Not always easy to make something simple. However I don't see anything wrong with SOLID. Separation of concerns is how a modern society or a football team works, and S brings D because specialization involves good relationships ("no man is an island" wrote John Donne ), and D is strongly related to L. I has no drawbacks. However I don't separate data from business logic anymore (no data access layer). Business logic applies on data, not on objects that hide data. Translating a ER diagram into anemic classes while the DBA do the same in the DB does not have any value and forces to use obstruction pattern like repository. If entity classes have properties and methods (a Plane class that has a 'takeOff' and 'land' methods for instance) it is different but must most backend I see don't implement entity classes that way. Because their classes represent data, not animated concept. Player class with a shoot method might makes sense for a video game, User class with a addComment method for a CRUD app makes less sense to me. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | egeozcan 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Choose a convention and stick with it. Your chosen conventions could be the worst fit for your domain, but the code following "a" convention ensures that people jumping in later can actually follow along and it makes refactoring at least bearable. I personally don't like when people stick to SOLID like it's the holy hammer, but nearly every serious programming language has a convention on how to write SOLID code, and it will be followed, which makes my job easier if I'm new to the codebase. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | Cpoll 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uncle Bob does a bad job talking about trade-offs, but there's still value in stuff like SOLID. The problems start when people blindly obey or ignore design principles. Saying SOLID makes bad code is as over-simplistic as saying SOLID makes good code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | jdmoreira 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uncle Bob is a snake oil salesman. Not sure he realizes it himself though. The whole SOLID, OOP design patterns era was one of the worst things to have happened to programming. I always thought I was the one that sucked but now I'm absolutely certain that whole zeitgeist was total crap. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | marcosdumay 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
I guess by now it's pretty settled down and unanimous that SOLID is an extremely bad way to organize your code, and that Clean isn't very good and has about the same odds of helping or harming you. But extending the complaint to all acronyms isn't helpful. ACID, OLAP, EBITDA, etc are perfectly good names with clear meanings that can be easily discovered. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | WillAdams 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
For some actual code and comparison of principles behind Clean Code see: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | rpcope1 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
While I agree the "Uncle Bob" cargo cult is IMO dumb, this really rubs me the wrong way: > You have the vendor pushed acronyms like: ACID, CAP, OLAP, OLTP. ACID and the CAP theorem in particular has _very_ serious consequences if you're doing anything that isn't a toy with a database, and if there was one thing worth beating into developers, it would be the consequences of those. With the big push on columnar stores and various flexible database options (and replication and etc.) understanding that OLAP and OLTP workloads have very different needs and performance profiles is also something that many (most?) developers seem to miss, and again seems like something that needs to be beaten into a huge cohort of developers. Just because there are some silly/stupid cargo cult acronym around process, does not mean that anything that's an acronym or is confusing to your _garden variety history major_ can just be dismissed. This is part of why we get a lot of the monstrosities that exist out in the world today; there's this really perverse behavior I've seen among people coming from somewhere other than the hard sciences to wave away formalism and anything that smells remotely like math as "oh they're just being dogmatic". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | fabian2k 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
These rules are all stuff that you probably should think about at some time. But they're often taught as strict rules, which I don't think is a good idea. In the end many of them are still quite subjective. It is useful to try to avoid mixing unrelated stuff into the same class. But trying to religiously find the boundary to what a single responsibility means in each specific case is a waste of time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | HumblyTossed 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Pick better data structures such that you can use simple language elements to manipulate said data. If you're writing a dozen lines of code to abstract 2 lines of logic, you're not doing anyone any favors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | rdiddly 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
The only thing worse than a long-winded explanation that finally gets around to the topic you're interested in (in his case an explanation of SOLID) is a long-winded explanation that never gets around to it (in my case a refutation of SOLID). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | jolt42 2 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
I've yet to find a panacea. For example, I thought DRY was, but found its not the case (test scenarios). I've yet to find altruisms past "everything in moderation". If you do choose a style and stick to it though at least it's consistent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | wduquette 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Re: Java classes called "SimpleFoo": that's usually because `Foo` is an abstract class or interface, and `SimpleFoo` is the version you actually use most of the time, unless you absolutely have to implement a `MyReallyComplexFoo` for some specific purpose. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | paulddraper 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
The #1 problem of most clean code, or microservices, or other architectural patterns is taking a correct observation to a logical extreme. Decomposition is good. Too much decomposition recreates complexity in the interactions. Immutability is good. Immutability everywhere creates gymnastics with more mental load. Extensibility is good. Extensible-everything is reduces usability. Program isolation is good. Too much isolation melts your laptop into a Docker-shaped puddle. Having the restraint to not apply your pet idea to everything under the sun is the mark of a mature programmer and indeed a mature person. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | dvh 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
I'm on 4G mobile, that stock photo of sheep is 19MB PNG file! Thanks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | msalsas 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
I read Clean Code when I was a beginner and found it revealing, but also annoying in parts, like the idea to 'do not use functions with more than 2 parameters.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | zelphirkalt 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
To see really elegant and great code, I recommend looking in books. I have seen elegant code in: SICP, The Little Schemer, Software Design for Flexibility. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | t-dog 2 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Did Uncle Bob rape everyone's grandma, because the amount of anger here for him and his work is insane. I'm guessing he wrote his books with the intention of helping others, and saw an opportunity to make a little coin at the same time. But you'd think he was software's Hitler the way people talk about him these days. I was given Clean Code as a junior developer... didn't think it was mind blowing, but I used the parts that made sense and left the parts that didn't... what you're supposed to do anytime you're exposed to other peoples opinions. And I never felt a need to follow it blindly. If your code got inappropriately criticized by your leads or managers for not being Clean or SOLID enough, or they forced you into following Clean Code like it was the bible, then be mad at those guys! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | breckenedge 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Programming is human. Obviously there will be cultures (and cults) that spring up and die down all the time. I probably pissed off a few colleagues over the years by rejecting their arguments because they were “appeals to authority” that I did not recognize as authorities in the particular problems we were solving at the time. Hate cargo cult programming, but admit I fell into that trap often enough in my early years. Gotta start somewhere. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | bbg2401 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
This is a tedious, meandering, almost self-contradictory article. > To me people calling their code or software “Clean”, “Easy”, or “Simple” has always felt wrong. You aren’t entitled to declare your own creation to have some subjective trait you strived for when writing it. Follows: > The more objective you assume you are, the more easily manipulated you can be by subjectivity, be it your own subjectivity or others. I'm happy to go on record stating the former is more forgivable than a lazy false truism or platitude. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | ilitirit 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
I agree with the point about dogmatism, but I have so many other issues with this piece. I mean... how do you even make the comparison between "A Handbook of Agile Software Craftsmanship" and "History of Hispanic Colonialism”!? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | sriramgopalan 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
I am sorry but nothing in the article clearly lays out how solid/clean code doesn't feel solid or clean. It seems to be a criticism of a specific person. What am I missing? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | high_na_euv 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | sublinear 4 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
> Software engineering culture is overly dogmatic and subjective. It doesn't have to be. You can have standards without clinging onto them for dear life like you're about to be swept away in a flood. > This is not a specific critique of the contents or ideas in SOLID or Clean Code. It’s about how it presents itself and how that made me feel. Yeah, this blog post added to the dogma. Someone will read this and just look for something else to cling on to. For critique to work, you can't be injecting even more of your superficial opinion, and the readers have to care instead of impatiently looking for "the answer". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||