Re: Scalability VS Performance

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: David Browne (meat_at_hotmail.com)
Date: 05/25/04


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



Relevant Pages

  • Re: OOD Question
    ... your work order task might have the work order ... instance of the derived classes will give the same information, ... > makes a database call. ... > If theres some change in base class I need to take care of these in all the> derived classes as well. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Scrubbing MySQL Values and CSVtoArray()
    ... Sanders Kaufman wrote: ... then a base class that does the business logic. ... the mysql-specific scrubbing function in the business logic base class - ... it defeats the purpose of putting ALL of the database work in database.php. ...
    (comp.lang.php)
  • Re: Using a Resource as a Class Property
    ... I'm aggragating the database object into a base class, ... other classes that "extend" that base class. ... But if you want to overwrite some methods to ...
    (comp.lang.php)
  • Re: Strongly typed DataSets: Relation between DataTable and TableAdapter
    ... Assuming I create a generic base base class like ... Public MustInherit Class MyBusinessObjectBaseClass(Of TDataRow As DataRow) ... update the database records in the base class. ... Is there a way to get the DataTable a TableAdapter 'belongs' to by code? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Scalability VS Performance
    ... > This is a common problem, but it's really a database problem more than ... Above solves the problem of referencing the base class specific ... database fields in the derived class and this is also one ... the database call in derived (WorkOrderTask) class, what we will do with the ...
    (microsoft.public.dotnet.framework.performance)