Object design question (two, actually)

From: Roger Bonine (RogerBonine_at_discussions.microsoft.com)
Date: 12/15/04


Date: Wed, 15 Dec 2004 08:27:04 -0800

I'm working on a rewrite of our employee database. I plan to implement a
fairly heavyweight base class, which includes 20 or 30 fields, including
address and phone number collections and the like. (I'll use lazy init to
fill the collections when needed.) More specialized employee types would
inherit from the base class.

Sometimes, though, all I need is the employee name and ID number - for
example, when filling a DDL - and I hate to have all the overhead of creating
a heavyweight class object every time I want to look up an employee name by
ID. My question is: what's the best practice for doing very small lookups
like this? Should I create a small helper class, or use a lookup method in
the full class and just live with the overhead?

Along the same lines, I want to have an overloaded method that returns
various lists of employees (by role, active/inactive, etc). Do most people
feel that it breaks abstraction to have a method that returns multiple rows
in an object that represents a single entity? If so, where would a method
such as this live in the object hierarchy? I don't want to have to create
several classes for each separate type of object, but I want to do this the
right way.

Any thoughts would be appreciated..



Relevant Pages

  • RE: Protected keyword
    ... Only the Employee class internally can see the base class RaiseEvent method. ... public void HoldBreath{ ... a child that inherits from it so as to be able to call the protected method ...
    (microsoft.public.dotnet.languages.csharp)
  • Lazy Load base types w/ EF Table Per Type?
    ... "Employee" and Employee inherits from Person, ... base class, it went back to the database to retrieve those properties. ... inspecting the properties via the VS Debugger - that is, ... the lazy load or not perform the lazy load. ...
    (microsoft.public.dotnet.languages.csharp)
  • Issues Serializing A Derived Class and its Base using IXmlSerializable, Cant See Base
    ... I am having issue with serializing a class and its base class using ... I am using System.Xml.Serialization I to serialize a class. ... There exists a class called Employee ... void IXmlSerializable.WriteXml ...
    (microsoft.public.dotnet.xml)
  • Issues Serializing A Derived Class and its Base using IXmlSerializable, Cant See Base
    ... I am having issue with serializing a class and its base class using ... I am using System.Xml.Serialization I to serialize a class. ... There exists a class called Employee ... void IXmlSerializable.WriteXml ...
    (microsoft.public.dotnet.general)
  • Re: Object design question (two, actually)
    ... > By instantiate the full object, do you mean do a full Get, or just have ... I thought you said "look up an employee", ... >> Employees where the criteria aren't held in the base class. ... > member variables for the properties. ...
    (microsoft.public.dotnet.general)