For Programmers: Free Programming Magazines  


Home > Archive > Software Engineering > October 2007 > Data objects considered harmful (was: Philosophy and Formal Methods)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Data objects considered harmful (was: Philosophy and Formal Methods)
bill turner

2007-10-30, 10:08 pm

On Wed, 03 Oct 2007 17:01:22 -0700, topmind <topmind@technologist.com>
wrote:

>On Oct 3, 11:07 am, Phlip <phlip2...@gmail.com> wrote:
>
>Trying to start something yet again? I did not saying any derogatory
>about you here. Hey, where's the Grand Proof That OOP Is Better, by
>the way? Dog ate it?
>
>
>-T-


You know, one thing has always bugged me about OOP, as practiced
anyway. When OOP was first all the rage, everyone spoke of how OOP
encapsulates data and methods so well. Also, everyone spoke of
eliminating global variables. Well, it seems with the widespread use
of data objects, you don't really get either. So what if you use
methods to get and set? Rarely are the data objects coded in any
restrictive way. Give me a string and I'll hold, who cares if it makes
any sense. And, with setters generally public, any other object can
just as easily set it as well. So, other than having a data structure
that could technically include some validation logic, it seems that
there is no benefit here. I guess the reason for data objects is to
reduce the coupling between business logic and
database/file/communication/etc. logic. Should data objects be
considered harmful?

bill
------------------------------------------
Bill Turner

A faith that the free play of market forces will eventually end in Good is, in fact, more 'absurd' than religious belief, for there, at least, there is a presumption of an intelligent Agent Who writes straight with His crooked lines. - William Pfaff


Views expressed are entirely my own and only coincidentally represent those of other persons or entities.
Phlip

2007-10-31, 7:12 pm

bill turner wrote:

> You know, one thing has always bugged me about OOP, as practiced
> anyway. When OOP was first all the rage, everyone spoke of how OOP
> encapsulates data and methods so well. Also, everyone spoke of
> eliminating global variables. Well, it seems with the widespread use
> of data objects, you don't really get either. So what if you use
> methods to get and set?


Then you need to refactor your design to not use get and set. Waving the OOP
wand won't make them go away; you still need to figure out the right
interfaces for objects.

> Should data objects be considered harmful?


How's your duplication? How often do clients of your naked objects repeat
the same code before and after getting and setting their strings?

--
Phlip


bill turner

2007-10-31, 10:08 pm

On Wed, 31 Oct 2007 05:49:03 -0700, "Phlip" <phlipcpp@yahoo.com>
wrote:

>bill turner wrote:
>
>
>Then you need to refactor your design to not use get and set. Waving the OOP
>wand won't make them go away; you still need to figure out the right
>interfaces for objects.


That's the point, Phlip. Getters and setters don't really hide
anything, nor do DataObjects, at least how I've seen them in practice
and seems recommended in design patterns and many examples,
encapsulate data with functionality. In fact, they do quite the
reverse. They separate the two. So, I agree with you. But, it is not
the state of practice. Look up DAO pattern, for example, and you'll
see a very explicit use of DataObject which separates the business
logic from the data. Therefore, I feel that DataObjects are really
nothing more than global variables in disguise.
>
>
>How's your duplication? How often do clients of your naked objects repeat
>the same code before and after getting and setting their strings?


I am speaking in the abstract, here, rather than my practices
specifically. I am referring to code samples I've found repeatedly on
the web, samples of pattern usage, etc. It has always struck me that
DataObjects were antithetical to the theory behind OOP.

In practice, I've never really had problems with them. They just don't
feel right to me. I dunno, maybe I am just rambling on for no apparent
reason. :-)

bill

------------------------------------------
Bill Turner

A faith that the free play of market forces will eventually end in Good is, in fact, more 'absurd' than religious belief, for there, at least, there is a presumption of an intelligent Agent Who writes straight with His crooked lines. - William Pfaff


Views expressed are entirely my own and only coincidentally represent those of other persons or entities.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com