Complexity
Contents
Abstract
Complexity can be measured and evaluated. Its effects can be determined through experimentation.
Introduction
In my head is the concept of "complexity". Much like cost, you can analyze something, determine its complexity, and then make judgments about the thing.
We can think of the complexity of a variety of things: a particular skill, a program, an API, a user interface, etc...
In my world, the complexity of a UI, an API, a program, or a skill is particularly relevant.
Analyzing the Complexity of a Skill
The complexity of a skill comes from the complexity of learning the skill, as well as the complexity of determining when it is appropriate to use a skill, and the complexity of using the skill. There is also complexity in analyzing the skill itself.
The complexity of learning a skill can be individually measured based on how many facts must be memorized and how many behaviors must be trained into the body. Without these behaviors and facts, the skill doesn't exist as part of the person's skill set.
The complexity of determining when to use a skill is something that is more difficult to analyze. It lies with understand what observables exist, as well as the parameters for those observables which require the skill. You could consider this a skill unto itself.
The complexity of using a skill is how many things must be done and in what particular order. For instance, it is more complex if you have to do 3 things instead of 2. It is also more complex if you have to do 3 things in a particular order, rather than 3 things in any order.
The complexity of analyzing the skill is based on how many variables enter into the parameters of the skill. For instance, we know it is impossible to analyze how long certain programs will run, while it is pretty easy to analyze how long it takes to bake a loaf of bread, given a variety of circumstances.
Analyzing the Complexity of a UI
The complexity of a UI is determined by several factors:
- The number of operable components.
- The difficulty in uncovering those components.
- The difficult in manipulating those components.
- The mental model that must be maintained to operate the UI correctly.
A less complicated system would require the use of more complicated components less often than a more complicated one. So frequency of use is also an important factor.
While a UI with a single component could appear to be simple, making the component difficult to find, or difficult to operate will increase the complexity. Also, even with relatively few components can be extraordinarily complex because of the mental model that must be maintained.
Take, for instance, the heater in a car versus the central heater in your house. In your home, you likely configure the heater with a thermostat. A simple dial can set the desired temperature. In your car, you have a similar device but no hint at temperature is given. Because the mechanics and electronics in the home (a temperature sensor, plus the on-off nature of the heater) is much more complex than the mechanics in the car (a simple flap that controls the proportion of hot vs. outside air), we can consider the home heater to be a more complex UI.
Analyzing the Complexity of a Program
All of these things increase the complexity of a program.
- Increasing the number of lines. Each line adds complexity.
- Increasing the length of the names of things.
- Increasing the number of operations performed on a single line. 1 + 4 vs. 1 + (2 * 2)
- Adding variables.
- Adding functions.
- Adding parameters to a function.
- Adding classes.
- Adding parent classes to a class.
- Adding modules (independent of code.)
- Adding dependencies (independent of code.)
As the complexity increases, the number of things the programmer has to think about when completing his tasks increase.
Analyzing the Complexity of an API
All of these things increase the complexity of an API:
- Increasing the number of API calls.
- The mental model behind the API.
- Increasing the number of parameters.
- Increasing the number of objects, or the methods or attributes on the objects.
General Analysis
The complexity increases as the number of things the person must think of increase.
It is possible to increase features without adding much complexity, or even reducing complexity. For instance, it is roughly equal in complexity to think of two operations, add and subtract, or one operation (add) and two types of numbers (positive and negative). When you begin to add multiplication and division, however, one type of thinking is obviously simpler than the other. If you didn't think numbers came as positive or negative, you would have to invent negative multiplication, negative division, as well as an operator that handles the left side being negative.
Effects of Complexity
I suppose the following effects can be attributed to complexity:
- Complex things take longer to learn than simple things.
- The chances of someone fully understanding a complex thing is much lower than someone understanding a simple thing.
- The chances of doing something complex incorrectly is much higher than doing something simple incorrectly.
- It is much more difficult to reason about complex things than simple things.
General Rule of Thumb
As you go through life, one of your duties to the people coming behind you is to reduce the complexity of the world. If you could leave the world with the same thing in two forms, one simple and the other complex, then you should choose the simple form. The reason is simply because you will be making life simpler.
That is not to say complexity should be avoided at all costs. Sometimes, complexity is necessary! You can't do math without mastering the complex skills involved, and without math, so many simple things would remain hidden!
Intellectual Challenge
Take something, and make it simpler without ruining it. That is the hardest challenge of all. This is the difference between successful and famous mathematicians and scientists, and brilliant mathematicians and scientists you've never heard of.