Re: Confusion With Inheritance
- From: Robert C. Martin <unclebob@xxxxxxxxxxxxxxxx>
- Date: Sat, 27 Aug 2005 12:01:02 -0500
On Thu, 25 Aug 2005 17:39:42 GMT, "H. S. Lahman"
<h.lahman@xxxxxxxxxxx> wrote:
>Responding to Martin...
>
>> Notice that when you described your classes, you described them in
>> terms of the data that they held, and not in terms of the behavior
>> that they exhibited. This is the first, and most serious, problem
>> with your example. Object Oriented Design is a discipline for
>> partitioning *behavior*, and *incidentally* the data that goes with
>> that behavior.
>
>We disagree Big Time on this one.
Actually, I doubt that we do. From the outside an object is nothing
but a bundle of behaviors. We might infer that there is some data
inside the object, but we can't be clear on exactly what data that is,
what form it takes, and where that data is actually located.
Some of the behaviors of an object present data at the interface.
Those behaviors might just be simple accessors, or they might be much
more complex operations that just appear to be simple accessors.
This view decouples the data itself from the behaviors. When we look
at an object, we know what it *does*, but we don't exactly know where
it does it.
>Knowledge and behavior responsibilities have always been given equal
>stature in OO development.
In relation to procedural development there was a definite shift.
Data was made private, and behaviors were grouped into scopes
(classes).
In any class, the behavior is public but the data is private. I'm not
talking about C++ keywords here, I'm talking about the general
principles. Data is hidden and behavior is exposed. This is almost
precisely the opposite of a data model in which data is exposed and
behavior is absent.
I'll grant you that data is *part* of OO development, but from a
stature point of view, data is the black sheep ugly child that is
hidden away into a closet when company comes over.
>One abstracts the /intrinsic/ properties of
>problem space /entities/. The proportions of knowledge vs. behavior or
>their relative importance to the solution is not relevant -- one
>abstracts and encapsulates the entity's bundle of relevant properties as
>the object.
Granted. This is why I think we don't disagree on this topic. The
data is not the motivation for creating object partitions. It is the
behavior of the object that defines its boundaries and the
partitioning strategy.
>Defining objects based primarily around behaviors rather than the whole
>entity is just a form of procedural functional decomposition.
Not at all. Functional decomposition is the breakdown of function
into a hierarchy. (e.g. a calling tree). Object oriented
partitioning is a breakdown of behavior into responsibilities that
have relationships with one another. That's a very different type of
decomposition.
>One ends
>up defining a function library that collects procedures into classes
>rather than abstracting the problem space.
Incorrect. Responsibility Driven Design (Wirfs-Brock) is one of the
oldest and best methods of partitioning the problem domain into
objects; and does not lead to a functional decomposition.
-----
Robert C. Martin (Uncle Bob) | email: unclebob@xxxxxxxxxxxxxxxx
Object Mentor Inc. | blog: www.butunclebob.com
The Agile Transition Experts | web: www.objectmentor.com
800-338-6716
"The aim of science is not to open the door to infinite wisdom,
but to set a limit to infinite error."
-- Bertolt Brecht, Life of Galileo
.
- Follow-Ups:
- Re: Confusion With Inheritance
- From: H. S. Lahman
- Re: Confusion With Inheritance
- References:
- Confusion With Inheritance
- From: Brad
- Re: Confusion With Inheritance
- From: Robert C . Martin
- Re: Confusion With Inheritance
- From: H. S. Lahman
- Confusion With Inheritance
- Prev by Date: Re: XP and Pair Programming
- Next by Date: Re: Confusion With Inheritance
- Previous by thread: Re: Confusion With Inheritance
- Next by thread: Re: Confusion With Inheritance
- Index(es):
Relevant Pages
|