Applications remain simple in the absence of god code – level 100

Imagine two scenarios: 

  • You build a system where one class is responsible for coordinating actions of many.  This one class may observe many conditions or events and act appropriately.
  • Each small event or condition is encapsulated by an object.  You have many classes, but the responsibility of each class is small.  No one class has too much to do.

I call the first scenario “god code”.  This code rules from on high.  This code might have to track multiple conditions in class or global variables to keep track of what is going on.  This code is very busy all the time and has its hand in everything. 

god code leads to overly complex applications.  A remedy for god code is to push behavior down into the smaller classes being worked on.  Empower the smaller classes to take some responsibility for themselves.  They are quite capable.