Clean Code: A Handbook of Agile Software Craftsmanship

Author: Robert C. Martin
4.5
All Stack Overflow 184
This Year Reddit 166
This Month Reddit 14

About This Book

Even bad code can function. But if code isn't clean, it can bring a development organization to its knees. Every year, countless hours and significant resources are lost because of poorly written code. But it doesn't have to be that way.

Noted software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship . Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code "on the fly" into a book that will instill within you the values of a software craftsman and make you a better programmer--but only if you work at it.

What kind of work will you be doing? You'll be reading code--lots of code. And you will be challenged to think about what's right about that code, and what's wrong with it. More importantly, you will be challenged to reassess your professional values and your commitment to your craft.

Clean Code is divided into three parts. The first describes the principles, patterns, and practices of writing clean code. The second part consists of several case studies of increasing complexity. Each case study is an exercise in cleaning up code--of transforming a code base that has some problems into one that is sound and efficient. The third part is the payoff: a single chapter containing a list of heuristics and "smells" gathered while creating the case studies. The result is a knowledge base that describes the way we think when we write, read, and clean code.

Readers will come away from this book understanding

  • How to tell the difference between good and bad code
  • How to write good code and how to transform bad code into good code
  • How to create good names, good functions, good objects, and good classes
  • How to format code for maximum readability
  • How to implement complete error handling without obscuring code logic
  • How to unit test and practice test-driven development

This book is a must for any developer, software engineer, project manager, team lead, or systems analyst with an interest in producing better code.

Clean Code: A Handbook of Agile Software Craftsmanship

4.5

Review Date:

Comments

by KevMar   2018-11-10

There are a lot of good answers in there already. Clean Code is one book that I read that I feel really changed the way I think about and write code. It's not PowerShell, but the ideas apply to any language and the code examples are easy enough to read.

by Yevon   2018-11-10

I recommend reading Clean Code if you haven't already.

https://toptalkedbooks.com/amzn/0132350882

Otherwise you need to be more specific about the question and how you solved it.

by Balduracuir   2018-11-10

That line of code you showed violates more Interface segregation principle than Single responsability to me.
It's not because everyone is using something that it is a good practice... You can try to spread the good word around you and encourage people to read or re-read Clean code for example.

by ExpatGuy06   2018-11-10

I'm not sure if you're already aware of it, but if you're interested to study, I wish to recommend 2 books -

Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series)

The Pragmatic Programmer

These are highly recommended books by many professors and architects.

by workmike026   2018-11-10

Read "Clean Code by Robert C. Martin (Uncle Bob): https://toptalkedbooks.com/amzn/0132350882

by NiceOneAsshole   2018-11-10

They do a good job trying to cover best practices. Can anything truly cover everything?

Without assuming your prior knowledge, I'd suggest looking through codebases/issues/PR's of large libraries in the react ecosystem. Conversations between maintainers and contributors tend to be very educational. Some good repos to peruse - redux, react-virtualized, react-router. /u/acemarke can also hook you up with his great lists/links that you can peruse.

And of course the ultimate recommendation for best practices - Clean Code .

by FizixMan   2018-11-10

Clean Code by Bob Martin

It's written in Java, but for the most part, it's very transferable to C#. When I was a junior dev transitioning to intermediate, it was pretty worth my while. It's a relatively easy read and doesn't require you to be writing code or sitting at a computer (at least it didn't for me).

Feel free though while reading it to critically question some ideas as to how applicable they are in the C#.NET ecosystem, current best practices, and your day-to-day work. (For example, IIRC, he argues that you shouldn't prefix interfaces with the capital I. I still do that though and I find it worthwhile.)

by what2_2   2018-11-10

They're not about architectural patterns so much as development philosophies that will allow you to solve problems the right way, sometimes illustrated through architectural examples, but:

The Pragmatic Programmer [https://toptalkedbooks.com/amzn/020161622X)

followed by

Clean Code [https://toptalkedbooks.com/amzn/0132350882)

by krizo   2018-11-10

I'm not sure if you're trolling or not.

If you're serious, then you're either a very very green developer or just an experienced terrible developer. Either way, you have a lot of learning to do.

Here are a couple of books I highly recommend.

The Pragmatic Programmer: From Journeyman to Master

and

Clean Code: A Handbook of Agile Software Craftsmanship

I hope you give this a shot. I'm not trying to insult you passive aggressively or anything. Just telling it like it is. You need to get passed your arrogance and start trying to be better. It would be a terrible waste of skill and talent if you remain this way.

by YuleTideCamel   2018-11-10

Definitely read the book Clean Code . Clean , well architected code is code that not only works, but also is easy to read and easy to modify (maintainable.) Some of this you'll learn by experience, but the book has some good concepts that are worth looking at. At the end of the day, if you were to take your code and ask another engineer to review it, how hard would that be? If it's easy for them to understand and grok (and change if need be) then it's good code imo. Another major litmus test is unit tests , good code has unit tests :)

In terms of design patterns, Head First Design patterns is a good intro to a few popular patterns. The book Design Patterns: Elements of Reusable Object-Oriented Software is one of the most important design pattern books, but it's a dense read. Good to have as a reference for specific patterns.

> Did I misunderstand him?

Maybe , hard to tell without more context or code samples. He could have objected to you building a binary tree class from scratch. As an architect, I often encourage devs to use existing data structures in the language they are coding in. Those are often very well designed (though not always) and work well. It's a case of not re-inventing the wheel, or put another way. Our job isn't to write a binary tree class, it's to solve the specific problem at hand.