torsdag den 24. maj 2012

Data and a box of matches

The way we think IT is both inspired and explained from our normal daily life.

You may perhaps still remember that inheritance in OOP is introduced in most of the books by an association with 'genetic' inheritance in the animal world, polymorphism with transportation by vehicles operated differently, etc.

A common pattern you often encounter is to retrieve some data. The retrieved data is used for ongoing lookup tasks, normally based on an input key.
At a conceptual level there are perhaps two ways to accomplish it :

  1. Access the underlying data each time the lookup operation is needed: directly or in a SOA like manner by calling the service layer on top of your data.
  2. Retrieve and cache all your lookup data in a hashtable data structure. If you are dealing with 'slow changing' data, the latency and refreshing policies are acceptable, then this might be your choice. You will gain a better performance, reduce locking and even cost of usage if your data provider charges your 'data trip' as perhaps is the case for your mainframe platform.
According to my experience option 1 is mostly used and often abused.

But what do you do every time you turn your gas oven on ?
 
  1. You rush to the grocery store and buy exactly one match. Then 'same procedure as....'  
  2. You already have a box of matches in your kitchen and just pick up a match out of it. No trip, no extra cost.
 Does this 'parallel' make any sense and can you give it a thought ?