Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series)
Rate it:
Open Preview
3%
Flag icon
God is in the details,
6%
Flag icon
Code, without tests, is not clean. No matter how elegant it is, no matter how readable and accessible, if it hath not tests, it be unclean.
7%
Flag icon
It is not the language that makes programs appear simple. It is the programmer that make the language appear simple!
7%
Flag icon
Change one variable name for the better, break up one function that’s a little too large, eliminate one small bit of duplication, clean up one composite if statement.
9%
Flag icon
The word variable should never appear in a variable name.
10%
Flag icon
A class name should not be a verb.
10%
Flag icon
Methods should have verb or verb phrase names
12%
Flag icon
The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that.
12%
Flag icon
Functions should hardly ever be 20 lines long.
12%
Flag icon
if statements, else statements, while statements, and so on should be one line long.
12%
Flag icon
FUNCTIONS SHOULD DO ONE THING. THEY SHOULD DO IT WELL. THEY SHOULD DO IT ONLY.
14%
Flag icon
The parts we ignore are where the bugs will hide.
17%
Flag icon
“Don’t comment bad code—rewrite it.”
17%
Flag icon
Every time you write a comment, you should grimace and feel the failure of your ability of expression.
17%
Flag icon
Clear and expressive code with few comments is far superior to cluttered and complex code with lots of comments.
17%
Flag icon
it’s simply a matter of creating a function that says the same thing as the comment you want to write.
20%
Flag icon
Don’t Use a Comment When You Can Use a Function or a Variable
22%
Flag icon
an upper limit of 500.
22%
Flag icon
Small files are usually easier to understand than large files are.
23%
Flag icon
Instance variables, on the other hand, should be declared at the top of the class.
24%
Flag icon
If one function calls another, they should be vertically close, and the caller should be above the callee, if at all possible.
24%
Flag icon
we expect the most important concepts to come first, and we expect them to be expressed with the least amount of polluting detail. We expect the low-level details to come last.
25%
Flag icon
A team of developers should agree upon a single formatting style, and then every member of that team should use that style.
28%
Flag icon
Error handling is important,
30%
Flag icon
If you are tempted to return null from a method, consider throwing an exception or returning a SPECIAL CASE object instead.
30%
Flag icon
Returning null from methods is bad, but passing null into methods is worse. Unless you are working with an API which expects you to pass null, you should avoid passing null in your code whenever possible.
31%
Flag icon
Third-party code helps us get more functionality delivered in less time.
33%
Flag icon
Test code is just as important as production code.
33%
Flag icon
What makes a clean test? Three things. Readability, readability, and readability.
35%
Flag icon
we want to test a single concept in each test function. We don’t want long test functions that go testing one miscellaneous thing after another.
35%
Flag icon
test just one concept per test function.
35%
Flag icon
The tests should have a boolean output.
40%
Flag icon
we should implement only today’s stories, then refactor and expand the system to implement new stories tomorrow.
42%
Flag icon
designing everything up front before implementing anything at all.
43%
Flag icon
According to Kent, a design is “simple” if it follows these rules: • Runs all the tests • Contains no duplication • Expresses the intent of the programmer • Minimizes the number of classes and methods The rules are given in order of importance.
47%
Flag icon
Do not lock regions of code that do not need to be locked.
72%
Flag icon
It is best not to write a comment that will become obsolete.
72%
Flag icon
Comments should say things that the code cannot say for itself.
72%
Flag icon
A comment worth writing is worth writing well. If you are going to write a comment, take the time to make sure it is the best comment you can write.
72%
Flag icon
When you see commented-out code, delete it! Don’t worry, the source code control system still remembers it. If anyone really needs it,
72%
Flag icon
You should be able to run all the unit tests with just one command.
72%
Flag icon
Functions should have a small number of arguments. No argument is best, followed by one, two, and three. More than three is very questionable and should be avoided with prejudice.
73%
Flag icon
Boolean arguments loudly declare that the function does more than one thing. They are confusing and should be eliminated.
73%
Flag icon
G5: Duplication This is one of the most important rules in this book, and you should take it very seriously. Virtually every author who writes about software design mentions this rule.
73%
Flag icon
The fewer methods a class has, the better. The fewer variables a function knows about, the better. The fewer instance variables a class has, the better.
73%
Flag icon
Dead code is code that isn’t executed.
73%
Flag icon
You find it in the catch block of a try that never throws.
74%
Flag icon
G10: Vertical Separation
74%
Flag icon
Variables and function should be defined close to where they are used. Local variables should be declared just above their first usage and should have a small vertical scope. We don’t want local variables declared hundreds of lines distant from their usages.
76%
Flag icon
The team should not need a document to describe these conventions because their code provides the examples.
« Prev 1