Re: How should a container class "know" its contained objects?



I've done some more digging and found a couple other nuggets out
there, mostly from Martin.

Here's one:

"We [should] create objects of the things that have behavior, not the
things that carry data.."

This makes sense to me on a bunch of different angles.

But, then, where does that leave the modeling of the data? Does the
data not deserve some representation in our application?

The obvious answer is "yes", that data needs to be modeled in some
way. For example, for some apps, a relational database model (and the
associated classes around the database tables and entities) suffice to
model the data, store it, and enforce business rules around it.

But in my case, we have lots of "weird" data entities in our domain
model that really don't fit well in a database.

So how am I to represent this data, enforce validation and
relationship rules for it, etc, except by creating classes to do so?

Michael
.