I’m a junior developer, and I’m looking for a book that teaches code design concepts. Clean Code is the most recommended book I saw, but it is also extremely controversial.

Any alternatives to read? I’m not a complete beginner as I have a Bachelor’s degree in CS, but I’m fairly new to the concept of writing “clean code”.

help-circle
  • @ttmrichter
    link
    62 years ago

    If you have ten programmers in a room and ask them to define “clean code” you will get eleven highly-incompatible definitions. This is because there are so many axes of “cleanliness” in code (readability, navigability, documentation, reusability, maintainability, discoverability, modifiability, testability, etc. etc. etc. etc. ad nauseum) that each programmer weighs differently in their assessment of what constitutes “clean”. And it doesn’t help that most people opining on the topic haven’t done nor read any actual empirical research relating to it, so what constitutes “clean” is basically just loud opinion masquerading as considered thought.

    • @MarcellusDrumOP
      link
      32 years ago

      I understand that. But still, tips like “Name your variables correctly”, “One feature per function”, and “Properly comment your code” are universal advices that will benefit everyone. I’m looking for a book that discusses simple practices in details. How to use abstraction correctly for example.

      • @ttmrichter
        link
        52 years ago

        Even these seemingly non-controversial pieces of advice turn out to have controversy attached to them.

        “Name your variables correctly,” for example, is that every experienced programmer will agree upon. What constitutes “correctly” however, is fuel for raging knock-down, drag-outs in coding groups. Let’s presume OOP programming and you have a class for a bank account. Obviously it will have a balance. (Ignore the poor modeling for pedagogic purposes. Real bank accounts can have multiple balances…) What should that balance variable be named, assuming the containing class is called BankAccount?:

        • balance
        • m_balance
        • fpBalance — the fp means fixed point
        • m_fpBalance
        • _balance
        • account_balance
        • accountBalance
        • AccountBalance
        • m_AccountBalance
        • fpAccountBalance
        • _AccountBalance
        • _fpAccountBalance
        • accBalance
        • m_accBalance
        • … and a cast of hundreds more.

        I have seen some variant of each of the examples provided and dozens more used in real-world code. I have watched programmers red/purple-faced and shouting at each other over which is right. (Programmers seem to have a problem with comprehending “perspective”.)

        Now lather, rinse, repeat for each and every other nugget of advice out there.

        And keep in mind, again, that this is screaming matches over trivial differences in agreed-upon principles. When you mix in things where even the principle isn’t agreed upon (“what is the right level of abstraction?”, say) … let’s just say that things get really ugly unless you’ve got management ready to stomp, hard, on the resulting interactions.

        Any book you read on the topic, as a result, will be just as controversial as Uncle Bobs’s Clean Code or Joe-Bob’s Rifle Range and Really Good Code Structuring or whatever.

        So my advice is … don’t look for any particular book. Pick up a book—it sounds like you already have one—and read it and make notes of what you do and do not agree with. Then read code. Lots of it. See where it follows and doesn’t follow what your book said. See if you can figure out why. Then see if you agree with the other approach more than, say, Maisie-Sue’s Coding and Crocheting.

        • @MarcellusDrumOP
          link
          12 years ago

          Very well said. I started reading the Clean Code, and the author makes it clear in the introduction that while he stands behind his school of thought, he agrees that it isn’t the only good one.

          Also what I’m excited about in the book are the study cases, which are basically practical examples to solidify the principles.

          Thanks for the detailed answer, much appreciated.

  • dinomug
    link
    42 years ago

    Well, Uncle Bob’s Clean Code is recommended for a strictly “object-oriented” approach, if you work with this paradigm (C#, Java, Typescript, etc.) this is your book. In this kind of books it’s not important the time in which they were written, but the concepts and guidelines that you get.

    The “clean code” is an ambiguous concept, it’s not just about the “code”, it involves the architecture of what you’re building, standards, workflow, technologies/languages, etc.

    You can also be more specific about what technology/language/paradigm you are working with so We can recommend books more focused on your needs.

  • Helix 🧬
    link
    fedilink
    3
    edit-2
    2 years ago

    If you do a twelve factor app, you cover most of the “clean code” stuff by accident. Uncle Bob also coined the term Clean Architecture, which also requires you to have a sane environment for your Clean Code. The latter is a requisite for the former.

    I can also recommend The Pragmatic Programmer by Andy Hunt.