|
-
Nov 27th, 2003, 11:06 PM
#1
[Your Opinions] Inheritance
I'm well aware of the advantages of inheritance. If you're not, ask us 
But I'd like to know, how often do you actually use it in your applications? I myself have used it just two times in total. (I know, VB6 doesn't have inheritance, I used our favorite pseudo-inheritance) And in those cases too, the usage was not very significant.
The way I see it,
1. Inheritance is something that jealous C/C++ programmers like to talk about in front of a VB programmer to vent their jealousy. I'm sure you've heard people referring to VB as a "toy" language, when the fact of the matter is, it can be much more than that, depending upon the implementation methods you choose.
2. VB programs don't really need inheritance. Like I said, again, I've only used it twice.
Of course, this is just my opinion, so that make it right. But I'd like to know your opinons on this. Since we have different visitors coming at different times, I'll bump this topic every couple hours for more inputs.
Edit: Also, how many times have you used it? Do you personally ever see the need for it, or have seen the need for it?
-
Nov 28th, 2003, 03:15 AM
#2
Hi,
I have done coding in java as well as vb and I still haven't come across a single case where I used inheritance in VB.
I have definitely used it in java.
BTW - Why do you need inheritance in visual basic? Could you quote the instances where you needed to use inheritance?
Cheers,
Abhijit
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 28th, 2003, 03:17 AM
#3
Hyperactive Member
I think that Inheritance is very useful and essential for real object oriented design and development. And it is not used only in C++, Java programmers use it as well as VB.NET programmers.
And I don't see the reason for C++ programmers to be jealous. A good C++ (especially MFC) programmer can program VB very easily.
-
Nov 28th, 2003, 03:24 AM
#4
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Nov 28th, 2003, 03:27 AM
#5
Fanatic Member
Well if you read my other post you already know that I dont really see the purpose of inheritance. 
So until I see a real example of it being usefull my opinion is that its an unnecessary step in VB.
Menhak if you have an example of where it was actually usefull to you in VB I would really like to see it.
-
Nov 28th, 2003, 03:33 AM
#6
Hi teve,
Cud u post a link 2 ur other post?
Abhijit
-
Nov 28th, 2003, 03:44 AM
#7
Re: [Your Opinions] Inheritance
Originally posted by mendhak
...But I'd like to know, how often do you actually use it in your applications? I myself have used it just two times in total. (I know, VB6 doesn't have inheritance, I used our favorite pseudo-inheritance) And in those cases too, the usage was not very significant.
...
Edit: Also, how many times have you used it? Do you personally ever see the need for it, or have seen the need for it?
Being fairly new to .net (but not VB) I've moved over to C# as my language of choice, I hope this doesn't preclude my opinion on this subject too much. Esp since C# isnt too far removed from VB anyway.
I use inheritance quite heavily in all of my programs, my record is 7 tiers so far!
It was such a liberating thing I just grabbed onto it and won't let it go for the world now I use my classes mainly for writing out realtime text (plain english) reports that can be sent to screen, file, email or printer. I wrote one class to handle printing (via Drawing.Printing namespace), another class to deal with file access as pertains to my needs (using IO and Text namespaces) a third to encapsulate console functions and interface with my app semantics.
The Email class inherited the file class, which in turn inherited the printer class and thus the screen class. So all I have to do is use the SendTo() function to email the report (which is the base class of the screen class) and a function called AppendText() which uses polymorphism (overloading / overriding) to decide whether to send the string to the PrintDocument(member of printing class), the screen or to a file.
Thus its possible for my apps to ask for user input onscreen and mirror that input in a written report without even indicating that the user had been asked at all!
Very sexy if I may say so myself. And that's 5 tiers of inheritance (if you inlude the base)
I'd be stuck if inheritance didn't exist. 
.Net rocks, it lets thicko's like me to write reasonlably decent programs.
I don't live here any more.
-
Nov 28th, 2003, 03:49 AM
#8
Re: ??
Originally posted by SnakeMaker
also btw, check out my snake game that I made a few yrs back and added an online scoreboard too... very interesting to see who can "Hack the server First" or "be the best snakest" ....
Just go play...
What does this have to do with anything? you'd be better off starting a new thread in the game forum or something.
-
Nov 28th, 2003, 04:52 AM
#9
StevenHickerson:
I can give you an example of where it would be used:
Let's say you're designing a large banking system, in which you have to specify several different methods, functions, properties, etc for different entities like accounts, loans, etc.
Now, an account could be of several types: savings account, current account, "gold" account, "joint" account, and other stupid accounts. The implementation of inheritance here would be that you create a base "account" class which imbibes the basic functionality common to all accounts, then you inherit it, and use it for your different types of accounts. See what I mean?
My point is, the apps that we VB developers create aren't usually part of multi-million dollar projects.
Gush:
You're only stating the obvious. It's the same stuff I hear everyday regarding inheritance. "True object oriented programming." Question is, how common is it?
Wossname gave us his example of usage of inheritance, albeit in a different language. And it's a good example too. .NET is good, I'm still in the intermediate-beginner phase, and it's very attractive. Inheritance would definitely come more into play with .NET languages, but what about VB6?
More opinions, anyone?
-
Nov 28th, 2003, 05:32 AM
#10
Hyperactive Member
Just because VB6 doesn't support inheritance doesn't mean that it is not useful.
My point is, the apps that we VB developers create aren't usually part of multi-million dollar projects.
Inheritance can be used in the smallest of projects. It doesn't have to be a multi-million project. Even a small project must be well organized and structured, and this cannot be achieved without a good hierarchy.
Take a card game for example, this should be a rather small project. Well if one is implementing a multi player card game, in which a player can either be Human, or the Computer. Here for example, a Player base class is defined, and it will be derived into two classes, and each one will implement the different functions of this class according to its needs. Now the Class instantiating the player class will define an object for each player, regardless of the type of the player.
Now I use VB6 for almost all my projects. But in almost every one of them I wished that vb supported inheritance.
Edit: Also, I was under the impression that we are talking about inheritance in general, not only using VB6. Anyway if VB6 supported inheritance, it would have been great. That's my opinion.
Last edited by Gush; Nov 28th, 2003 at 05:42 AM.
-
Nov 28th, 2003, 05:53 AM
#11
Speaking of inheritance, PB has supported it right from ver 6.5
You can inherit all the existing objects and reuse the same code again and again.
Abhijit
-
Nov 28th, 2003, 05:53 AM
#12
I have come across a few situations where I could really do with true inherritance in VB...but alas it doesn't work 
I have many classes that ALL have the following properties, subs etc:
In ALL classes
- State
- SuperState
- Fetch
- Update
- CancelUpdate
- Backup
- Dirty
- StructureDirty
- Show
In ALL single classes
...and more for collection classes, you get the picture anyways.
The code behind these subs etc, is 99.999% identical.
.NET will sort it out though...I think...
Woof
-
Nov 28th, 2003, 08:06 AM
#13
Banned
Was my entire first part of my reply invisible???... Read the first few lines of it
Hmmm Im not even sure what Inheritence are... can you explain, I think I've heard of them before, but... I probably just dont know the "word" for .. what it is...
*** Text removed by ADMIN - Brad! ***
-
Nov 28th, 2003, 08:14 AM
#14
-
Nov 28th, 2003, 08:24 AM
#15
Banned
Oh, so is inheriting... similar to ... Include for C++.?
Also is it like Require() in PhP?...
*** Text removed by ADMIN - Brad! ***
-
Nov 28th, 2003, 08:30 AM
#16
Sorry, couldn't comment on C++ or Php, I only know VB thank god. I don't even like computers that much. I just do this for a living. If someone had told me 4 years ago, when I didn't even know what VB was, I would be a programmer then I would have laughed in their faces 
It doesn't take long to post source code...zip up the main directory, then post it here...will take 30 seconds...anyways, add it into your sig. If you keep posting it in threads then people will tell you to **** off and will start having a go at you I am afraid. This is the wrong type of forums to be posting stuff like that 
Doesn't bother me as I am a badger and have no opposable thumbs to plays games with But others take offence. And to top it off, no offence, but it's only a snake game. They have been around since computers were invented and MANY MANY users have written snake games. It's nothing new If you do a search on the web you will no doubt find a flash verion of a snake game that is 3000x better than yours. Not having a go at you, just merely stating some facts...hope you don't mind.
Anyways, add it into ya sig.
Woof
-
Nov 28th, 2003, 08:39 AM
#17
Banned
oh, I understand, the game itself I made a few years back, its just the otherday, I was bored.... and added client/server online scoreboard... just for fun, and I just wanted to see how many people will play it... and see if they can "hack it", the data isnt encrypted when its sent across so Im sure someone can just make a program that would send say "NewScore|Name|NewScore", now im not saying thats EXACTLY how its setup, but im sure it's similar to that... 
Its just a fun experiment I'm having...
*** Text removed by ADMIN - Brad! ***
What Include does, is when the C++ code is being Compiled...
Say you have like Include connectToDataBase.h or something
it will go and grab this text file and throw it where the Include is, this way say u need that code for MANY many files... you just have to have it in that one file, and just Include it many times for every file that you need it in... understand? Require() in PhP is basically identicle...
-
Nov 28th, 2003, 08:50 AM
#18
Have you listened to anything I have said? *sigh* 
Anyways, no it's not like the include. VB has resources, components and references for any external modules (DLL, OCX's and ActiveX EXE's) that it uses. These automatically get added to the setup package...again, people may correct me on this, but I know what I mean, and I'm right in my head 
Do a search for it on the MS site or google. There are loads of web pages explaining what it is.
Woka
-
Nov 29th, 2003, 05:24 PM
#19
Inheritance is a concept or principal and brings benefits to any language that implements/supports it. So the same ideas represented in .NET or other languages apply to VB6 or all others IF they had inheritance. Since I currently use VB.NET and I use inheritance a lot here are some examples I have: Extending the standard controls from .NET (adding Icons to menus, Images to Comboboxes, listboxes), Plugins (this allows me to pass functionality along too not just structure as an Interface does), and misc. other example like you typically think of. I am working on a larger project at work that works with Nurses and Patients a lot so I made a base class that holds all similar functionality and properties that they each inherit from, likewise for simplier contact info for Doctors, Emergency Contacts... Not only does this save me coding time by not repeating the same stuff, it helps with maintance because if I make any change to the base class it automatically filters down to the derived classes. Also it allows me to make common functions that except the base class type and thus will work for all the derived types as well. Another way I have used inheritance is to make a generic DataLayer. Anytime I want to implement a set of basic functionality that makes a class or collection bind properly to a datagrid, and map to a database with a certain set of events and methods I just inherit it from a DataLayerBase class and it handles all the database parts for me. I just add attributes to any properties I want mapped to data and I'm done.
-
Dec 2nd, 2003, 04:57 AM
#20
I don't live here any more.
-
Dec 2nd, 2003, 05:06 AM
#21
Originally posted by SnakeMaker
Oh, so is inheriting... similar to ... Include for C++.?
Nope, that just adds a load of code into another code file. #include merely makes that code available without typing it in manually.
Inhertance...
A Derived class inherits from its Base class. For example you Inherited your father's height (for instance). Thus you are the Derived class and your father is the Base class. You're probably a bit taller (more technologically advanced) than him.
#include...
...means that you are simply standing in the same room as some random other guy. You don't necessarily inherit anything from him. He might even be taller (more technologically advanced) than you. It's even possible he speaks swahili and has nothing in common with you at all.
That's how I imagine it anyway. Its not really as simple as that. I wish it was!
I don't live here any more.
-
Dec 19th, 2003, 02:50 PM
#22
I have never used inheritance in VB6 (naturally ), but I have used it in C++. I have been working on a modeling system that makes extensive use of run-time polymorphism, and inheritance is fairly fundamental in that. I have an array of pointers to the base class, and it really doesn't matter how many different types of classes I have inheriting from that base class, the system will work. This is a kind of built-in extensibility, since I can't decide how many trophic levels will be there (lake ecosystem modeling).
I was reading an editorial in a C++ prog journal a few months back, where the editor was complaining about tutorials all using trivial examples (an orange is a fruit) to show relationships between classes. He was saying that these were unrealistic examples, because nobody ever really uses inheritance in such simplistic fashion. I was tempted to write him to point out that I was doing just that. Each species inherits from the base class organism. Not only is this correct, but it is the most efficient way to go about it.
I may or may not use inheritance much as I move into .NET, but I will keep it in mind. It isn't useless, but you do have to guard against overdoing it.
-
Dec 20th, 2003, 10:01 AM
#23
I use inheritance in Java, of course, and sometimes in C++, but in C++ I tend to use templates.
Of course templates and inheritance have somewhat different uses, but often there are problems that can be solved with either.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|