Re: OOD Question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 05/24/04


Date: Mon, 24 May 2004 10:13:13 -0400

Alok,

    The approach I would take is to use attributes. It would seem that the
details that you get are stored in fields of your database which are
type-specific. For example, your work order task might have the work order
id that it needs to get.

    In this case, you can do two things. You could have the base class
define virtual methods which the derived classes would provide
implementations for which would give information about how to alter the
query being made (additional fields, joins, etc, etc). However, since each
instance of the derived classes will give the same information, you don't
need to have this on an instance level. I would recommend using attributes
instead. You could create custom attributes which your derived classes
would place on themselves. These attributes would give the same information
about which fields to select, join on, etc, etc, that you would need to form
your query.

    Hope this helps.

-- 
               - Nicholas Paldino [.NET/C# MVP]
               - mvp@spam.guard.caspershouse.com
"Alok Jain" <alokj@renewal-iis.com> wrote in message
news:%23892HIZQEHA.1892@TK2MSFTNGP09.phx.gbl...
> This is a design / inheritance qus.
> I have class Task.
> This is a base class for some specific tasks
>
> Say
> WorkOrderTask : Task
> TimeSheetTask : Task
>
> Now   Task has a function GetDetails() which gets all info about task.
This
> makes a database call.
>
> I override this in the derived class. For implementing this in  derived
> class i see following 2 approaches.
>
>
> Approach 1. WorkOrderTask .GetDetails()
>    {
>         Calls base.GetDetails(); to get base details, populates in the
> object
>         Gets details specific to WorkOrderTask, populates in the object
>         returns;
>     }
>
>
>
> Approach 2. WorkOrderTask .GetDetails()
>    {
>         Get details specific to WorkOrderTask as well as the base class
> details, populates in the object
>         returns;
>     }
>
>
> The problem with
>
> Approach 1
> I have to make 2 database calls.
>
> Approach 2
> If theres some change in base class I need to take care of these in all
the
> derived classes as well.
> Whereas, Approach 1 is advantageous here as by modifying only the
> Task.GetDetails funciton ( this is the base class ) function i have all
the
> values and i do not need to touch the derived classes.
>
>
>
> Was thinking this might be a very common problem, so perhaps many of might
> be able to guide me on the approach i must take here. Perhaps anything
other
> then the two i have talked about.
>
> Thanks in advance
> Sourabh
>
>


Relevant Pages

  • Architecture: Scalability VS Performance
    ... WorkOrderTask: Task ... I have to make 2 database calls. ... If theres some change in base class I need to take care of these in all the ... values and i do not need to touch the derived classes. ...
    (microsoft.public.dotnet.framework)
  • OOAD: Scalability VS Performance
    ... WorkOrderTask: Task ... I have to make 2 database calls. ... If theres some change in base class I need to take care of these in all the ... values and i do not need to touch the derived classes. ...
    (microsoft.public.dotnet.framework.performance)
  • OOD Question
    ... WorkOrderTask: Task ... I have to make 2 database calls. ... If theres some change in base class I need to take care of these in all the ... values and i do not need to touch the derived classes. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Not pure virtual functions and mixing virtual and non virtual methods
    ... Should I call base class implementation or not? ... But doing the above assumes that one answer is good for all, that all derived classes will want the base class method called in the same way. ... More generally, the way I see it, if you combine invariant implementation with variant parts, you have no elegant way to change the variant part. ... Following them will remove all inheritance relationships. ...
    (comp.object)
  • This one took weeks to resolve
    ... would be better designed as deriving from a base class form. ... control in the Windows generated code. ... These derived classes where the only place in a project ... Private sub Btn_ClickHandles btn.click ...
    (microsoft.public.dotnet.languages.vb)