rw-book-cover

Metadata

Highlights

Quality is the result of a million selfless acts of care—not just of any great method that descends from the heavens. (Location 435)

Of course, I am still an advocate of thinking at broader scope, and particularly of the value of architectural approaches rooted in deep domain knowledge and software usability. (Location 438)

design lives in the code. (Location 443)

rework in design leads to value. (Location 443)

Learning to write clean code is hard work. It requires more than just the knowledge of principles and patterns. You must sweat over it. You must practice it yourself, and watch yourself fail. You must watch others practice it and fail. (Location 474)

Bad code tries to do too much, it has muddled intent and ambiguity of purpose. Clean code is focused. (Location 667)

Clean code (Location 685)

has unit and acceptance tests. (Location 685)

focus mostly on duplication. When the same thing is done over and over, it’s a sign that there is an idea in our mind that is not well represented in the code. I try to figure out what it is. Then I try to express that idea more clearly. (Location 714)

Reduced duplication, high expressiveness, and early building of simple abstractions. That’s what makes clean code for me. (Location 732)

Ward Cunningham, (Location 734)

Programs that are that clean are so profoundly well written that you don’t even notice it. The designer makes it look ridiculously simple like all exceptional designs. (Location 747)

If we all checked-in our code a little cleaner than when we checked it out, the code simply could not rot. (Location 799)

The name of a variable, function, or class, should answer all the big questions. It should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name does not reveal its intent. (Location 832)

Beware of using names which vary in small ways. (Location 876)

A truly awful example of disinformative names would be the use of lower-case L or uppercase O (Location 883)

Use Pronounceable Names (Location 924)

Single-letter names and numeric constants (Location 941)

are not easy to locate across a body of text. (Location 942)

The length of a name should correspond to the size of its scope (Location 949)

A class name should not be a verb. (Location 1009)

When constructors are overloaded, use static factory methods with names that describe the arguments. (Location 1017)

We want to use the popular paperback model whereby the author is responsible for making himself clear and not the academic model where it is the scholar’s job to dig the meaning out of the paper. (Location 1053)

go ahead and use computer science (CS) terms, (Location 1056)

What programmer would not know what a JobQueue was? There are lots of very technical things that programmers have to do. Choosing technical names for those things is usually the most appropriate course. (Location 1059)

When there is no “programmer-eese” for what you’re doing, use the name from the problem domain. At least the programmer who maintains your code can ask a domain expert what it means. (Location 1062)

There are a few names which are meaningful in and of themselves—most are not. Instead, you need to place names in context for your reader by enclosing them in well-named classes, functions, or namespaces. When all else fails, then prefixing the name may be necessary as a last resort. (Location 1066)

The function is a bit too long and the variables are used throughout. To split the function into smaller pieces we need to create a GuessStatisticsMessage class and make the three variables fields of this class. This provides a clear context for the three variables. They are definitively part of the GuessStatisticsMessage. The improvement of context also allows the algorithm to be made much cleaner by breaking it into many smaller functions. (Location 1092)

In an imaginary application called “Gas Station Deluxe,” it is a bad idea to prefix every class with GSD. Frankly, you are working against your tools. You type G and press the completion key and are rewarded with a mile-long list of every class in the system. Is that wise? (Location 1115)