Advertisement

Definition of OOP

Started by July 21, 2000 03:56 PM
25 comments, last by null_pointer 24 years, 5 months ago
quote: Original post by nicba

To be considered Object Oriented I think a language has to cntain at least the following 3 features:

1. Encapsulation
2. Inheritane
3. Polymorphism


This would imply that VB IS an object oriented language..


VB supports Encapsulation via classes or UDTs.

VB supports Inheritance through the keyword Implements. Although, VB doesn''t support implementation inheritance (at least at last glance), meaning you have to reimplement all the methods of the parent class. You didn''t specify that you had to LIKE the way OO features were implemented.

VB supports Polymorphism as you can redefine the behavior of the parent methods in your child class. Also provides runtime identification of classes (RTTI). VB also supports the concept of an abstract class.







Actually, OOP theoretically should be possible in any procedural language, which it is, C, Pascal, etc. all have ways of doing it. But VB isn''t an OOP language, completely. It supports *most* OOP features, but not all. Although, it is correct to say VB is not a programming language but a scripting language with an application builder.

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

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
Advertisement
I would have to say that Java is not OOP.... it is Object Based. There is no decision, when writing a Java program, as wether or not to use objects.... The program itself is an object, and everything within Java is an object. Therefore I would conclude that Java is OBP instead of OOP.

40

www.databyss.com
www.omlettesoft.com

"Don''t meddle in the affairs of wizards, for they are subtle and quick to anger."
-40
OOP: Last name of a cartoon caveman. See Alley Oop. Also, a sound that an ape makes as in "Oop, oop, oop!".
I''m not criticizing Java or anything, but sometimes I think Java was made to keep you from hurting yourself...

- DarkMage139
++++++++++++++++
I can do things, things you never knew,
I can change your world if you only knew.

I can do miracles if you want me to.
Anything is possible, I'll prove it to you.
- DarkMage139
quote: Original post by ImmaGNUman
Although, it is correct to say VB is not a programming language but a scripting language with an application builder.

I suggest you actually know something about VB before posting. VB has a native compiler which compiles to native code. It is defaulted to to that. VB4 and lower did not. It has P-Code. Either way, it isn''t a scripting language.

And to the Anon Poster, I hope you''re right. I don''t have the slightest clue on what those 3 things are. Although I know what implements does. :p

------------------------
Captured Reality
Advertisement
OK, I do not know VB and I really do not care if it is OOP or not, so don''t take this wrong. But I have some question about VB.

quote: Original post by Anonymous Poster

VB supports Encapsulation via classes or UDTs.



What''s UDT''s???

quote:

VB supports Inheritance through the keyword Implements. Although, VB doesn''t support implementation inheritance (at least at last glance), meaning you have to reimplement all the methods of the parent class. You didn''t specify that you had to LIKE the way OO features were implemented.



No implmention inheritance?? Strange. It sounds almost as if VB classes is really interfaces (Java also uses the keyword ''implements'' when dealing with interfaces).

quote:

VB supports Polymorphism as you can redefine the behavior of the parent methods in your child class. Also provides runtime identification of classes (RTTI). VB also supports the concept of an abstract class.



Well, redefining (overriding) parent methods isn''t really what is understood by Polymorphism. Polymorphism is when you use late binding (compiler time binding) to call methods of a child class through a pointer to a parent class. Example:

You have 3 differend classes in your game Animal, Dog and Cat. Animal have the public method Sound() which both Dog and Cat inherits and overrides. Now you want to store a list of both dog''s and cat''s in an array so you creates an array of pointers to Animals (but let your pointers point to Dog and Cat objects). Then when you loop through the array calling the sound() method for each item the compiler would use polymorphism to determind which sound() method to call by determinding (at runtime) which class your pointer really pointed to. Without polymorphism the compiler would already had hard-wired these function calls to the sound() method of the parent class Animal since all your pointers pointed to that class.

I hope I made myself somewhat clear. Now, could someone tell me if VB still supports Polymorphism?

Regards

nicba



quote: Original post by nicba
Well, redefining (overriding) parent methods isn''t really what is understood by Polymorphism. Polymorphism is when you use late binding (compiler time binding) to call methods of a child class through a pointer to a parent class. Example:

You have 3 differend classes in your game Animal, Dog and Cat. Animal have the public method Sound() which both Dog and Cat inherits and overrides. Now you want to store a list of both dog''s and cat''s in an array so you creates an array of pointers to Animals (but let your pointers point to Dog and Cat objects). Then when you loop through the array calling the sound() method for each item the compiler would use polymorphism to determind which sound() method to call by determinding (at runtime) which class your pointer really pointed to. Without polymorphism the compiler would already had hard-wired these function calls to the sound() method of the parent class Animal since all your pointers pointed to that class.

I hope I made myself somewhat clear. Now, could someone tell me if VB still supports Polymorphism?

Regards

nicba

God that was confusing...thanks for clearing it up.

Anyhoo, if you put it that way, yes VB does support polymorphism. Using Implements it can do that. That''s how I made plugins for the Captured Reality Engine.

If you understand VB and have VB, try this link. Patrice Scribe shows how to make plugins with Implements and such. Tell me, is that polymorphism?


------------------------
Captured Reality
quote: Anyhoo, if you put it that way, yes VB does support polymorphism. Using Implements it can do that.


How does this implements thing work... and can they be changed during runtime? Let me use the classes mention by that dude before... Animal as the parent class and Dog and Cat as the subclasses... In C++ when you construct your classes this way using virtual functions (or how you want it) you actually create both objects... say you do this:

Animal* ptr=0;

now during runtime i can execute this:

ptr = new Dog;

ptr->Sound(); // executes the Sound() function in the Dog class

ptr.Sound(); // executes the Sound() function in the Animal class

Further in my program if needed i could do this:

ptr = new Cat;

ptr->Sound(); // executes the Sound() functino in the Dog class

ptr.Sound(); // again back to the Animal class

and I can modify these all i want during my program with if's and stuff... during runtime... so it's called a runtime polymorphism... is this possible in VB using implements?

40

www.databyss.com
[a]http://www.omlettesoft.com'>www.omlettesoft.com

"Don't meddle in the affairs of wizards, for they are subtle and quick to anger."

Edited by - 40 Thieves on July 23, 2000 7:01:50 AM ' Target=_Blank>Link
-40
quote: Original post by nes8bit

God that was confusing...thanks for clearing it up.

Anyhoo, if you put it that way, yes VB does support polymorphism. Using Implements it can do that. That''s how I made plugins for the Captured Reality Engine.

If you understand VB and have VB, try this link. Patrice Scribe shows how to make plugins with Implements and such. Tell me, is that polymorphism?



I don''t know anything about VB. I have never owned VB and have never had a chace to look at VB code before.

But anyway I took a quick look at the link you provided and to me it seems like it is polymorphism allright. And I saw that it had the ''public'' and ''private'' keywords also, so encapsulation is also OK.

The only issue left is then inheritance. If you can''t inherit implementation in VB then you don''t really have that much to inherit. You can''t inherit an objects behaviour only its definition (much like Interfaces as I said before). Haven''t VB got an ''extend'' keyword or something?

Regards

nicba

This topic is closed to new replies.

Advertisement