C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The Gist of Object Oriented Programming
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Roger Smythe
Guest





PostPosted: Mon Apr 19, 2004 5:48 am    Post subject: The Gist of Object Oriented Programming Reply with quote



A means for the progressive decomposition a problem space into increasingly simpler component parts
such that these component parts represent higher levels of conceptual abstraction, and are
completely independent of each other except for their well-defined interfaces.

This was an attempt to explain the gist of OOP to programmers accustomed to the
structured programming paradigm. I tried to explain OOP in terms of ideals that can
be striven for, even though these ideals may never be perfectly achieved in real systems.

Does anyone have any ideas on how to improve this explanation?
The goal is to provide the gist of the benefits of OOP to structured
programmers in no more than a single short paragraph.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Ian McCulloch
Guest





PostPosted: Mon Apr 19, 2004 9:51 pm    Post subject: Re: The Gist of Object Oriented Programming Reply with quote



Roger Smythe wrote:

Quote:
A means for the progressive decomposition a problem space into
increasingly simpler component parts such that these component parts
represent higher levels of conceptual abstraction, and are completely
independent of each other except for their well-defined interfaces.

This was an attempt to explain the gist of OOP to programmers accustomed
to the structured programming paradigm. I tried to explain OOP in terms of
ideals that can be striven for, even though these ideals may never be
perfectly achieved in real systems.

Does anyone have any ideas on how to improve this explanation?
The goal is to provide the gist of the benefits of OOP to structured
programmers in no more than a single short paragraph.

Does that imply a 'structured programming' style cannot have a well-defined
interface? Surely not, you could also be describing top-down design which
doesn't necessarily imply object orientation.

Not necessarily an improvement, but I have a different perspective on this:

Structured programming: 'code' and 'data' are completely separate entities,
the code is completely static in the sense that any change in program flow
is explicitly coded by the programmer as some test on the data that results
in two or more different paths through the code.

OO programming: introduces the notion of an 'object', which is a way of
packaging code and data together. Objects of a different type can be
substituted transparantly, as long as they satisfy the inferface (Liskov
substitution principle), in which case the code path may depend implicitly
on the actual type (which is really 'data').

Functional programming: code and data are essentially equivalent.

Pure OO (as taught in my undergraduate classes) is a mapping between objects
and real-life (or imagined) entities (Employee, ATM machine, Animal etc
etc). I've never found this approach useful in practice, perhaps because I
don't know how to apply it to my usual problem domain (computational
physics), maybe it is useful elsewhere.

Cheers,
Ian McCulloch



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
llewelly
Guest





PostPosted: Tue Apr 20, 2004 10:30 am    Post subject: Re: The Gist of Object Oriented Programming Reply with quote



"Roger Smythe" <Roger314159 (AT) hotmail (DOT) com> writes:

Quote:
A means for the progressive decomposition a problem space into increasingly simpler component parts
such that these component parts represent higher levels of conceptual abstraction, and are
completely independent of each other except for their well-defined
interfaces.

This definition seems equally true for structured programming. In
fact, it seems like a general definition for 'design method'.

Quote:

This was an attempt to explain the gist of OOP to programmers accustomed to the
structured programming paradigm. I tried to explain OOP in terms of ideals that can
be striven for, even though these ideals may never be perfectly achieved in real systems.

Does anyone have any ideas on how to improve this explanation?
The goal is to provide the gist of the benefits of OOP to structured
programmers in no more than a single short paragraph.
[snip]


The benefit of OO is OO-designed objects have behavior conceptually
similar to real-world entities, and OO-designed types have
behavior conceptually similar to real-world categories.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Francis Glassborow
Guest





PostPosted: Tue Apr 20, 2004 7:26 pm    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

In message <s8ygc.48267$K_.1098501 (AT) bgtnsc05-news (DOT) ops.worldnet.att.net>,
Roger Smythe <Roger314159 (AT) hotmail (DOT) com> writes
Quote:
A means for the progressive decomposition a problem space into
increasingly simpler component parts such that these component parts
represent higher levels of conceptual abstraction, and are completely
independent of each other except for their well-defined interfaces.

This was an attempt to explain the gist of OOP to programmers
accustomed to the structured programming paradigm. I tried to explain
OOP in terms of ideals that can be striven for, even though these ideals
may never be perfectly achieved in real systems.

Does anyone have any ideas on how to improve this explanation?
The goal is to provide the gist of the benefits of OOP to structured
programmers in no more than a single short paragraph.

Well to start with I would never have recognised OO from your first
paragraph. Try

Object orientation is a view of programming where the available behaviour is
strictly constrained by the type of the data. For example, if you have two
values that represent dates, subtracting one from the other will result in a
number of days, addition, multiplication and division are not only
meaningless but attempts to apply them to such values are diagnosed errors.

Of course I am definitely not happy with my paragraph because trying to
encapsulate such a major paradigm in a single paragraph requires skills that
I do not have.

--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit For project
ideas and contributions: http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Peter Olcott
Guest





PostPosted: Tue Apr 20, 2004 7:42 pm    Post subject: Re: The Gist of Object Oriented Programming Reply with quote


"Ian McCulloch" <nobody (AT) example (DOT) com> wrote

Quote:
Roger Smythe wrote:

A means for the progressive decomposition a problem space into
increasingly simpler component parts such that these component parts
represent higher levels of conceptual abstraction, and are
completely independent of each other except for their well-defined
interfaces.

This was an attempt to explain the gist of OOP to programmers
accustomed to the structured programming paradigm. I tried to
explain OOP in terms of ideals that can be striven for, even though
these ideals may never be perfectly achieved in real systems.

Does anyone have any ideas on how to improve this explanation?
The goal is to provide the gist of the benefits of OOP to structured
programmers in no more than a single short paragraph.

Does that imply a 'structured programming' style cannot have a
well-defined interface? Surely not, you could also be describing
top-down design which doesn't necessarily imply object orientation.

You have taken what I have said out of context, and thus provided a
different meaning than the one that I provided. The required context is

"such that these component parts are completely independent of each other
except for their well-defined interfaces"

In other words 100% complete encapsulation.

Quote:
Not necessarily an improvement, but I have a different perspective on
this:

Structured programming: 'code' and 'data' are completely separate
entities,
Yes this seems to be one of the primary distinctions.


Quote:
the code is completely static in the sense that any change in program
flow is explicitly coded by the programmer as some test on the data
that results in two or more different paths through the code.

OO programming: introduces the notion of an 'object', which is a way
of packaging code and data together. Objects of a different type can
be substituted transparantly, as long as they satisfy the inferface
(Liskov substitution principle), in which case the code path may
depend implicitly on the actual type (which is really 'data').

Yes this is the crucial difference. Now here is the hard part. Try to
accurately describe this difference, not, in how the difference works, but,
in terms the the quantity of benefits of this difference. In other words why
is this better?
and how much better is this than structured programming?

Quote:
Functional programming: code and data are essentially equivalent.

Pure OO (as taught in my undergraduate classes) is a mapping between
objects and real-life (or imagined) entities (Employee, ATM machine,
Animal etc etc). I've never found this approach useful in practice,
perhaps because I don't know how to apply it to my usual problem
domain (computational physics), maybe it is useful elsewhere.

Cheers,
Ian McCulloch



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Peter Olcott
Guest





PostPosted: Tue Apr 20, 2004 10:33 pm    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

Quote:
A means for the progressive decomposition a problem space into increasingly simpler component
parts
such that these component parts represent higher levels of conceptual abstraction, and are
completely independent of each other except for their well-defined
interfaces.

This definition seems equally true for structured programming. In
fact, it seems like a general definition for 'design method'.

Yet the structured paradigm does not have nearly the same
degree of encapsulation...

"such that these component parts are completely
independent of each other except for their well-defined
interfaces."

Quote:
The benefit of OO is OO-designed objects have behavior conceptually
similar to real-world entities, and OO-designed types have
behavior conceptually similar to real-world categories.

This is the kind of material that I was looking for. Because of the
capability to create user defined types, OOP can more closely
correspond to the real world. This makes systems much more
self-documenting, but, more importantly, provides these systems
with a fully elaborated design, this being the design of the real
world system that is being modeled.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
John G Harris
Guest





PostPosted: Wed Apr 21, 2004 12:14 am    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

In message <8665bvvrir.fsf (AT) Zorthluthik (DOT) local.bar>, llewelly
<llewelly.at (AT) xmission (DOT) dot.com> writes

<snip>
Quote:
The benefit of OO is OO-designed objects have behavior conceptually
similar to real-world entities, and OO-designed types have
behavior conceptually similar to real-world categories.

The idea that there is a mapping from things inside the computer to
things outside can be tricky to describe, and is sometimes misleading.

For instance, where in the real world do you find Sonic The Hedgehog and
Lara Croft? What exactly is a digital camera image, and where is it? Why
is OO so useful when doing BigInt arithmetic?

John
--
John Harris

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Antoun Kanawati
Guest





PostPosted: Wed Apr 21, 2004 12:29 am    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

llewelly wrote:

Quote:
"Roger Smythe" <Roger314159 (AT) hotmail (DOT) com> writes:

A means for the progressive decomposition a problem space into increasingly simpler component parts
such that these component parts represent higher levels of conceptual abstraction, and are
completely independent of each other except for their well-defined
interfaces.
[snip]
The benefit of OO is OO-designed objects have behavior conceptually
similar to real-world entities, and OO-designed types have
behavior conceptually similar to real-world categories.

I've always had an issue with Objects and The Real World.

Whether you're doing procedural or object-oriented programming, the
"Real World" is out, and all you have is some abstraction, which
[hopefully] captures the essence of the problem under consideration.

The primary characteristic of object oriented programming is
that it provides a notation for the classification of program
entities (classes), the specification of their interfaces (method
names, exposed variables), and the control of generalizations
and specializations. Different OO-languages provide different
supports for various aspects of specification. In Smalltalk,
you have no control over the interface, anyone can, post-facto,
add methods to a class. In C++, you have very fine control over
specialization points (virtual, non-virtual, pure-virtual, and
inheritance). Java's 'final' also allows some fine tuning.

All of the above is doable, and has been done, with procedural
frameworks (e.g.: the X[-windows] class system). Object oriented
languages formalize these approaches, solidify them and make them
more robust and usable.

In other words, OOP simplifies some aspects of expressing abstract
models in program designs and implementations, because it provides
notation that is better suited for this sort of work.

The conceptual similarities to "The Real World" cannot be avoided
no matter how you're programming. If they're not there, you're
doing the wrong thing. The expression of the concepts, which
affects the visibility of the similarities, is where object
oriented notations have an impact.

On a related note: lately, "Aspect Orientation" is picking up
steam because Object Orientation does not seem to capture the
real world just right.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Walt Karas
Guest





PostPosted: Wed Apr 21, 2004 9:15 am    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

I think the first thing you'd have to make clear is that
there is not a clear consensus as to what OO means. We
can only give our own point of view.

OO (I would say) originated in the idea of abstract
data types. Traditionally, a "type" had been thought
of as a way of representing a set of values in computer
memory (e.g. an "int" is represented as 32 binary
bits using 2's complement for negative values). But
an abstract data type was defined by a set of operations
that could be performed on a values of the type that
would result in other valid values of the type.
Algorigthms written to use abstract data types were
easier to understand, less error prone in that invalid
values were avoided, and more portable to different
architectures. In orthodox OO-speak, the abstraction
of data types is called "encapsulation".

Once you look at types as sets of operations, a
definition like "type B is type A plus operations X,
Y and Z" seems straight-forward. This is inheritance.
It saves alot of repetition in the definition of B.
It also makes it easy to define programming languages
where an algorithm written for values of type A also
works for type B.

The next step forward is a programming language where
you can express things like "type B is type A, execpt
A's operations U and V work differntly for B, and B
has the additional operations X, Y and Z". And as
long as the changed operations U and V are "conceptually"
the same, algorithms written for type A still work for
type B. This is called (for extreme want of a better
term) polymorphism.

It's now a small step to see the usefulness of data types
that are just sets of operations, with no associated
set of values. The only purpose of these data types is
to be inherited from by other data types. Such a data type
can be useful even if some or all of its operations have
only "conceptual" definitions, and require the inheriting
type to provide a compilable definition for the operation.
This idea expresses itself as abstract classes in C++,
and interfaces in Java.

Another swell thing is if you can write an algorithm for
some type T that uses operations X, Y and Z and relies
only on a "conceptual" definition of X, Y and Z. Then,
the algorithm works for any type having opearations
X, Y, and Z with the same conceptual definition. The
"type" (the set of operations X, Y and Z) become anonymous
and implicit. This is what C++ templates allow you to do.
Most people seem to feel that this goes beyond OO, and we
need to use the term "generic programming" for this
capability. It seems to me that SmallTalk also had this
capability because of its weak typing, and it was
considered to be covered by the term OO. But I've seen
it argued that SmallTalk programmers where never interested
in this concept (of writing algoritms that operate on ad-hoc
sets of operations, rather than base classes), so it shouldn't
be thought of as falling under OO.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Peter Olcott
Guest





PostPosted: Wed Apr 21, 2004 9:23 am    Post subject: Re: The Gist of Object Oriented Programming Reply with quote


Quote:
Well to start with I would never have recognised OO from your first
paragraph. Try

Object orientation is a view of programming where the available behaviour is
strictly constrained by the type of the data. For example, if you have two
values that represent dates, subtracting one from the other will result in a
number of days, addition, multiplication and division are not only
meaningless but attempts to apply them to such values are diagnosed errors.

Of course I am definitely not happy with my paragraph because trying to
encapsulate such a major paradigm in a single paragraph requires skills that
I do not have.

Nonetheless that was a pretty good attempt. When Bjarne Stroustrup
was here and presented a brief description of his language, it was very
similar to what you have said. UDT, might be the essence of OOP.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Francis Glassborow
Guest





PostPosted: Wed Apr 21, 2004 2:09 pm    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

In message <XG8hc.7899$um3.191094 (AT) bgtnsc04-news (DOT) ops.worldnet.att.net>,
Peter Olcott <olcott (AT) worldnet (DOT) att.net> writes
Quote:
The benefit of OO is OO-designed objects have behavior conceptually
similar to real-world entities, and OO-designed types have
behavior conceptually similar to real-world categories.

This is the kind of material that I was looking for. Because of the
capability to create user defined types, OOP can more closely
correspond to the real world. This makes systems much more
self-documenting, but, more importantly, provides these systems
with a fully elaborated design, this being the design of the real
world system that is being modeled.

However I know a number of OO experts who will dance up and down with
irritation at this view of OO because it leads to a simplistic approach.
It certainly helps the novice get started but there is more to it and a
fixation on that view will inhibit the student from going further.

I can remember an enlightening conversation with the designer of some
software for managing an oil refinery. The gist of it was that the
'objects' were not the physical equipment but the processes.

The trouble is that it takes a great deal of time and open-minded
experience to develop wisdom. Sound-bytes are often greatly inhibit the
acquisition of wisdom.

--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Hyman Rosen
Guest





PostPosted: Thu Apr 22, 2004 12:17 am    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

Francis Glassborow wrote:
Quote:
However I know a number of OO experts who will dance up and down with
irritation at this view of OO because it leads to a simplistic approach.

In my opinion, OO is a programming technique, and the objects are
programming constructs which help you write the program to do what
it needs to do. The objects may model some aspect of the real world
or they may simply be useful internal constructs or both, whatever
gets the job done.

Arguing about the "meaning" of the objects in a program is one of
the most useless endeavors I can think of.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
llewelly
Guest





PostPosted: Thu Apr 22, 2004 3:02 pm    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

John G Harris <news0 (AT) nospam (DOT) demon.co.uk> writes:

Quote:
In message <8665bvvrir.fsf (AT) Zorthluthik (DOT) local.bar>, llewelly
[email]llewelly.at (AT) xmission (DOT) dot.com[/email]> writes

snip
The benefit of OO is OO-designed objects have behavior conceptually
similar to real-world entities, and OO-designed types have
behavior conceptually similar to real-world categories.

The idea that there is a mapping from things inside the computer to
things outside

There is not 'a mapping'. There are endless possible mappings. It is
up to the designer to devise one that aids understanding. If such
a mapping is difficult to determine, OO may not be appropriate.

Quote:
can be tricky to describe, and is sometimes misleading.

If OO design ideas are tricky or misleading in a particular problem
domain USE SOMETHING ELSE.

Quote:

For instance, where in the real world do you find Sonic The Hedgehog and
Lara Croft? What exactly is a digital camera image, and where is it?

Why is OO so useful when doing BigInt arithmetic?

I don't think OO is at all useful for BigInt arithmetic. BigInt
arithmetic naturally operates on values, not on entities. In
fact, I think OO is a hindrance when it comes to most kinds of
numerical types. (Especially in a langauge like C++, which has
rather primitive OO.)

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
llewelly
Guest





PostPosted: Thu Apr 22, 2004 3:05 pm    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

Francis Glassborow <francis (AT) robinton (DOT) demon.co.uk> writes:

Quote:
In message <XG8hc.7899$um3.191094 (AT) bgtnsc04-news (DOT) ops.worldnet.att.net>,
Peter Olcott <olcott (AT) worldnet (DOT) att.net> writes
The benefit of OO is OO-designed objects have behavior conceptually
similar to real-world entities, and OO-designed types have
behavior conceptually similar to real-world categories.

This is the kind of material that I was looking for. Because of the
capability to create user defined types, OOP can more closely
correspond to the real world. This makes systems much more
self-documenting, but, more importantly, provides these systems
with a fully elaborated design, this being the design of the real
world system that is being modeled.

However I know a number of OO experts who will dance up and down with
irritation at this view of OO because it leads to a simplistic
approach.

It certainly helps the novice get started but there is more to it and a
fixation on that view will inhibit the student from going further.

Agreed, but I couldn't think up a short paragraph which didn't have
that drawback.

I'll agree that there is danger in simplification, but sometimes I
think one difference between the beginner and a master, is that
the master has identified and unleared many of the simplifications
that were helpful or necessary to him as a beginner.

I don't believe it's possible to avoid all simplifications.

Quote:
I can remember an enlightening conversation with the designer of some
software for managing an oil refinery. The gist of it was that the
'objects' were not the physical equipment but the processes.

I think at some point the student must learn that OO can be used to
map entities which are not real-world things to program objects,
but I don't know fit that into a short paragraph for a beginner.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Dave Harris
Guest





PostPosted: Thu Apr 22, 2004 3:06 pm    Post subject: Re: The Gist of Object Oriented Programming Reply with quote

[email]Roger314159 (AT) hotmail (DOT) com[/email] (Roger Smythe) wrote (abridged):
Quote:
This was an attempt to explain the gist of OOP to programmers
accustomed to the structured programming paradigm.

I think we need to see how you defined "Structured programming" Smile
I generally take that to mean the Single Entrance, Single Exit
approach to coding individual routines. As such it was at a lower
level than OO, which is a way of organising routines into modules.


Quote:
I tried to explain OOP in terms of ideals that can be striven for,
even though these ideals may never be perfectly achieved in real
systems.

For me it a specific strategy for achieving those ideals, whether or
not that strategy is successful. Other strategies may do better
without having to be called OO. "Object oriented" is not a synonym
for "good".

Specifically: OO is a decompositional paradigm which takes access
to common representations as its relatedness metric.

The goal is to manage dependencies. We want to avoid situations where
changes to one module causes changes to another module, because that
can lead to knock-on effects propagating through the code without
limit. The OO insight is that changes to a representation are likely
to cause changes to the code which manipulates it. Therefore we
organise modules around the representations, to form Abstract Data
Types.

I prefer the word "representation" to "data", even though in C++ we
are usually talking about data, because I believe the insights of OO
can carry across to situations in which there is no mutable state.

So OO is programming with ADTs. Some people call that "Object based",
saying that it is not OO without inheritance and dynamic
polymorphism. I disagree. I think there is a kind of mental flip
which happens when you go from structured programming to OO, and I
think it happens with ADTs. The other stuff is nice, of course. A
good OO language should support, in order of importance:

(1) User-defined abstract data types.
(2) Message-sending or some other form of dynamic polymorphism.
(3) Inheritance or some other form of explicit reuse.
(4) Automated memory management.

(The last one is controversial in this newsgroup - drop it if it
causes offense.)

-- Dave Harris, Nottingham, UK

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.