Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series)
Rate it:
Open Preview
Kindle Notes & Highlights
15%
Flag icon
Functions should either do something or answer something, but not both.
16%
Flag icon
It would appear that since the invention of the subroutine, innovations in software development have been an ongoing attempt to eliminate duplication from our source code.
16%
Flag icon
The art of programming is, and has always been, the art of language design.
17%
Flag icon
“Don’t comment bad code—rewrite it.” —Brian W. Kernighan and P. J. Plaugher1
17%
Flag icon
comments are, at best, a necessary evil.
17%
Flag icon
The proper use of comments is to compensate for our failure to express ourself in code.
17%
Flag icon
Inaccurate comments are far worse than no comments at all.
17%
Flag icon
Truth can only be found in one place: the code.
17%
Flag icon
It takes only a few seconds of thought to explain most of your intent in code.
17%
Flag icon
Keep in mind, however, that the only truly good comment is the comment you found a way not to write.
22%
Flag icon
First of all, let’s be clear. Code formatting is important
22%
Flag icon
The coding style and readability set precedents that continue to affect maintainability and extensibility long after the original code has been changed beyond recognition.
24%
Flag icon
As in newspaper articles, 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. This allows us to skim source files, getting the gist from the first few functions, without having to immerse ourselves in the details.
26%
Flag icon
Hiding implementation is not just a matter of putting a layer of functions between the variables. Hiding implementation is about abstractions!
26%
Flag icon
A class does not simply push its variables out through getters and setters. Rather it exposes abstract interfaces that allow its users to manipulate the essence of the data, without having to know its implementation.
26%
Flag icon
Objects hide their data behind abstractions and expose functions that operate on that data. Data structure expose their data and have no meaningful functions.
27%
Flag icon
Mature programmers know that the idea that everything is an object is a myth. Sometimes you really do want simple data structures with procedures operating on them.
28%
Flag icon
Error handling is important, but if it obscures logic, it’s wrong.
29%
Flag icon
When you wrap a third-party API, you minimize your dependencies upon it: You can choose to move to a different library in the future without much penalty.
33%
Flag icon
Test code is just as important as production code.
33%
Flag icon
It is unit tests that keep our code flexible, maintainable, and reusable.
33%
Flag icon
What makes a clean test? Three things. Readability, readability, and readability.
34%
Flag icon
That is the nature of the dual standard. There are things that you might never do in a production environment that are perfectly fine in a test environment. Usually they involve issues of memory or CPU efficiency. But they never involve issues of cleanliness.
35%
Flag icon
we want to test a single concept in each test function.
35%
Flag icon
If you let the tests rot, then your code will rot too. Keep your tests clean.
36%
Flag icon
If we cannot derive a concise name for a class, then it’s likely too large.
36%
Flag icon
However, a system with many small classes has no more moving parts than a system with a few large classes.
37%
Flag icon
When classes lose cohesion, split them!
39%
Flag icon
Classes should be open for extension but closed for modification.
39%
Flag icon
In an ideal system, we incorporate new features by extending the system, not by making modifications to existing code.
39%
Flag icon
In essence, the DIP says that our classes should depend upon abstractions, not on concrete details.
40%
Flag icon
If we are diligent about building well-formed and robust systems, we should never let little, convenient idioms lead to modularity breakdown.
40%
Flag icon
It is a myth that we can get systems “right the first time.” Instead, we should implement only today’s stories, then refactor and expand the system to implement new stories tomorrow.
40%
Flag icon
Software systems are unique compared to physical systems. Their architectures can grow incrementally, ifwe maintain the proper separation of concerns.
42%
Flag icon
An optimal system architecture consists of modularized domains of concern, each of which is implemented with Plain Old Java (or other) Objects. The different domains are integrated together with minimally invasive Aspects or Aspect-like tools. This architecture can be test-driven, just like the code.
43%
Flag icon
A premature decision is a decision made with suboptimal knowledge.
43%
Flag icon
The agility provided by a POJO system with modularized concerns allows us to make optimal, just-in-time decisions, based on the most recent knowledge. The complexity of these decisions is also reduced.
43%
Flag icon
A good DSL minimizes the “communication gap” between a domain concept and the code that implements it,
43%
Flag icon
Domain-Specific Languages allow all levels of abstraction and all domains in the application to be expressed as POJOs, from high-level policy to low-level details.
43%
Flag icon
Whether you are designing systems or individual modules, never forget to use the simplest thing that can possibly work.
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.
43%
Flag icon
Systems that aren’t testable aren’t verifiable. Arguably, a system that cannot be verified should never be deployed.
43%
Flag icon
making sure our system is fully testable helps us create better designs.
43%
Flag icon
Once we have tests, we are empowered to keep our code and classes clean. We do this by incrementally refactoring the code.
43%
Flag icon
The fact that we have these tests eliminates the fear that cleaning up the code will break it!
44%
Flag icon
The majority of the cost of a software project is in long-term maintenance.
44%
Flag icon
code should clearly express the intent of its author.
44%
Flag icon
By using the standard pattern names, such as COMMAND or VISITOR, in the names of the classes that implement those patterns, you can succinctly describe your design to other developers.
44%
Flag icon
Someone reading our tests should be able to get a quick understanding of what a class is all about.
44%
Flag icon
Care is a precious resource.