Most of us developers think we're smart. But we aren't smart. We're clever.
You can easily prove this by looking at our code. Specifically, by answering these questions:
- How many layers of indirection are there?
- How many abstractions of abstractions are there?
- How many different things are our methods doing?
Combined, these reveal how complicated a set of code is.
What we do as developers is complex. There are lots of little moving parts that all need to work together.
Complex: composed of many interconnected parts; compound; composite1
Complicated: difficult to analyze, understand, explain, etc.2
Because we're clever, we think we understand how to manage this complexity. But we don't. We're confused by it. So, instead of making the complex clear, we complicate it. We add stuff that makes those moving parts harder to understand (over-use of indirection and abstraction), and harder to work together (method multi-responsibility).
No one likes to hear this or face it in themselves. But we face it too often when supporting others' code. It comes with that little, internal question, "Couldn't this be easier?"
So, what do we do?
First, decide that "we" applies to "you." It's better to start with this assumption because it leads to learning rather than avoidance. If I insist I'm smart, I won't make the effort to learn better--thus, not smart. But if I insist I can be better, no matter how good I am, then the path to improvement and away from stagnation opens long and wide.
Second, find examples of complex code that isn't complicated. Open source projects coming out of Microsoft and Google are good starting points.
Third, Read about and apply the principles behind uncomplicating code. Three of these are:
Finally, be guided by four overarching principles in your architecture and coding. Make your code...
We may not be smart, but be can code smarter.
Complex 1645–55; 1905–10 for def 7; (adj.) < Latin complexus, past participle of complectī, complectere to embrace, encompass, include, equivalent to complect- (see complect) + -tus past participle suffix; (noun) < Late Latin complexus totality, complex (Latin: inclusion, grasping, embrace), equivalent to complect(ere) + -tus suffix of v. action; reanalysis of the Latin v. as “to intertwine (completely)” has influenced sense of the adj.↩
Complicated 1615–25; < Latin complicātus (past participle of complicāre to fold together), equivalent to com- com- + -plic- (combining form of *plecāre to fold, akin to plectī to plait; see complex) + -ātus -ate1↩