In a complex system, it takes a lot of work to implement even small improvements. In a simple system, larger improvements can be implemented with less effort.
A Philosophy of Software Design
- loc 306-307 · Challenging Assumptions And Habits
Your job as a developer is not just to create code that you can work with easily, but to create code that others can also work with easily.
loc 321-322 · Action And Executiona dependency exists when a given piece of code cannot be understood and modified in isolation; the code relates in some way to other code, and the other code must be considered and/or modified if the given code is changed.
loc 369-371 · Information And ModularityObscurity occurs when important information is not obvious.
loc 387-388 · Information And ModularityThe problem with tactical programming is that it is short-sighted. If you’re programming tactically, you’re trying to finish a task as quickly as possible. Perhaps you have a hard deadline. As a result, planning for the future isn’t a priority.
loc 424-426 · Deep Work PrinciplesTypically, other engineers must clean up the messes left behind by the tactical tornado, which makes it appear that those engineers (who are the real heroes) are making slower progress than the tactical tornado.
loc 443-444 · Challenging Assumptions And HabitsYour primary goal must be to produce a great design, which also happens to work. This is strategic programming .
loc 450 · Challenging Assumptions And HabitsAt the beginning, a tactical approach to programming will make progress more quickly than a strategic approach. However, complexity accumulates more rapidly under the tactical approach, which reduces productivity. Over time, the strategic approach results in greater progress.
loc 471-473 · Deep Work PrinciplesOne of the most important techniques for managing software complexity is to design systems so that developers only need to face a small fraction of the overall complexity at any given time.
loc 517-518 · Information And ModularityThe best modules are deep: they allow a lot of functionality to be accessed through a simple interface.
loc 591-592 · Action And ExecutionA shallow module is one whose interface is complicated relative to the functionality it provides. Shallow modules don’t help much in the battle against complexity, because the benefit they provide (not having to learn about how they work internally) is negated by the cost of learning and using their interfaces. Small modules tend to be shallow.
loc 641-643 · Information And ModularityWhen designing a new module, you should think carefully about what information can be hidden in that module. If you can hide more information, you should also be able to simplify the module’s interface, and this makes the module deeper.
loc 710-711 · Information And ModularityInformation leakage occurs when a design decision is reflected in multiple modules. This creates a dependency between the modules: any change to that design decision will require changes to all of the involved modules. If a piece of information is reflected in the interface for a module, then by definition it has been leaked; thus, simpler interfaces tend to correlate with better information hiding.
loc 721-723 · Information And ModularityIf you encounter information leakage between classes, ask yourself “How can I reorganize these classes so that this particular piece of knowledge only affects a single class?” If the affected classes are relatively small and closely tied to the leaked information, it may make sense to merge them into a single class. Another possible approach is to pull the information out of all of the affected classes and create a new class that encapsulates just that information.
loc 728-732 · Information And ModularityInformation leakage occurs when the same knowledge is used in multiple places, such as two different classes that both understand the format of a particular type of file.
loc 736-737 · Information And ModularityIn temporal decomposition, execution order is reflected in the code structure: operations that happen at different times are in different methods or classes. If the same knowledge is used at different points in execution, it gets encoded in multiple places, resulting in information leakage.
loc 752-754 · Information And Modularityinformation hiding can often be improved by making a class slightly larger . One reason for doing this is to bring together all of the code related to a particular capability (such as parsing an HTTP request), so that the resulting class contains everything related to that capability.
loc 780-781 · Information And ModularityIf the API for a commonly used feature forces users to learn about other features that are rarely used, this increases the cognitive load on users who don’t need the rarely used features.
loc 838-840 · Information And Modularitythink about the different pieces of knowledge that are needed to carry out the tasks of your application, and design each module to encapsulate one or a few of those pieces of knowledge. This will produce a clean and simple design with deep modules.
loc 859-860 · Information And ModularityMaking your modules somewhat general-purpose is one of the best ways to reduce overall system complexity.
loc 968-969 · Information And ModularityA pass-through method is one that does nothing except pass its arguments to another method, usually with the same API as the pass-through method. This typically indicates that there is not a clean division of responsibility between the classes.
loc 1003-1005 · Information And ModularityIt is fine for several methods to have the same signature as long as each of them provides useful and distinct functionality. The methods invoked by a dispatcher have this property.
loc 1038-1039 · Action And Executionit is more important for a module to have a simple interface than a simple implementation.
loc 1139-1140 · Action And ExecutionIdeally, each module should solve a problem completely; configuration parameters result in an incomplete solution, which adds to system complexity.
loc 1178-1179 · Information And ModularityIf the same piece of code (or code that is almost the same) appears over and over again, that’s a red flag that you haven’t found the right abstractions.
loc 1265-1266 · Information And Modularity