I heckin' love Clean Code!

I heckin' love Clean Code!

  1. 3 weeks ago
    Anonymous

    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

    • 3 weeks ago
      Anonymous

      Just write like you would normally, then remove every newline.

    • 3 weeks ago
      Anonymous

      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.

    • 3 weeks ago
      Anonymous

      write normally and then artificially divide the methods so that each newly created one is a direct continuation of the previous one

    • 3 weeks ago
      Anonymous

      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

    • 3 weeks ago
      Anonymous

      BASED professor calling for total naggerlicious code death

    • 3 weeks ago
      Anonymous

      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

      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.

    • 3 weeks ago
      Anonymous

      All your functions are probably one liners

      • 3 weeks ago
        MercurySession

        Thats called "Laconic humour" anon

    • 3 weeks ago
      Anonymous

      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.

      • 3 weeks ago
        Anonymous

        Bad move, university professors hate creativity.

  2. 3 weeks ago
    Anonymous

    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);
    }

    • 3 weeks ago
      Anonymous

      const printGuessStatistics = (candidate, count) => console.log(`There ${count === 1 ? "is" : "are"} ${count === 0 ? "no" : count} ${candidate}${count === 1 ? "" : "s"}`);

    • 3 weeks ago
      Anonymous

      >canidate

      • 3 weeks ago
        Anonymous

        >not cunnidate

    • 3 weeks ago
      Anonymous

      >formatting an int value with %s
      you dun goof'd

      • 3 weeks ago
        Anonymous

        Yeah it will probably fucking crash in runtime.

  3. 3 weeks ago
    Anonymous

    everyone on this board talking about clean code doesnt write code

    • 3 weeks ago
      Anonymous

      There's been a massive surge all over in hatred for clean code. What gives?

      If you think the code on the right is better you are retarded.

    • 3 weeks ago
      Anonymous

      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?

      • 3 weeks ago
        Anonymous

        >an exaggeration
        It's taken verbatim from his book.

        • 3 weeks ago
          Anonymous

          Surely you fuckin jest!

      • 3 weeks ago
        Anonymous

        It's actually genuinely not an exaggeration.

        • 3 weeks ago
          Anonymous

          Well, I mean, it's an example used to illustrate concepts. You'd expect the methods to be overpowered for the problem.

          • 3 weeks ago
            Anonymous

            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.

            • 3 weeks ago
              Anonymous

              >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.

              • 3 weeks ago
                Anonymous

                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.

              • 3 weeks ago
                Anonymous

                >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.

                >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.

                >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

              • 3 weeks ago
                Anonymous

                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.

              • 3 weeks ago
                Anonymous

                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.

                I accept your surrender.

                Whatever homie.

              • 3 weeks ago
                Anonymous

                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.

              • 3 weeks ago
                Anonymous

                I accept your surrender.

              • 3 weeks ago
                Anonymous

                You should be able to add features by adding data, without touching the codebase at all.

                "Clean" code promotes awful design.

              • 3 weeks ago
                Anonymous

                >clean code effectively defeats debuggers

                >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.

                >have fun debugging shit when you hit one of those "1 in a million" bugs
                *throws in your path*

              • 3 weeks ago
                Anonymous

                >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.

      • 3 weeks ago
        Anonymous

        It's taken straight from the clean code guru himself
        https://sites.google.com/site/unclebobconsultingllc/one-thing-extract-till-you-drop

        • 3 weeks ago
          Anonymous

          >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.

  4. 3 weeks ago
    Anonymous

    There's been a massive surge all over in hatred for clean code. What gives?

    • 3 weeks ago
      Anonymous

      Cnile e-celeb made a video about it.

      • 3 weeks ago
        Anonymous

        Casey?

        • 3 weeks ago
          Anonymous

          Yes.

    • 3 weeks ago
      Anonymous

      its one guy whos been obsessed with starting the same thread after casey muratori released a video over this

      • 3 weeks ago
        Anonymous

        so casey himself?

        • 3 weeks ago
          Anonymous

          It's just some random attention seeker.

          • 3 weeks ago
            Anonymous

            >It's just some random attention seeker.
            So casey himself?

            • 3 weeks ago
              Anonymous

              Not likely. Casey is the kind of person who avoids engaging with randoms if there's no reason to.
              What's your thought process?

              • 3 weeks ago
                Anonymous

                >What's your thought process?
                his thought process is getting you to reply

              • 3 weeks ago
                Anonymous

                I doubt it. He's probably just paranoid.

    • 3 weeks ago
      Anonymous

      It's one dude who got canned from his junior level dev position for writing shit code

  5. 3 weeks ago
    Anonymous

    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

  6. 3 weeks ago
    Anonymous

    /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.

    • 3 weeks ago
      Anonymous

      33 is Christ and LULZ is anti [C]lean [C]ode so ...

  7. 3 weeks ago
    Anonymous

    >replace method only calls replaceAllSymbols method
    what did Uncle Bob mean by this

  8. 3 weeks ago
    Anonymous

    whens this dude gonna be banned for doing nothing but low quality flame wars

  9. 3 weeks ago
    Anonymous

    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?

    • 3 weeks ago
      Anonymous

      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.

    • 3 weeks ago
      Anonymous

      >Is this really what people mean by "clean code"?
      No, this is Clean Code™ by Uncle Bob.

    • 3 weeks ago
      Anonymous

      Yes and yes. Glad you finally get it.

    • 3 weeks ago
      Anonymous

      >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?

      • 3 weeks ago
        Anonymous

        The elementary level. It's even more basic than tco.

      • 3 weeks ago
        Anonymous

        >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.

  10. 3 weeks ago
    Anonymous

    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.

    • 3 weeks ago
      Anonymous

      >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.

      • 3 weeks ago
        Anonymous

        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.

        • 3 weeks ago
          Anonymous

          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.

          • 3 weeks ago
            Anonymous

            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.

            • 3 weeks ago
              Anonymous

              >The problem with retards like you is you only see the world in strawmen.
              Now This Is What I Call Projecting, Volume 69

              • 3 weeks ago
                Anonymous

                No one said use DRY on 2 lines of code.

              • 3 weeks ago
                Anonymous

                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.

          • 3 weeks ago
            Anonymous

            >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

  11. 3 weeks ago
    Anonymous

    String replace() {
    replaceAllSymbols();
    return stringToReplace;
    }

    what the fuck is this

  12. 3 weeks ago
    Anonymous

    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.

  13. 3 weeks ago
    Anonymous

    10x slower, check.
    10x more engery use, check.
    10x more co2 production, check.
    truly clean code.

  14. 3 weeks ago
    Anonymous

    (and like 20 other times today too)

    • 3 weeks ago
      Anonymous

      The threads will continue until morale improves

  15. 3 weeks ago
    Anonymous

    "Clean" code is anything but clean.

  16. 3 weeks ago
    Anonymous

    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.

    • 3 weeks ago
      Anonymous

      >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.

      • 3 weeks ago
        Anonymous

        See

        Well, I mean, it's an example used to illustrate concepts. You'd expect the methods to be overpowered for the problem.

        Its an example taken from a book, the idea is to show concepts with a small bit of code.

        • 3 weeks ago
          Anonymous

          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.

          • 3 weeks ago
            Anonymous

            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.

  17. 3 weeks ago
    Anonymous

    both examples reference some getSymbol which is not defined anywhere. sasuga anon

  18. 3 weeks ago
    Anonymous

    Why is this a class at all?

    • 3 weeks ago
      Anonymous

      Oop brainrot is a hell of a drug

  19. 3 weeks ago
    Anonymous

    >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.

  20. 3 weeks ago
    Anonymous

    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.

  21. 3 weeks ago
    Anonymous

    shit.
    use python

  22. 3 weeks ago
    Anonymous

    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

  23. 3 weeks ago
    Anonymous

    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.

    • 3 weeks ago
      Anonymous

      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.

  24. 3 weeks ago
    Anonymous

    Yep

    https://qntm.org/clean

    • 3 weeks ago
      Anonymous

      This cannot be real

      • 3 weeks ago
        Anonymous

        >says he wants "clean code"
        >yet he uses only two spaces for indents

      • 3 weeks ago
        Anonymous

        provide your alternative implementation

        • 3 weeks ago
          Anonymous

          > 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

          • 3 weeks ago
            Anonymous

            >purely procedural style from 60s
            you actually think its better why

            • 3 weeks ago
              Anonymous

              >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

        • 3 weeks ago
          Anonymous

          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;
          }

      • 3 weeks ago
        Anonymous

        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.

  25. 3 weeks ago
    Anonymous

    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.

  26. 3 weeks ago
    Anonymous

    Just making this an entire class instead of one function is already naggerlicious. But I guess Javafags or whatever don't have a choice.

  27. 3 weeks ago
    Anonymous

    I don't event understand what this code is doing. Both examples are dirty as indian hands that wrote it

  28. 3 weeks ago
    Anonymous

    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).

  29. 3 weeks ago
    Anonymous

    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

    • 3 weeks ago
      Anonymous

      >it was just a prank bro

  30. 3 weeks ago
    Anonymous

    https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

  31. 3 weeks ago
    Anonymous

    Great example OP

  32. 3 weeks ago
    Anonymous

    >t. retard webshit "developer" seethe thread number 245

  33. 3 weeks ago
    Anonymous

    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.

    • 3 weeks ago
      Anonymous

      Oooh, didn't know this pasta. Thanks for sharing.

    • 3 weeks ago
      Anonymous

      >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

  34. 3 weeks ago
    Anonymous

    >protected
    Imagine still using inheritance. Learn to use interfaces you homosexual.

  35. 3 weeks ago
    Anonymous

    > SymbolReplacer
    just kill yourself already

  36. 3 weeks ago
    Anonymous

    I think clean code just means easily readable code to humans.

  37. 3 weeks ago
    Anonymous

    This is the prettiest example of clean code I have ever seen
    https://github.com/bvschaik/julius/blob/master/src/game/tick.c

    • 3 weeks ago
      Anonymous

      >https://github.com/bvschaik/julius/blob/master/src/game/tick.c
      I still don't understands why LULZ hates readable code?

    • 3 weeks ago
      Anonymous

      >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.

      • 3 weeks ago
        Anonymous

        Then tell me.
        What's wrong with clean code?

    • 3 weeks ago
      Anonymous

      >all state is global
      yikes

  38. 3 weeks ago
    Anonymous

    right side is objectively superior and youre all low iq animals

  39. 3 weeks ago
    Anonymous

    >OO
    into the trash it belongs

  40. 3 weeks ago
    Anonymous

    >"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

Your email address will not be published. Required fields are marked *