Updates from 04-13.

This commit is contained in:
russoj88 2020-04-13 20:22:24 -07:00
parent 4c235a8ee0
commit eae3547012

View File

@ -8,40 +8,52 @@ desc: What is complexity as it relates to software?
The most [relevant definition of complexity](https://www.lexico.com/en/definition/complex) for this blog post is: (adj) "Not easy to analyze or understand; complicated or intricate." Intuition of complexity is important if you are designing, writing, or reading software. If you are purchasing software, it is important to prioritize simpler options; it will be cheaper in the long run. In this blog post, I will discuss identifying complexity, why it's bad, why simple is good, and how software engineers manage complexity. The most [relevant definition of complexity](https://www.lexico.com/en/definition/complex) for this blog post is: (adj) "Not easy to analyze or understand; complicated or intricate." Intuition of complexity is important if you are designing, writing, or reading software. If you are purchasing software, it is important to prioritize simpler options; it will be cheaper in the long run. In this blog post, I will discuss identifying complexity, why it's bad, why simple is good, and how software engineers manage complexity.
## Identifying Complexity ## Identifying Complexity
Before being able to manage complexity, it must be identified. In addition to the definition, it is helpful to know indicators and examples. Seasoned engineers sometimes call these smells; complexity is not black and white, but more of an intuition. Some things that are simple now will become complex in the future. Before being able to manage complexity, it must be identified. In addition to the definition, it is helpful to know indicators and examples. Seasoned engineers sometimes call these smells; complexity is not black and white, but more of an intuition. Some things that appear simple now may become complex in the future.
#### Indicators #### Indicators
* Incomprehensible: Something complex is difficult to comprehend or articulate. It may have too many parts, or the interaction between the parts is complicated. * Incomprehensible: Something complex is difficult to comprehend or articulate. It may have too many parts, or the interaction between the parts is complicated.
* Fragile to change: Complex things are not easily modified. An internal combustion engine is complex. If one was to modify the bore of the cylinders, special machining and new parts are required. * Fragile to change: Complex things are not easily modified. An internal combustion engine is complex. If one was to modify the bore of the cylinders, special machining and new parts are required.
* Multi-purpose: A tool that can, "do it all," usually does nothing well due to its complexity. * Multi-purpose: A tool that can, "do it all," usually does nothing well due to its complexity.
#### Examples #### Examples
* Run on sentences: Sentences that have too many clauses become complex because they are trying to express too many independent, but possibly related, although sometimes unrelated thoughts, and they take more mental energy to comprehend, causing the now frustrated reader to reread it until they can ascertain the author's meaning. * Run on sentences: Sentences that have too many clauses become complex because they are trying to express several independent, but possibly related, although sometimes unrelated thoughts, and they take more mental energy to comprehend, causing the now frustrated reader to reread it until they can ascertain the author's meaning.
* Chess: At a glance, chess is straightforward. There are only six types of pieces, and the board is 8x8. The complexity comes from the [permutation of games](https://www.youtube.com/watch?v=Km024eldY1A). It generally takes [a dedicated decade](https://www.quora.com/How-long-does-it-take-to-become-a-chess-grandmaster) to become a grand master. * Chess: At a glance, chess is straightforward. There are only six types of pieces, and the board is 8x8. The complexity comes from the [permutation of games](https://www.youtube.com/watch?v=Km024eldY1A). It generally takes [a dedicated decade](https://www.quora.com/How-long-does-it-take-to-become-a-chess-grandmaster) to become a grand master.
* Humans: No two humans are the same. DNA on its own is complex; factoring in the expression of DNA is beyond the understanding of any single person.
* Humans: No two humans are the same. DNA on its own is complex; factoring in the expression of that DNA is beyond the understanding of any single person.
## Complex Software is Undesirable ## Complex Software is Undesirable
All software is complex; it is one of the most complex man-made things. Physical creations such as space ships, submarines, and skyscrapers may be complex, but they are limited by the laws of physics. Software has no such limit. [FreeBSD](https://www.freebsd.org/) is an operating system that was first released in 1993. Using [scc](https://github.com/boyter/scc), a tool to estimate the size of codebases, it is shown to take about 16 years with 500 people to recreate FreeBSD 12.1. All software is complex; it is one of the most complex man-made things. Physical creations such as space ships, submarines, and skyscrapers may be complex, but they are limited by the laws of physics. Software has no such limit. [FreeBSD](https://www.freebsd.org/) is an operating system that was first released in 1993. Using [scc](https://github.com/boyter/scc), a tool to evaluate the size of codebases, it estimates about 16 years with 500 people to recreate FreeBSD 12.1.
While some complexity is unavoidable, it is best minimized. Complex software is difficult to reason about and therefore difficult to rule out bugs. This is code that an adversary would enjoy combing through, trying to find an exploit. While some complexity is unavoidable, it is best minimized. Here are a few reasons to minimize the complexity of software:
{ reasons it is undesirable }
* Expensive changes: As software gets more complex, the cost to change increases exponentially. A module bound to several business concerns is more expensive than a module that does one thing. Engineers, business representatives, and managers need to work together instead of just handing a simple task to an engineer.
* Time: While money can be acquired, time keeps ticking. If a project becomes expensive, some larger companies can handle it. If the software is complex enough, the bottleneck becomes time and at that point it is too late. By analogy, if the task is to carry a gallon of water 100 meters, it could be put in a car(expensive, but fast) and cover the distance pretty quickly. If the water must be converted to steam and then back to water, it will take much longer, and the car will not help with delivering it.
* Engineer retention: Engineers who work on simple software run into less frustrating walls. This is more fulfilling work, and will keep engineers on the team. Engineers are less likely to take ownership of problems and code if it is part of a complex mess.
## Software Engineers Program, but Programmers do not Engineer ## Software Engineers Program, but Programmers do not Engineer
A programmer understands software languages and can program a computer to accomplish tasks. A software engineer will do the same, with the addition of minimizing the program's complexity. In fact the act of minimizing the complexity may take up almost all the time of a software engineer. Many other tasks such as designing, testing, documenting, refactoring, and code reviews are much more time intensive -- and important -- than the actual programming. A programmer understands software languages and can program a computer to accomplish tasks. A software engineer will do the same, with the addition of minimizing the program's complexity. In fact the act of minimizing the complexity takes up most of the engineer's time. Many other tasks such as designing, testing, documenting, refactoring, and code reviews are much more time intensive -- and important -- than the actual programming.
Software engineers must create programs that are simple enough to be understood by other engineers. This enables others to work on the project and create something greater than the sum of the engineers' abilities. Software engineers must create programs that are simple enough to be understood by other engineers. This enables others to work on the project and create something greater than the sum of the engineers' abilities.
## Simple is Difficult, but Effective ## Simple is Difficult, but Effective
[An antonym of complexity is simplicity.](https://www.thesaurus.com/browse/complexity) Although it is easy to express what a [simple system](https://simplesystems.tech/blog/post/simplicity) is, it is not easy to create one. Simplicity is so effective in software that many books and blogs are written on the topic. A few examples of simplifying principles: [An antonym of complexity is simplicity.](https://www.thesaurus.com/browse/complexity) Although it is easy to explain a [simple system](https://simplesystems.tech/blog/post/simplicity), it is not easy to create one. This is the classic investment mindset applied to time. It is better to think twice and code once. A few examples of simplifying principles:
* Encapsulation: This is a very powerful idea, especially when some complexity cannot be mitigated -- it can still be encapsulated. * Encapsulation: This is a very powerful idea, especially when some complexity cannot be mitigated -- it can still be encapsulated.
* UNIX philosophy: "Make each program do one thing well." This can save software from becoming an indomitable mess. Constantly adding features to the same system will eventually make it collapse in on itself. * UNIX philosophy: "Make each program do one thing well." This can save software from becoming an indomitable mess. Constantly adding features to the same system will eventually make it collapse in on itself.
* Composition: Software should be composed of interchangeable modules. The boundaries between modules must be well-defined. * Composition: Software should be composed of interchangeable modules. The boundaries between modules must be well-defined.
None of these principles are easy to incorporate into an engineering process. There is both a science and art aspect of designing and building something in a simple manner. Once a system becomes simple, the benefits are exponential. One important benefit for teams to think about is number of engineers who can work on a project. If a system becomes an interconnected mess, usually only 1 or 2 people can work on it simultaneously. If a system is well designed, especially using modularity, the number of engineers who can work on it simultaneously is practically unlimited, because each module is independent. None of these principles are easy to incorporate into an engineering process. There is both a science and art aspect of designing and building something in a simple manner. Once a system becomes simple, the benefits are exponential. One important benefit for teams to think about is number of engineers who can work on a project. If a system becomes an interconnected mess, usually only 1 or 2 people can work on it simultaneously. If a system is well designed, especially using modularity, the number of engineers who can work on it simultaneously is practically unlimited, because each module is independent.
##### ? Monero provides a simple interface, but it was not easy to create. There is a lot going on behind the scenes. ##### ? Monero provides a simple interface, but it was not easy to create. There is a lot going on behind the scenes.
##### Reference Rob Pike's comments on GC (The simplest interface is none at all) https://www.youtube.com/watch?v=rFejpH_tAHM ##### Reference Rob Pike's comments on GC (The simplest interface is none at all) https://www.youtube.com/watch?v=rFejpH_tAHM
##### MVCC ? Maybe a complex topic for a post on reducing complexity
##### ? design patterns ##### ? design patterns
##### Simplicity is so effective in software that many books and blogs are written on the topic.