Re: OOD Question
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 05/24/04
- Next message: point: "Share objects"
- Previous message: Ignacio Machin \( .NET/ C# MVP \): "Re: OOD Question"
- In reply to: Alok Jain: "OOD Question"
- Next in thread: Alok Jain: "Re: OOD Question"
- Reply: Alok Jain: "Re: OOD Question"
- Messages sorted by: [ date ] [ thread ]
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
>
>
- Next message: point: "Share objects"
- Previous message: Ignacio Machin \( .NET/ C# MVP \): "Re: OOD Question"
- In reply to: Alok Jain: "OOD Question"
- Next in thread: Alok Jain: "Re: OOD Question"
- Reply: Alok Jain: "Re: OOD Question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|