More on this book
Community
Kindle Notes & Highlights
Red Flag: Nonobvious Code If the meaning and behavior of code cannot be understood with a quick reading, it is a red flag. Often this means that there is important information that is not immediately clear to someone reading the code.
Another way of thinking about obviousness is in terms of information. If code is nonobvious, that usually means there is important information about the code that the reader does not have:
One of the risks of agile development is that it can lead to tactical programming. Agile development tends to focus developers on features, not abstractions, and it encourages developers to put off design decisions in order to produce working software as soon as possible.
With a good set of tests, developers can be more confident when refactoring because the test suite will find most bugs that are introduced.
Imagine instead that you are writing a new method that implements just the critical path, which is the minimum amount of code that must be executed in the the most common case.
I.e. Ignore all the extra functionality and try to find the key function performed by your application and optimise for that key function, i.e. Critical path. Allows to simplify and get rid of superfluities that might be slowing the code down
Let’s call this code “the ideal.” The ideal code probably clashes with your existing class structure, and it may not be practical, but it provides a good target: this represents the simplest and fastest that the code can ever be.
One of the most important things that happens in this process is to remove special cases from the critical path. When code is slow, it’s often because it must handle a variety of situations, and the code gets structured to simplify the handling of all the different cases.
This is a great point; a big part of the simplification process is to define what is important, and optimise around that. Spreading yourself too thin will result in increased complexity and lowered performance.
if you aren’t used to thinking about design issues, then you will slow down even more while you learn good design techniques. If the only thing that matters to you is making your current code work as soon as possible, then thinking about design will seem like drudge work that is getting in the way of your real goal.
The time you spent honing your design skills will also pay for itself: as your skills and experience grow, you will find that you can produce good designs more and more quickly. Good design doesn’t really take much longer than quick-and-dirty design, once you know how.
This allows for scalability in productivity, and follows the law of diminishing return. The rule is not to work hard, but to work on your strategy as much as possible so then every hour of your time is worth more.
If you improve your design skills, not only will you produce higher quality software more quickly, but the software development process will be more enjoyable.