Y'ello Benjamin!
BLM> Hee, Hee, Hee! I've gotten more great replies because of that
BLM> little line! |) Seriously tho, with very little information
BLM> of practical use to the beginner it may as well be molecular
BLM> biology as object oriented programming. The best source of
BLM> useful information to me so far is this echo, followed closely
BLM> by Glen McCluskey's "C++ Newsletter". Tho the neither discuss
BLM> very much OOP theory. |)
Well, I have a very comprehensive set of lecture notes, brilliantly typed out
in Low-ASCII and I'm going to make them available for FREQing. They combine
little OOAD theory with C++ and are just the thing for the beginner.
BLM>> I have never seen a clear definition of object oriented
BLM>> programming.
CA>> Somebody in this echo posted a brilliant description of
CA>> exactly what OOD is.
BLM> Brilliant? In this echo? Are you sure? :>
Yes, see the end of this message. I saved this at the time because I thought
it was good, but maybe it's not exactly what you want.
CA>> Let me give you an example. Let's say we wanted to model
CA>> everything in a horse racing.
BLM> That's all well and good if you want to race horses, but what if
BLM> you wanted to extract functions from a C program.
I was just giving an example, really. "Normally", you would start with a
spec,
and isolate the components. What you are talking about is taking existing C
code and Seeplusplusifying it. :) Well, I can give you a simple example of
that too. Semaphores, ever use them in C? Well, you create a semaphore, and
then use C function calls wait(s) and signal(s). In this case you have a
mixture of functions and variables and it's all very confusing (well not
really,
but you get my drift). Why not create a Semaphore class?
It has possibly one instance variable, the semaphore variable, and a couple
f
methods, wait() and signal(). You could even add a bit of functionality by
having an instance variable which "tracks" the waits and signals made on a
semaphore. Now you have an easy to understand "Semaphore" object, with the
data
and methods which relate to it. You simply include the relevant C header
files
in your Semaphore class implementation and bury them away in the methods.
Is this what you mean? Or do you just mean C functions which you have
written?
Again, you can do that. It would just be a question of deciding "what" these
functions relate to, and organising them into a class. This sounds a bit
ike
butchery, and I'm not sure why you'd want to do it. Better to start from
scratch, design whatever it is you want, and then consider perhaps re-using
some
old C code.
BLM> Hey, I've been called much worse than a "C programmer", I take
BLM> it as a compliment. Is that a bad thing? :>
Hehehe. No, no. Sorry old boy. You are a man if you can tame a beast like
C,
but a gentleman if you can train C++. Something like that anyway. :)
What is object orientated programing?
=--=--=--=--=--=--=--=--=--=--=--=--=
It's not easy to give a totally satisfactory answer without using
some new terms that seem confusing. I will try to give you a short
and understandable, but by no means complete, answer.
Any system can be viewed either by looking at the things involved or
the processes involved. Procedural languages and design (for instance
using C) concentrate on the processes and algorithms. A collection of
functions is created to perform various operations.
In object oriented programming, the things themselves are of
interest. These are the objects. An object is just some entity that
has well defined behavior. Objects do things when one of their member
functions is called.
Object oriented programming deals with the behavior and interaction
of objects. New objects can contain other objects or inherit directly
the features of other objects.
Here's a simple example of the difference between OOP and procedural
languages. I won't discuss the mechanisms involved, but will just
tell you what happens.
Suppose you are writing a program that needs to display objects of
different shapes on the screen. In a procedural language you would
write a routine to draw a line, a circle, an oval, a rectangle, etc.
Then to display say, a circle, you would call the circle routine with
the correct center and radius. To display a rectangle, you call the
rectangle routine with the correct parameters.
In an OOP drawing program, you would have a base object, call it
Figure, from which objects for the various shapes would be derived.
To display the proper shape on the display, you might only need to
call the Draw() member function of Figure. Figure->Draw(); The object
knows what shape it is and how to draw itself!
So, instead of calling a particular procedure to display a certain
shape, you tell a shape object to draw itself. The result is you can
pass around shapes without having to worry about any particular
one--the object knows what type it is.
What is the differnce between C and C++?
=--=--=--=--=--=--=--=--=--=--=--=--=--=
C is a procedural language. You write applications by creating a
number of functions to do certain operations on data.
C++ is an enhanced C with many new capabilities that support object
oriented programming. In specific terms, C++ supports classes,
encapsulation, polymorphism, inheritance, data abstraction,
overloading, and other OOP goodies.
Sorry I don't know who to attribute this to... I thought it was good.
Fido = 2:259/33
--Craigzilla++ Internet = McMoose@sol.co.uk
WWW = http://www.taynet.co.uk/users/mcmoose/
--- GEcho 1.00
---------------
* Origin: The Kilted Bun, Letham Angus -- hame o' the McMoose (2:259/33)
|