A Philosophy of Software Design
Rate it:
Open Preview
Read between November 25 - December 3, 2022
54%
Flag icon
The overall idea behind comments is to capture information that was in the mind of the designer but couldn’t be represented in the code.
55%
Flag icon
Developers should be able to understand the abstraction provided by a module without reading any code other than its externally visible declarations.
59%
Flag icon
missing. When documenting a variable, think nouns, not verbs. In other words, focus on what the variable represents, not how it is manipulated.
61%
Flag icon
The first step in documenting abstractions is to separate interface comments from implementation comments.
71%
Flag icon
When considering a particular name, ask yourself: “If someone sees this name in isolation, without seeing its declaration, its documentation, or any code that uses the name, how closely will they be able to guess what the name refers to? Is there some other name that will paint a clearer picture?”
73%
Flag icon
Consistency has three requirements: first, always use the common name for the given purpose; second, never use the common name for anything other than the given purpose; third, make sure that the purpose is narrow enough that all variables with the name have the same behavior.
73%
Flag icon
Every word in a name should provide useful information; words that don’t help to clarify the variable’s meaning just add clutter
75%
Flag icon
“The greater the distance between a name’s declaration and its uses, the longer the name should
78%
Flag icon
Ideally, when you have finished with each change, the system will have the structure it would have had if you had designed it from the start with that change in mind. To achieve this goal, you must resist the temptation to make a quick fix. Instead, think about whether the current system design is still the best one, in light of the desired change. If not, refactor the system so that you end up with the best possible design. With this approach, the system design improves with every modification.
79%
Flag icon
When writing implementation comments, don’t put all the comments for an entire method at the top of the method. Spread them out, pushing each comment down to the narrowest scope that includes all of the code referred to by the comment.
79%
Flag icon
the farther a comment is from the code it describes, the more abstract it should be (this reduces the likelihood that the comment will be invalidated by code changes).
79%
Flag icon
If there are multiple places in the code that are affected by a particular decision, don’t repeat the documentation at each of these points. Instead, find the most obvious single place to put the documentation.
88%
Flag icon
Developing incrementally is generally a good idea, but the increments of development should be abstractions, not features. It’s fine to put off all thoughts about a particular abstraction until it’s needed by a feature. Once you need the abstraction, invest the time to design it cleanly;
88%
Flag icon
The problem with test-driven development is that it focuses attention on getting specific features working, rather than finding the best design. This is tactical programming pure and simple, with all of its disadvantages. Test-driven development is too incremental: at any point in time, it’s tempting to just hack in the next feature to make the next test pass. There’s no obvious time to do design, so it’s easy to end up with a mess.
89%
Flag icon
One place where it makes sense to write the tests first is when fixing bugs. Before fixing a bug, write a unit test that fails because of the bug. Then fix the bug and make sure that the unit test now passes. This is the best way to make sure you really have fixed the bug.
89%
Flag icon
don’t try to force a problem into a design pattern when a custom approach will be cleaner.
90%
Flag icon
If the faster design adds a lot of implementation complexity, or if it results in more complicated interfaces, then it may be better to start off with the simpler approach and optimize later if performance turns out to be a problem.
94%
Flag icon
To decide what matters, look for leverage, where the solution to one problem also allows many other problems to be solved, or where knowing one piece of information makes it easy to understand many other things.
« Prev 1 2 Next »