Re: Scalability VS Performance
From: David Browne (meat_at_hotmail.com)
Date: 05/25/04
- Next message: Stu Smith: "Re: garbage collection experience?"
- Previous message: Alok Jain: "Re: Scalability VS Performance"
- In reply to: Alok Jain: "Re: Scalability VS Performance"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 25 May 2004 09:14:24 -0500
"Alok Jain" <alokj@renewal-iis.com> wrote in message
news:%23g6kJDjQEHA.1392@TK2MSFTNGP09.phx.gbl...
> > This is a common problem, but it's really a database problem more than
>
> > an OO problem. From the OO point of view you use Approach 1, period.
>
> > A common approach here is to have a separate data source for each
>
> > subclass you support. So a Task instance is populated by "select *
>
> > from task", and WorkOrderTask is populated by "select * from
>
> > WorkOrderTask". Where WorkOrderTask is a view which joins the main
>
> > task table to the table containing the additional columns for
>
> > WorkOrderTask.
>
> Above solves the problem of referencing the base class (Task) specific
> database fields in the derived (WorkOrderTask) class and this is also one
> database call. But there is one more issue, now when we have the results
of
> the database call in derived (WorkOrderTask) class, what we will do with
the
> values which are specific to the base class? If we write code in the
derived
> class to set the base class attributes then this will break the
> encapsulation for base class and this also enforces a high dependency on
the
> base class, whenever any base class member changes . Derived class will
also
> require changes (not a good approach).
>
> In this scenario we can write a method in the base class
> (setAttributes(DataReader dr) which can set its attributes. What you
suggest
> here?
Absolutely. The derived class will call the base class's method to set its
attributes, passing it a generic data container of some type. Like this
class Task
{
. . .
protected virtual setAttributes(DataRow r)
{
//set instance fields from DataRow
}
}
class WorkOrderTask
{
. . .
protected virtual setAttributes(DataRow r)
{
//set instance fields from DataRow
//invoke the superclass's setValues
super.setValues(r);
}
}
David
- Next message: Stu Smith: "Re: garbage collection experience?"
- Previous message: Alok Jain: "Re: Scalability VS Performance"
- In reply to: Alok Jain: "Re: Scalability VS Performance"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|