Entity-Relationship Diagrams and OO

Source: comp.object
Date: 22-Dec-99

Related Sites


o-< Problem: Are object models any different from ER models? Can old ER dogs learn new OO tricks?


o-< Nilesh Shah wrote:

[...] Whenever I try to draw class diagram I end up drawing Entity relationship diagram. [...]


o-< Michael C. Feathers explained what is different in OO:

One of the deepest truths about object orientation is the fact that objects are about behavior rather than data.

It is very unfortunate that it is hard for people who come from a data modeling background to really grok this part of OO.

As an example, consider dates. A data modeler could model a date as a value object which holds month, day, and year. You can use such objects all over your application and never get to some of the higher behavioral abstractions which make OO so useful.

For instance, if you look at how dates are used, you may discover that it makes more sense to have a timeperiod object (after all, a date consists of 24 hours, it is a period) which has an "includes" method that you can use to determine whether one timeperiod falls into another.

The first thing that I would recommend is that you start to pay more attention to the "behaviorists" in OO: Booch, Robert Martin, Rebecca Wirfs-Brock, since you know that you see things as data right now.

Also, read about CRC cards and start to use them rather than UML for a while. You are much less likely to end up with a data driven design this way.


o-< Richard J. Botting pointed out how data and behavior are both necessary for OO modeling:

When you focus and draw entities and relationships say your studying the "static structure". When you are working with sets of responsibilities and looking for similar behaviors --- then you are doing the "dynamic structure".

They are both necessary, and each helps the other. For example one "GRASP" pattern is to assign a responsibility to the "Expert": assign the function to the entity that holds the data. This works if you have an ER on hand with attributes.

To stretch in the direction of dynamics, as an exercise you could take some non-risky and simple projects/problems and try doing CRC on it. Or Coad's colored post-it note technique.


o-< More Info:

Alistair Cockburn, An Open Letter to Object Technology Newcomers
[Discusses (among other things) the differences and similarities between data models and the structural part of object models.]

CRC Cards

Rebecca Wirfs-Brock, Brian Wilkerson, Lauren Wiener, Designing Object-Oriented Software

Robert C. Martin, Designing Object Oriented C++ Applications Using UML

Grady Booch, Ivar Jacobson, James Rumbaugh, The Unified Modeling Language User Guide

Craig Larman, Applying UML and Patterns
[Includes General Responsibility Assignment Software Patterns (GRASP)]

Peter Coad, Eric Lefebvre, Jeff De Luca, Java Modeling In Color With UML