in reply to Whip Me, Beat Me, Make Me Use ORMs

The biggest problem with ORMs is the same problem I see with OO frameworks that generate public accessors for member variables.

Accessors for member variables turn objects into glorified structs. When you design an object's interface, it really should be in terms of messages, not in terms of what guts the object contains.

SImilarly, ORMs map each column into the interface, instead of mapping the interface from the use cases. Surely, you could create "actual" objects that encapsulate that, but I don't see that happening very often (even in my own code).

What happens when the DBA decides that street address should actually be two fields: street number plus street name? We now have to ripple that through all the code, because all the code was talking directly to the street address text field before. Sure, we can do some wrappers and things, but a proper OO design would have minimized the locality of that knowledge. ORMs don't encourage that design.

Replies are listed 'Best First'.
Re^2: Whip Me, Beat Me, Make Me Use ORMs
by Ovid (Cardinal) on Jun 29, 2007 at 15:28 UTC

    I'm actually working on actual objects which encapsulate that, but I made the mistake of inheriting instead of delegating, thus exposing too much. I have a robust enough test suite that the refactoring should be easy, but I'm kicking myself for being so stupid.

    Of course, if one has a poorly designed database, making this distinction is even more important.

    Cheers,
    Ovid

    New address of my CGI Course.