Re: How does one model behavior?

From: Phlip <>
Date: Thu, 10 Apr 2008 07:28:02 -0700
Message-ID: <StpLj.27094$KJ1.1039_at_newsfe19.lga>

David Cressey wrote:

>> What's the worst thing that could happen if you get this data model >> "wrong" before you write the code?

> It's a good question. I'm going to defer to people who have written a lot
> of OO code. I hope they will answer.

Allow me: Nothing.

Firstly, the state variables in the messages sent between objects are, by definition, dynamic and transient. The data in a database is static and persistent. When OO objects share database records in their messages, the records participate in this transient. As a program grows in versions, it's natural for OO objects to change more often than database, but...

> I've seen what can go wrong, several times, where people have started with
> the "wrong" data model and have built a database. There are various flavors
> of "wrong" and various kinds of unfortunate consequences. If I had to
> summarize, at the expense of over simplifying, I would say that the data in
> the database will be less useful and more costly than it otherwise would
> have been.

These people did not make a (modest) investment in making sure they could change their database over time. Look up "Rails ActiveRecord migrations" for a good example how to do this.

> But it may be that the pitfalls in writing code and the pitfalls in building
> a database are quite different. So I look forward to reading what
> programmers have to say about this.

Write unit tests for everything you do, including the migrations, and pass them after every few edits. These techniques make the cost of a bad database negligible, if you can improve it over time, in response to new feature requests.

Received on Thu Apr 10 2008 - 16:28:02 CEST

Original text of this message