Definition of OOP

Started by
25 comments, last by null_pointer 23 years, 9 months ago

nicba -

Thanks for providing a clear example on polymorphism. Dunno where my head was at when I posted, but I bet you could hazard a guess.

A UDT in VB is a User Defined Type, basically a struct in C.

40 Theives-
For your example of polymorphism, VB can do that easily:

    Dim theDog As IAnimalDim theCat As IAnimalDim theAnimals As New Collection'''' ojbect creation''Set theDog = New DogSet theCat = New Cat'''' add to our collection''theAnimals.Add theDogtheAnimals.Add theCat'''' iterator for our collection''Dim animal As IAnimalFor Each animal In theAnimals'''' sounds off for each animal''animal.SoundNext'''' explicitly call objects Sound method''theDog.SoundtheCat.Sound'''' clean up''Set theDog = NothingSet theCat = Nothing[/source]Yes, in VB inheritance is very similar to using interfaces...the difficulty is that you have to re-implement all of the parent class/interfaces properties and methods in your derived class..its a big issue within VB (as in it sucks ..).Here is a sample of the Dog code implementing the IAnimal interface:[source]'''' dog.cls''Implements IAnimalPublic Sub IAnimal_Sound()Debug.Print "Woof"End Sub    


You have to do that for EVERY method/property of IAnimal..so while Inheritance is supported...the support leaves alot to be desired.


-Z


Advertisement
40 Thieves:

You can''t use the . operator on a pointer, unless you do this:


(*ptr).Sound();



Which is defined to mean exactly the same thing as the -> operator. A virtual function is a virtual function - you can''t mix and match where you want (because it wouldn''t make any sense). However, you can call any of the base class versions from within a derived class''s virtual function:


class Animal
{
public:
virtual void Sound() {}
};

class Dog
: public Animal
{
public:
virtual void Sound() { Animal::Sound() }



heh heh I don''t know how the VB discussion got started, but it''s interesting...I used QBASIC so long ago...ah, memories...

But what _is_ the technical definition of OOP?



- null_pointer
Sabre Multimedia
So in more englishish terms, VB is OOP already? Microsoft said that VB7 is going to finally have OOP, but I guess VB6 already has it.

So is it true?

------------------------
Captured Reality
VB still requires runtimes from my knowledge and it is possible to create an executable without writing ANY code (course it will suck). And yes, i have programmed a little VB myself.

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
Right.

So OOP is exactally those 3 things?

------------------------
Captured Reality
(That''s what my C++ book says, that is that nicba says, and that''s even what I say, but there should be more articles on this subject on the web...especially considering how importantly this topic is regarded...)

If you don''t include those three things, the definition of OOP seems to disintegrate into one of those "every-is-everything-else; everything-is-relative" definitions, which is the epitome of uselessness.

method - 1. a way of doing something, especially according to a defined plan. 2. the habit of acting according to plan and order; system in doing things; order in thinking.

methodology - 1. the science of method. 2. the system of methods or procedures used in any field. 3. a branch of logic dealing with the application of the principles of that science in the production of knowledge. 4. the methods of teaching; the branch of education dealing with the means and ways of instruction.

Perhaps some people can write software without a clear goal or even without a clear methodology, but I can''t.



- null_pointer
Sabre Multimedia
OOP is not a method. It doesn''t give any clear algorithm or plan on how things should be done. Its more like a special way of thinking. An approach to problem solving other than the usual procedural one.

There exist a number of special methods dealing with object oriented analysis, design and (usually limited) implementation. By following such a methods you can go through a number of (iterative) steps and arrive at the end with an application.

But always at some point in such a method you must select and describe your intended platform (including language and compiler). And since even these methods take into account varying implementations of object orientation I doubt that there exists any precise definition.

Regards

nicba

This topic is closed to new replies.

Advertisement