Results 1 to 23 of 23

Thread: [Your Opinions] Inheritance

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Post [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?


  2. #2
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228
    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

  3. #3
    Hyperactive Member
    Join Date
    May 2001
    Location
    Beirut, Lebanon
    Posts
    318
    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.

  4. #4
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228
    Originally posted by Gush
    And I don't see the reason for C++ programmers to be jealous. A good C++ (especially MFC) programmer can program VB very easily.
    A good programmer can program in anything. Try coding in PB and you will know what I mean.
    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

  5. #5
    Fanatic Member
    Join Date
    Sep 2002
    Location
    Lexington, SC
    Posts
    586
    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.

  6. #6
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228
    Hi teve,
    Cud u post a link 2 ur other post?

    Abhijit

  7. #7
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Cool 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.

  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  9. #9

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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?

  10. #10
    Hyperactive Member
    Join Date
    May 2001
    Location
    Beirut, Lebanon
    Posts
    318
    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.

  11. #11
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Arrow

    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

  12. #12
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    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
    • UID
    • Delete
    • Validate


    ...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

  13. #13
    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! ***

  14. #14
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    It is where many different modules use exactly the same code, but you only write the code once in a class, and "inherrit" it into other modules...sorry, I am crap at explaining things. I know what I mean

    Why not put a link in your sig...go to user profile and then add it in there so you donm't have to add it to every post, like the link in my sig.
    Also, you must be tripping on some magic drugs if you expect people to run a random EXE on their PC's...no offence, but I would touch that EXE with a ****ty stick
    Post the source if you want people to run it. I am sure your intentions are perfectly OK, and I'm also sure that the EXE is a setup file for a snake game and that it won't trash my PC...but I can't take the risk...u know how easy it is to trash a PC with a radom EXE with VERY few lines on VB code...?!
    There are less than a handful of uses on this forums whom I would trust enough to run their EXE directly...come on, think, we live in the age of trojans and viruses. The days or running random EXE's has long gone

    Woka

  15. #15
    Oh, so is inheriting... similar to ... Include for C++.?

    Also is it like Require() in PhP?...

    *** Text removed by ADMIN - Brad! ***

  16. #16
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    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

  17. #17
    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...

  18. #18
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    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

  19. #19
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  20. #20
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Originally posted by SnakeMaker
    also woss, I like throwing "This" on the end of every post just to get more people to play my game ... you should know how it is...
    I get it, but that is what your signature is for! Please don't put that in your main text because it can be misconstrued as plugging your wares where it is inappropriate. Its also confusing as its buggered this thread up already.

    Just a word to the wise. Anyway signatures are put on all your posts by default. Just go to your user cp page and add it in there.

    I don't live here any more.

  21. #21
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    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.

  22. #22
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104
    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.

  23. #23
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width