I heckin' love Clean Code!
I heckin' love Clean Code!
Falling into your wing while paragliding is called 'gift wrapping' and turns you into a dirt torpedo pic.twitter.com/oQFKsVISkI
— Mental Videos (@MentalVids) March 15, 2023
I heckin' love Clean Code!
Falling into your wing while paragliding is called 'gift wrapping' and turns you into a dirt torpedo pic.twitter.com/oQFKsVISkI
— Mental Videos (@MentalVids) March 15, 2023
i'd say you are a retard who never coded in his life but today my professor told us that for the course project our methods must be at most 10 lines and this angers me so much it's unreal
Just write like you would normally, then remove every newline.
Write your method normally then just take out the individual mechanisms of the code that does one thing into a separate method, done. It's not difficult.
write normally and then artificially divide the methods so that each newly created one is a direct continuation of the previous one
thats because youre a retard still in school
prof doesnt want to get a hundred assignments back with infinity line spagetti functions that all undergrads ultimately end up making at some point
BASED professor calling for total naggerlicious code death
Right. My experience with rules like this is that they evolve over time as a response to failure modes observed from real students. Sometimes the rules are more obnoxious than others (a 10 line limit is a little ridiculous) but it's usually not too hard to see the motive even when they're stupid.
That doesn't excuse wasting time on Object-Oriented Design and a decent professor will caveat that the rules are for the class specifically and not necessarily meant to be best practices they should internalize forever. But I get it.
All your functions are probably one liners
Thats called "Laconic humour" anon
if he didn't tell you how long one line should be just put everything into 10 huge lines. Tell him it conforms to specifications and if he has at least a lick of humor he'll give you top grade.
Bad move, university professors hate creativity.
works on my machine!
private static void printGuessStats(char canidate, int count) {
String GuessStat = String.format(
"There %s %s %s%s",
((count == 1) ? "is" : "are"),
((count == 0) ? "no" : count),
canidate,
((count == 1) ? "" : "'s")
);
print(GuessStat);
}
const printGuessStatistics = (candidate, count) => console.log(`There ${count === 1 ? "is" : "are"} ${count === 0 ? "no" : count} ${candidate}${count === 1 ? "" : "s"}`);
>canidate
>not cunnidate
>formatting an int value with %s
you dun goof'd
Yeah it will probably fucking crash in runtime.
everyone on this board talking about clean code doesnt write code
If you think the code on the right is better you are retarded.
I know the example on the right is an exaggeration but what legitimate complaints are there concerning clean code? Is there something fundamentally wrong with it or is it just poorly implemented?
>an exaggeration
It's taken verbatim from his book.
Surely you fuckin jest!
It's actually genuinely not an exaggeration.
Well, I mean, it's an example used to illustrate concepts. You'd expect the methods to be overpowered for the problem.
Clean code is meant to be used like tdd: this would be what the basis of a real world project would look like.
I have had the displeasure of working on large codebases written in this style: let me assure you, the problem gets WORSE as the codebase grows. The level of indirections in any operation is so high the code becomes 100% impossible to debug and let's not even mention refactoring that hellspawn spaghetti.
>I have had the displeasure of working on large codebases written in this style
I highly doubt that
>The level of indirections in any operation is so high the code becomes 100% impossible to debug
Nocoder detected. Bro, you set a breakpoint and turn on the debugger. It's not hard.
The irony of a dumb zoomer who even admits never having encountered clean code yet thinks it's debuggable, let alone with a debugger (bar none the worst tool for this, clean code effectively defeats debuggers by design) calling anyone a ~~*nocoder*~~ (a redditarded zoomzoom memeword only tourists use). What's this your ilk says nowaday? Oh yes. Grim.
>admits never having encountered clean code yet thinks it's debuggable
lmao. Don't talk to me ESL nagger.
>(bar none the worst tool for this, clean code effectively defeats debuggers by design)
HAHAHAHAHAHAHAHAHAHAHAHAHA. Nocoder confirmed. Most retarded sentence in this thread bar none.
>but I have seen that shit often enough in Java codebases.
I've worked on 2 Java codebases, the better one I worked on heavily used "clean code". I didn't find it that hard to work with. Could it have been easier, maybe. But it's not worth the anger that it instills in ni/g/s
I don't know, so far my experience from reading Java codebases or even writing some code is that following OOP + "clean code" makes it very hard to track what is actually happening.
Of course, if OOP is done well, things might make *sense* structure wise, but debugging issues or adding new features always was a pain since it's hard to follow the exact execution flow with too many functions just calling other functions for very minor things.
Meanwhile working with other languages (Python, Go, hell even Rust sometimes), I don't experience the same issues. Even when using OOP (except Go duh), it's way more straightforward to follow what happens than Java "clean coding" practices, and modifying things is way easier.
I won't lie, they can easily be overused. And I have seen examples in friends code bases that kinda demonstrate that. I think the issue isn't the ideas in "clean code", but developers that don't really know what they're doing. They just apply a design pattern, or some OO principle because "that's just what you're supposed to do". And the ability to separate out when to use something and when not to is, at least in my opinion, the first step towards becoming a good programmer.
Whatever homie.
you're just bad coder. you don't add new features by modifiying existing classes and adding new functions inside them. you add new features by adding new classes.
I accept your surrender.
You should be able to add features by adding data, without touching the codebase at all.
"Clean" code promotes awful design.
>clean code effectively defeats debuggers
>have fun debugging shit when you hit one of those "1 in a million" bugs
*throws in your path*
>I highly doubt that
Not the guy you are replying to, but I have seen that shit often enough in Java codebases. It's one of the reasons people hate Java so much: Too much spaghetti code + FaCToRIeS because of "clean code" and MuH REUsaBiLity.
It's cancer.
>Nocoder detected. Bro, you set a breakpoint and turn on the debugger. It's not hard.
Or just write your code in a readable fashion. Also, have fun debugging shit when you hit one of those "1 in a million" bugs.
It's taken straight from the clean code guru himself
https://sites.google.com/site/unclebobconsultingllc/one-thing-extract-till-you-drop
>https://sites.google.com/site/unclebobconsultingllc/one-thing-extract-till-you-drop
I can't believe it's not a joke. By that thinking, he should also extract a dollar sign to a DollarSignFactory method.
There's been a massive surge all over in hatred for clean code. What gives?
Cnile e-celeb made a video about it.
Casey?
Yes.
its one guy whos been obsessed with starting the same thread after casey muratori released a video over this
so casey himself?
It's just some random attention seeker.
>It's just some random attention seeker.
So casey himself?
Not likely. Casey is the kind of person who avoids engaging with randoms if there's no reason to.
What's your thought process?
>What's your thought process?
his thought process is getting you to reply
I doubt it. He's probably just paranoid.
It's one dude who got canned from his junior level dev position for writing shit code
OP, my code is the opposite of clean and the poor bastard who gets stuck with my position in the case of my death/mental breakdown is fucked.
This is not going to be a positive thing for him, but I'll be dead/institutionalized, so who cares
/x/misc/ schizo here.
>C is the 3rd letter of the alphabet
>CC == 33, signature if the masons
>Common Core == CC, when they decided to make the way they teach math retarded and useless
>Clean Code == CC, when they decided to make the way they teach people to wrote code retarded and useless
Come on, spongebob, it's elementary.
33 is Christ and LULZ is anti [C]lean [C]ode so ...
>replace method only calls replaceAllSymbols method
what did Uncle Bob mean by this
whens this dude gonna be banned for doing nothing but low quality flame wars
Is this really what people mean by "clean code"? Doesn't this just increase function overhead? Each function call is going to need it's own stack frame thus a return address to the previous frame?
Not really if they have any sense. But generally I don't think you should be worrying about call stack overhead. Within a module, modern compilers can easily inline private functions, and you can -lto for outside.
Really clean code is about modularity and readability. OP's pic is some brainlet who doensn't understand it. If it's Uncle Bob, I hold my claim.
>Is this really what people mean by "clean code"?
No, this is Clean Code™ by Uncle Bob.
Yes and yes. Glad you finally get it.
>Each function call is going to need it's own stack frame thus a return address to the previous frame?
What levels of autistic optimization are we on now bro?
The elementary level. It's even more basic than tco.
>What levels of autistic optimization are we on now bro?
Apparently we're not, judging by the quality of software over the past couple decades.
KISS, DRY, SRP in that order of priority. Simple until it bloats, DRY when you repeat yourself across function, SRP because bloat is often because you're doing MULTIPLE THINGS in one function.
>DRY when you repeat yourself across function
I would go a step further and say that "DRY" is a harmful idea. DRY should be "single point of truth". Multiple functions that are _almost_ the same are allowed to be different if they handle desperate things. The sirens' call of making a generic function that doesn't make sense and is cross-cutting is too much for the junior dev wielding the "DRY" mantra.
If you're copy-pasting code across functions verbatim you're a retard and if you think it's a good idea you've never had to refactor a bug that came from copy-pasting verbatim code that could've been simplified into its own function or better yet, needing to add a feature to that copy-pasted code and have to do it 5 times across your codebase. There's a reason why you're a slower developer than me.
I at no point advocated for that, smallbrain.
>needing to add a feature to that copy-pasted code and have to do it 5 times across your codebase.
This is exactly the circumstance when you should combine them. But you should not shoe-horn some ridiculous abstraction together to save 2 lines of duplication when they are close, but logically different. One problem with this, is now an alteration to one feature may fuck with a disperate feature. The problem is DRY but backwards.
The problem with retards like you is you only see the world in strawmen. USE YOUR FUCKING BRAIN WHEN USING ANY DESIGN PRINCIPLE. Here's a protip, if the design principle is not reducing the total lines of code, you're probably using it autistically.
>The problem with retards like you is you only see the world in strawmen.
Now This Is What I Call Projecting, Volume 69
No one said use DRY on 2 lines of code.
No one said someone said DRY on 2 lines of code. I was trying to illustrate what I meant by single point of truth. You still fail to grasp you're arguing for the same thing, and that is *exactly* why calling it DRY is retarded.
>But you should not shoe-horn some ridiculous abstraction together to save 2 lines of duplication when they are close, but logically different. One problem with this, is now an alteration to one feature may fuck with a disperate feature.
Yes, this is true. Still, DRY is useful and you should have tests detecting whether some change in a common method actually has an unintended side effect at another call site. You can then also split the common function up once you actually need the split
String replace() {
replaceAllSymbols();
return stringToReplace;
}
what the fuck is this
You use the left side code in your hobby projects and the right side puts food on your table, whine all you want but that's how it is.
10x slower, check.
10x more engery use, check.
10x more co2 production, check.
truly clean code.
(and like 20 other times today too)
The threads will continue until morale improves
"Clean" code is anything but clean.
Benefits of left
>Looks simpler
Benefits of right
>Matcher and Pattern could be replaced at compile time, if you overload the constructor
>Implementation details are hidden behind private methods
>Since the only thing publicly exposed is replace and translate, it would be easy to extend to an interface if more general behavior is needed.
>(subjective) easier to reason about.
I honestly believe that if you find the left simpler then you've either never worked in your life, or are in the bottom 10% of programmers.
>I honestly believe that if you find the left simpler then you've either never worked in your life, or are in the bottom 10% of programmers.
Or you are just not a shit tier Java dev.
You could do some of the refactorings such as:
>Matcher and Pattern could be replaced at compile time, if you overload the constructor
Without the craziness of having 15 functions for a fucking replace. In the end the only public functions are still replace and translate. Doesn't matter that you now have 15 private subfunctions with the implementation when the implementation is so trivial is 10 lines anyway.
See
Its an example taken from a book, the idea is to show concepts with a small bit of code.
Yes, that's the biggest problem with examples such as these. Any example you show will be too trivial for it to actually make sense. It's when your code base gets fuck huge that this stuff matters, but nobody is going to read a book with a 400,000+ line example.
Yeah the issue is: this shit does not belong in those books then. It's not an important thing to teach. If you're not the lead software architect on a project designing software expected to grow to several million lines in a few years, you don't need to waste your time with this shit. There are more important concepts to be learning at this stage in your career. And if you are a top-tier software architect, either because you have real experience or because you are some kind of 1 in a million savant, you don't need a book with gay newfag examples either.
This is the kind of topic that should appear in software white papers and materials aimed at seasoned professionals. Such materials should be able make reference to massive projects in an informed way, even if there isn't a million lines of example code, because the target audience is presumed to have experience with such codebases.
both examples reference some getSymbol which is not defined anywhere. sasuga anon
Why is this a class at all?
Oop brainrot is a hell of a drug
>left
You read from top to bottom and know what the code is doing in 20 seconds
>right
You read from line 5 to line 10 back to line 6 then line 30 then line 20 and so on. This example is trivial but imagine applying this retarded methodology of abstracting every 2 lines of actual logic behind some retarded method name in a large codebase, it's absolute hell.
This is the kind of code that NOBODY will ever read, if I saw this in a codebase I would absolutely despise the person who wrote it.
I am so sick of muh performant autists treating software development like building a race car being validated on LULZ recently its made me forget how retarded some parts of bob martins advice actually are
If I want to read what some code is doing, the left reads more "like english" (something these people stress very highly) than the right, the right has me jumping all over the place on the page to find what everything does, all for the modularity of what? None of that shit is any more modular than on the right, at an extreme readability cost.
shit.
use python
Too much duplication but right is superior if you've ever worked in a company with more than 5 devs or 2 managers. Review the SDLC sir
Just to be clear the clean code is faster in this case because of the regex compilation being done once.
Might wanna make it static too.
Yeah, it's fucking ridiculous that they didn't move the regex compilation during class construction in the left example. Right now it's going to be recompiled every time replace() is called.
Yep
https://qntm.org/clean
This cannot be real
>says he wants "clean code"
>yet he uses only two spaces for indents
provide your alternative implementation
> provide your alternative implementation
That abomination is the result of him refactoring some code from Knuth. Refer to the original code if you want to learn how to implement prime sieve
>purely procedural style from 60s
you actually think its better why
>you actually think its better why
Because I can actually understand what's going on? Anyone that knows how a prime sieve work can trivially map the algorithm to the obvious imperative code, which all fits on one fucking screen and it's much easier to read? Try to do that with Bob's clusterfuck. Jesus fuck can you even tell what the isLeastRelevantMultipleOfNextLargerPrimeFactor function does after reading its name? kek
public static bool IsPrime(int number)
{
if (number <= 1) return false;
if (number == 2) return true;
if (number % 2 == 0) return false;
var boundary = (int)Math.Floor(Math.Sqrt(number));
for (int i = 3; i <= boundary; i += 2)
if (number % i == 0)
return false;
return true;
}
It is. Not sure which point Bob is trying to make with this. Assuming he's not the shittiest programmer to have ever lived (the jury is still out on this one), this has to be the worst example ever put into a textbook of any kind.
I'd assume he's just trolling and trying to make money, kinda like Hubbard with Scientology.
When I was new to programming, I actually took his stuff kinda seriously. It's painful to even think about now.
I used to agree that this was a waste of time.
Until I found pragmatic reasons for modularising everything in functions rather than subfunctions.
Makes it super easy to use for different circumstances.
Just making this an entire class instead of one function is already naggerlicious. But I guess Javafags or whatever don't have a choice.
I don't event understand what this code is doing. Both examples are dirty as indian hands that wrote it
Functions should be small, but not at the cost of introducing additional shared mutable state. This is the fundamental point that Uncle Bob misses in his book.
Nothing wrong with many small functions as long as they have a pure interface (within the limitations of your specific programming language).
ITT: 80iq retards thinking anything in a book or lecture is gospel and you can either worship it or be an absolute heretic about it
you read stuff like Clean Code to learn the process (even if the example cases are shit), then apply to your own codebase (which is assumedly more complex than the examples, given the book is targeted for enterprise programming) and draw your own conclusions if it works in a given case or not
>it was just a prank bro
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
Great example OP
>t. retard webshit "developer" seethe thread number 245
To be fair, you need to have a very high IQ to understand clean code. The principles are extremely nuanced, and without a solid grasp of programming concepts, most of the benefits will go over the head of a typical developer. There are also the best practices for writing clean, maintainable code, which require a deft understanding of programming concepts and patterns.
The skilled developers understand this stuff; they have the intellectual capacity to truly appreciate the benefits of writing clean code, to realize that it's not just a matter of style- it has a deep impact on the quality and longevity of the software. As a consequence, those who dismiss clean code practices are truly missing out- of course, they wouldn't appreciate, for instance, the benefits of a clean codebase for collaboration and maintainability.
I'm nodding right now just imagining one of those disorganized developers struggling to maintain a messy codebase as their deadline approaches. What fools...how I pity them.
And yes, by the way, I DO practice clean code. And no, you cannot see it. It's for the team's eyes only- and even then, they have to demonstrate that they understand the principles of clean code beforehand. Nothing personal, just good programming practices.
Oooh, didn't know this pasta. Thanks for sharing.
>The principles are extremely nuanced, and without a solid grasp of SOLID concepts, most of the benefits will go over the head of a typical developer.
ftfy
>protected
Imagine still using inheritance. Learn to use interfaces you homosexual.
> SymbolReplacer
just kill yourself already
I think clean code just means easily readable code to humans.
This is the prettiest example of clean code I have ever seen
https://github.com/bvschaik/julius/blob/master/src/game/tick.c
>https://github.com/bvschaik/julius/blob/master/src/game/tick.c
I still don't understands why LULZ hates readable code?
That's not Clean Code at all.
Then tell me.
What's wrong with clean code?
>all state is global
yikes
right side is objectively superior and youre all low iq animals
>OO
into the trash it belongs
>"Clean" code
> Doesn't open curly braces on a new line
If you're going to autismo organize, at least do the first set to making it not look retarded