[thelist] OOD question

Matt Warden mwarden at gmail.com
Thu Oct 7 16:16:49 CDT 2004


On Thu, 7 Oct 2004 16:03:46 -0400, David Mitchell <dave at dbmdata.com> wrote:
> Yes, it is sorta fishy from an OO standpoint. A class should subclass
> another one when the objects are related and you want to extend the
> functionality of the base class.

Well, I think that's probably exactly what it's doing in this case. A
User object is probably a specific case of an "data access" object,
the data of which is based on the database, and which needs to
interact with the database with various operations (insert, update,
delete, and select (to populate data members)).

Scott asked about the utility design pattern, where there would be a
DataAccess object as a data member of User. Again, it depends on what
DataAccess actually is, but this probably won't work. All its
operations would be specific to a given table (e.g., the user table)
with a certain structure and a given class with a certain set of data
members.

Because of this, these general operations (methods/functions) need to
be overridden. In other words, the interface of the object is the same
(i.e., the exposed methods and their signatures) but the
implementation of the operations will differ. Additionally, there may
be operations specific to a User which to not apply to DataAccess.

If this is the case, it is correctly using inheritance.


-- 
Matt Warden
Miami University
Oxford, OH
http://mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the thelist mailing list