This is the basic problem. Say I have a base class Foo. This class does a call to the database to get some data to cache in the class.
public class Foo
{
// Properties/fields go here.
public virtual void ReadData()
{
// Queries the database for information and stores it in Foo.
}
}
Now, say I have a derived class called Bar. This class wants to cache some additional data.
public class Bar : Foo
{
// Additional properties/fields go here.
public override void ReadData()
{
base.ReadData();
// Queries the database for additional information and stores it in Bar.
}
}
Now, looking at this, it seems like a somewhat common thing to do if you were doing regular OOP. But, in this case, you are accessing the database twice which is inefficient. I'm working on a legacy codebase that does practices like this all over the place. In the next release, they want database access optimization (meaning, less calls to the DB).