Rick Kitts
Posts: 48
Nickname: rkitts
Registered: Jan, 2003
|
|
Re: Oh No! DTO!
|
Posted: Feb 27, 2004 6:43 AM
|
|
I tend to think this argument is naive. Every place that you do class.member = 23 is surrounded by a context. An implicit definition of a set of acceptable values. While these may feel unconstrained and "obvious" today, all non-trivial systems end up getting bent in directions not originally envisioned or anticipated.
With a tight schedule and a change in the set of acceptable values for a member, developers are faced with a choice of rooting out all assignments to member and addressing the changing set (usually caused by a local only relevant context like "Oh, this time I'm using this DTO as part of an XYZ structure, member means this") by creating a setter or doing an in place if. What do you think they'll do? What have you <b>seen</b> them do. This will probably happen more than once in the lifetime of the code base. Probably lot's of times. Kruft accumulates. It happens. Seems to happen always.
If you argue that the the DTO should only have it's members set in one place then guess what, it's a setter. Put it on the DTO. Why not?
These rules are not created for people who write blogs and think passionately about the craft of development. They're created for the majority of developers. Well intentioned perhaps, reasonably intelligent, but in the end it's still just a job to them. Do it well sure, but the day ends and you go home and think about other things. Everything that is advised has to be advised with these people in mind. These are the consumers of design processes and guidelines. Not the people who actually care about them. Look, there's a reason for GUIs. Same rationale applies to this.
Finally any argument that has as it's premise or supports itself with developer convenience is, I belive, instantly suspect. You know what's inconvenient for me? Flood insurance. Gotta have it. It's the law. There hasn't been a flood here in like 100 years. But(!), there will be eventually. When there is the city recognizes it's simply better for me and my fellow citizens for me to have the insurance and not bog the city down with law suits, or wrecked houses I can't afford to build, or for them to have to show up at my door and throw me out because the house isn't safe.
|
|