A Philosophy of Software Design
This means that the greatest limitation in writing software is our ability to understand the systems we are creating.
Programmers aren’t bound by practical limitations such as the laws of physics; we can create exciting virtual worlds with behaviors that could never exist in the real world. Programming doesn’t require great physical
Programmers aren’t bound by practical limitations such as the laws of physics; we can create exciting virtual worlds with behaviors that could never exist in the real world.
Software systems are intrinsically more complex than physical systems; it isn’t possible to visualize the design for a large software system well enough to understand all of its implications before building anything.
Complexity is what a developer experiences at a particular point in time when trying to achieve a particular goal.
Complexity is anything related to the structure of a software system that makes it hard to understand and modify the system.
Isolating complexity in a place where it will never be seen is almost as good as eliminating the complexity entirely.
Complexity is more apparent to readers than writers.
The first symptom of complexity is that a seemingly simple change requires code modifications in many different places.
Change amplification: The first symptom of complexity is that a seemingly simple change requires code modifications in many different places.
Sometimes an approach that requires more lines of code is actually simpler, because it reduces cognitive load.
With unknown unknowns, it is unclear what to do or whether a proposed solution will even work.
With unknown unknowns, it is unclear what to do or whether a proposed solution will even work. The only way to be certain is to read every line of code in the system, which is impossible for systems of any
With unknown unknowns, it is unclear what to do or whether a proposed solution will even work. The only way to be certain is to read every line of code in the system, which is impossible for systems of any size.
The first step towards becoming a good software designer is to realize that working code isn’t enough. It’s not acceptable to introduce unnecessary complexities in order to finish your current task faster.
Your primary goal must be to produce a great design, which also happens to work. This is strategic programming.
No matter how much you invest up front, there will inevitably be mistakes in your design decisions.
A developer working in a particular module must understand the interface and implementation of that module, plus the interfaces of any other modules invoked by the given module. A developer should not need to understand the implementations of modules other than the one he or she is working in.
A developer working in a particular module must understand the interface and implementation of that module, plus the interfaces of any other modules invoked by the given module.
If a module’s interface is much simpler than its implementation, there will be many aspects of the module that can be changed without affecting other modules.
In modular programming, each module provides an abstraction in the form of its interface.
An abstraction that omits important details is a false abstraction: it might appear simple, but in reality it isn’t.
The best modules are deep: they allow a lot of functionality to be accessed through a simple interface.
A deep module is a good abstraction because only a small fraction of its internal complexity is visible to its users.
A module’s interface represents the complexity that the module imposes on the rest of the system: the smaller and simpler the interface, the less complexity that it introduces.
Providing choice is good, but interfaces should be designed to make the common case as simple as possible
The best form of information hiding is when information is totally hidden within a module, so that it is irrelevant and invisible to users of the module.
Pass-through methods make classes shallower: they increase the interface complexity of the class, which adds complexity, but they don’t increase the total functionality of the system.