Re: What's OOP?
- From: The_Sage <The_Sage@xxxxxxx>
- Date: Tue, 26 Apr 2005 19:53:18 -0700
>Reply to article by: randyhyde@xxxxxxxxxxxxx
>Date written: 25 Apr 2005 10:00:51 -0700
>MsgID:<1114448451.413180.279530@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
>>most readers here know me as the very last HEX-coder anyway,
>>so don't wonder my question: what's all about this OOP-stuff?
>OOP, in it's rawest form, works under the assumption that each packet
>of data (i.e., an "object") carries around not only the data, but the
>list of operations (i.e., procedures/functions) that are possible on
>that data.
Nope, that ain't it. OOP is a PROGRAMMING TECHNIQUE. It's a way of ORIENTING
your thinking on how to PROGRAM. Simply having "objects" in your code does not
make it OOP. Technically and typically, "objects" are implemented as STRUCTURES,
not "packets of data". A packet of data is what you transmit over a TCP/IP
connection, not something that exists in your code or a technique. How OOP is
implemented is never as important as the TECHNIQUE. Knowing how OOP works under
the hood does not mean one thereby understands OOP technique. OOP is a tool to
help programmers create complicated programs easier and quicker. Simple
programs, like your typical "Hello World" program, would not benefit from OOP
techniques.
>object-oriented programming you need to support two facilities:
>inheritence and polymorphism and generally you need to support a third,
>overloading.
Wrong again. The main concepts behind OOP are encapsulation (or classes) and
(virtual) methods. Since the methods are only virtual, they can be "redirected"
or overridden. The point behind the technique, regardless of it's implementation
under the hood, is to be able to declare a class at compile time, but
create/delete an unspecified number of instances of that class as required
during run time. The old way of programming would be to create each object at
compile time, with the number objects limited by the size of your pointer array
instead of by memory.
>Inheritence means that if you have a data type, then you can create a
>new data type by *extending* the old one.
>Polymorphism, in a nutshell, means that functions written for the older
>data type will operate properly on the new data type and, in fact, the
>whole purpose of those pointers to the code (that an object carries
>around) is to allow the selection of whatever procedure is appropriate
>for the task at hand.
Not even close! Polymorphism is the ability of one abstract class to use another
abstract class. This implies inheriting data and methods from one class, but
overriding the methods with functions that are applicable to that class. In
other words, I create a base class called SHAPE. SHAPE has a method called
draw(). I then subclass three other classes from SHAPE: CIRCLE, RECTANGLE, and
TRIANGLE. All three subclasses, by default, have a method called draw() that
draws the corresponding circle, rectangle, or triangle. Think of polymorphism as
multiple overriding.
>It goes without saying that OOP depends upon strong typing. In OOP
>languages, the type checking system provides this. In assemblers that
>don't support OOP, it is the programmer's responsibility to handle the
>type checking. Keeping this right is a lot of tedious work, which is
>why you don't see too many people doing true OOP programming in a
>non-OOP language (e.g., most assemblers).
OOP typical depends on type checking but it isn't a given. You could create a
compiler that restricts all data types to pointers, like JAVA does. A better way
would be to perform object checking at compile time, instead of type checking.
It's more efficient.
>In it's rawest form, the inefficiency associated with OOP is mainly all
>those indirect (rather than direct) calls to functions that operate on
>data.
OOP is one of the more efficient langauges, certainly much more efficient than
ASM for applications like CAD or 1st person 3-D games.
If you were my student, I would give you an F for knowledge and a D for effort.
The Sage
=============================================================
My Home Page : http://members.cox.net/the.sage
"Toward no crimes have men shown themselves so cold-bloodedly
cruel as in punishing differences in belief"
-- James Russell Lowell
=============================================================
.
- References:
- What's OOP?
- From: wolfgang kern
- Re: What's OOP?
- From: randyhyde
- What's OOP?
- Prev by Date: Re: An Object-Oriented Syntax for x86 Assembly
- Next by Date: HAY BETOV, your apologies are overdue !
- Previous by thread: Re: What's OOP?
- Next by thread: Re: What's OOP?
- Index(es):
Relevant Pages
|