Jeffrey Palermo (.com)

Sponsors

The Lounge

Wicked Cool Jobs

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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. 


Posted Sat, Oct 14 2006 12:28 AM by Jeffrey Palermo

[Advertisement]

Comments

dp wrote re: Applications remain simple in the absence of god code - level 100
on Mon, Oct 16 2006 11:06 AM
Well said J. I worked on a project recently which served the purpose of being a State Engine for an application. Instead of creating a Mondo State Engine class, with every state and all it's complexities within, the Engine was simply a broker/manager of individual state classes, each with it's own behavior. Much more manageable.
Vikas Kerni wrote re: Applications remain simple in the absence of god code - level 100
on Fri, Nov 3 2006 6:02 PM
How one can distinguish between God Code and AOP/Metadata driven/complex configuration driven code ? Microsoft heavy use of attributes in .Net Framework shows the strength of these techniques. How can one determine if he is making effective use of these techniques or over-engineering?
Devlicio.us