Before delving into Design patterns, let us think architecture from resilience perspective.
At the application architecture level, I would recommend to focus on seperation of concenrs, that Data services layer should always do operations related to data.
For Design Patterns you have the answer from Rajesh, which is always within a specific layer.
From 3-tier perspective, you should have a layer to manage Caching, between business and data services layer.
That UI -> BSL-> Optionally (caching Layer)-> DB
Once the data is retrived by business layer, it may optionally can pass in to Caching layer, which will satisfy caching requirement.
Once Cached, then pass the data back to UI layer.
Hope this helps.
Tarriq Ferrose Khan, Nov 01, 2011
If you have the repository patterns at the DB layer then you can easily implement a cache repository and plugin via some IOC container or by poor man's dependency injection..
Basically its a combination of factory + strategy pattern. Factory to create instance and strategy to select the algorithm like getting from cache or Db.
You can also use variation of the above pattern as well.
In case your DB layer is not that flexible the quickest thing would be to introduce a caching facade service which interacts with the DB layer based on cache settings....
Rajesh Pillai, Oct 28, 2011
In real estate it is all about location, location, location. In coding, it is all about readability, readability, readability. So, the best practice for using 'var' is to avoid it when it is going to degrade readability. - Use it when the type is obvious. - Use it when knowing the type is useless and doesn't affect readability or understandability. For example, loops are a perfect place to use 'var'.
Apr 11, 2011