Unix Programming - Speaking of Complexity - Mapping Complexity
So far, we've developed two different scales for thinking about
complexity. These scales are actually orthogonal to each other.
Figure13.1 may help clarify the
relationships. Each of the nine boxes of the figure lists a common
source of a particular kind of complexity.
We've touched on some of these varieties of complexity earlier
in this book, especially the accidental ones. In Chapter4 we saw that accidental interface
complexity often comes from non-orthogonality in the interface design
— that is, failing to carefully factor the interface operations
so that each does exactly one thing. Accidental code complexity
(making code more complicated than it needs to be to get the job done)
often results from premature optimization. Accidental codebase bloat
often results from violating the SPOT rule, duplicating code or
organizing it poorly so that opportunities for reuse aren't
recognized.
Essential interface complexity usually can't be cut without
trimming the basic functional requirements for the software (a theme
we'll develop further in this chapter's case studies). Essential
codebase size is related to choice of development tools because, if
the feature list is held constant, the most important factor in
codebase size is probably the choice of implementation language (as we
implied in Chapter8).
Sources of optional complexity are the most difficult to make
useful generalizations about, because they so often depend on
delicate judgments about which features it is worth paying the
complexity cost for. Optional interface complexity often comes from
adding convenience features that make life easier for users but aren't
essential to the function of the program. Optional increases in
codebase size (supposing the user-visible features and the algorithms
used are held constant) can often come from various sorts of practices
intended to make it more maintainable — adding mode comments,
using long variable names, and so forth. Optional implementation
complexity tends to be driven by
everything
that
touches a project.
The sources of complexity have to be grappled with in different
ways. Codebase size can be attacked with better tools.
Implementation complexity can be addressed with better choice of
algorithms. Interface complexity has to be addressed with better
interaction design, a skill involving considerations of ergonomics and
user psychology. This skill is less common (and possibly more
difficult) than writing code.
Attacking the kinds of complexity, on the other hand, has to be
done more with insight than with methods. You cut accidental
complexity by noticing that there is a simpler way to do things.
You cut optional complexity by making context-dependent judgments
about what features are worthwhile. You can only cut essential
complexity by having an epiphany, fundamentally redefining the
problem you are addressing.
[an error occurred while processing this directive]
|