A Philosophy of Software Design
Rate it:
Kindle Notes & Highlights
45%
Flag icon
However, if you are having trouble figuring out what to do for the particular situation, there’s a good chance that the caller won’t know what to do either.
45%
Flag icon
classes with lots of exceptions have complex interfaces, and they are shallower than classes with fewer exceptions.
45%
Flag icon
define errors out of existence.
46%
Flag icon
With this approach, an exceptional condition is detected and handled at a low level in the system, so that higher levels of software need not be aware of the condition.
47%
Flag icon
Exception masking is an example of pulling complexity downward.
47%
Flag icon
The third technique for reducing complexity related to exceptions is exception aggregation.
47%
Flag icon
A single handler in this method can catch all of the exceptions and generate an appropriate error response for missing parameters.
48%
Flag icon
However, getParameter knows nothing about the syntax of an HTTP error response.
48%
Flag icon
Exception aggregation works best if an exception propagates several levels up the stack before it is handled;
48%
Flag icon
masking usually works best if an exception is handled in a low-level method.
49%
Flag icon
Design special cases out of existence
50%
Flag icon
The notion of “no selection” makes sense in terms of how the user thinks about the application’s interface, but that doesn’t mean it has to be represented explicitly inside the application.
50%
Flag icon
design it twice.
51%
Flag icon
Does one alternative have a simpler interface than another? In the text example, all of the text interfaces are relatively simple.
51%
Flag icon
Is one interface more general-purpose than another?
51%
Flag icon
Does one interface enable a more efficient implementation than another? In the text example, the character-oriented approach is likely to be significantly slower than the others, because it requires a ...
This highlight has been truncated due to consecutive passage length restrictions.
51%
Flag icon
Use the problems you identified with the original alternatives to drive the new design(s).
51%
Flag icon
you might notice that each of the alternatives is awkward because it requires higher level software to perform additional text manipulations. That’s a red flag:
52%
Flag icon
the process of writing comments, if done correctly, will actually improve a system’s design.
53%
Flag icon
If you want to use abstractions to hide complexity, comments are essential.
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.
54%
Flag icon
Change amplification: a seemingly simple change requires code modifications in many places.
54%
Flag icon
Cognitive load: in order to make a change, the developer must accumulate a large amount of information.
54%
Flag icon
Unknown unknowns: it is unclear what code needs to be modified, or what information must be considered in ord...
This highlight has been truncated due to consecutive passage length restrictions.
54%
Flag icon
Comments Should Describe Things that Aren’t Obvious from the Code
54%
Flag icon
comments should describe things that aren’t obvious from 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.
55%
Flag icon
Interface:
55%
Flag icon
Data structure member:
55%
Flag icon
Implementation comment:
55%
Flag icon
Cross-module comment:
57%
Flag icon
If the information in a comment is already obvious from the code next to the comment, then the comment isn’t helpful.
57%
Flag icon
use different words in the comment from those in the name of the entity being described.
57%
Flag icon
Lower-level comments add precision
57%
Flag icon
comments. Comments augment the code by providing information at a different level of detail.
57%
Flag icon
provide information at a lower, more detailed, level than the code; these comments add precision by clarifying the exact meaning of the code.
57%
Flag icon
Other comments provide information at a higher, more abstract, level than the code; these...
This highlight has been truncated due to consecutive passage length restrictions.
57%
Flag icon
What are the units for this variable?
58%
Flag icon
Are the boundary conditions inclusive or exclusive?
58%
Flag icon
If a null value is permitted, what d...
This highlight has been truncated due to consecutive passage length restrictions.
58%
Flag icon
If a variable refers to a resource that must eventually be freed or closed, who is responsibl...
This highlight has been truncated due to consecutive passage length restrictions.
58%
Flag icon
Are there certain properties that are always true for the variable (invariants), such as “this list alway...
This highlight has been truncated due to consecutive passage length restrictions.
58%
Flag icon
When documenting a variable, think nouns, not verbs.
59%
Flag icon
Higher-level comments enhance intuition
61%
Flag icon
Interface documentation
61%
Flag icon
One of the most important roles for comments is to define abstractions.
61%
Flag icon
If you want code that presents good abstractions, you must document those abstractions with comments.
61%
Flag icon
interface comments from implementation comments.
61%
Flag icon
Interface comments provide information that someone needs to know in order to use a class or method;
61%
Flag icon
Implementation comments describe how a class or method works internally in order to i...
This highlight has been truncated due to consecutive passage length restrictions.