Re: What's the Criteria for Promoting a "Thing" to a Class
- From: frebe73@xxxxxxxxx
- Date: 30 Dec 2006 23:08:43 -0800
I'm an OOAD noob, and I'm thinking that "State" (as in the "S" of the
U.S.A.) qualifies as a class, and should be represented as a Class in
my Class Diagram, with its two properties: name and abbreviation.
Similarly, I think that any type of lookup (in DB ERD terms) should be
modeled as a Class in the class diagram.
Mapping relations (tables) to classes are generally not a good idea. If
you are using a RDBMS, relations/tables are the only data structure
that should be used. Classes may be used for defining data types, but
not for data structures.
If you don't have a RDBMS availible, classes might be used as data
structures in lack of better options. Using classes as a data structure
is pretty similar to records and pointers in a network database. This
is obviously a valid approach - after all many sucessful applications
was made in the 60s and 70s using network databases - but today more
powerful tools exists.
My colleague is of the opposite opinion, and thinks that there
shouldn't be classes for these "lookups." I'm not sufficiently
following her logic well enough to represent her viewpoint, but here's
a thread:
her: to me [State] would just be an element of the "conference" class.
me: an element of what type?
her: ah
her: let me think on that for a minute
her: a record type
her: a generic reference table type that has a code and description
her: so, for example, we'll have something similar for ethnicity, i'm
guessing
her: a code and description
her: i wouldn't see an ethnicity class - i would just see that as an
element of target population
her: and it's type would also be the generic record class
me: sounds weird to me, but i'm not enough of an OOAD guru to be
confident of my "weirdness" determination
If the class definitions of State and ethnicity would be exactly the
same, a generic class would obviously be a valid alternative. If there
are only minor differences, subclassing could be an option.
You can't compare a class to a table in a database, because a table is
not only a data structure definition, but also a data container. A
class is not a data container. You need to put you class instances
somewhere tool. That is why you might need different tables, but not
different class definitions.
Fredrik Bertilsson
http://frebe.php0h.com
.
- References:
- What's the Criteria for Promoting a "Thing" to a Class
- From: mySpamB8
- What's the Criteria for Promoting a "Thing" to a Class
- Prev by Date: Re: double-entry bookkeeping unneeded?
- Next by Date: Critique of Robert C. Martin's "Agile Principles, Patterns, and Practices"
- Previous by thread: Re: What's the Criteria for Promoting a "Thing" to a Class
- Next by thread: Modeling User/Accounts
- Index(es):