Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search.
Apparently I need to clarify that it is commonly understood that object-oriented includes implementation inheritance and polymorphic behaviour. It has been asserted VB. NET is object-oriented. I understand that VB. NET followed VB6. Did VB6 have implementation inheritance and polymorphic behaviour? Did VB. NET have implementation inheritance and polymorphic behaviour? NET have the other aspects of object-orientation?
The Wikipedia article on VB. NET gives both and as the date of release. When was VB. NET "released"? VB6 was not object-oriented, although it had some features that were influenced by OOP. The first version of VB. I knew this would turn into a debate, and thats okay Just don't get too pissed at each other in the process.
The funny thing is I have always wanted to be able to extend to classes in VB, I just didn't know it was called inheritence and that it was part of pure OOP. Thanks guys. Feel free to keep debating. Extend classes can be done in many ways, the easiest and best is "true" inheritance but since VB6 lacks this possibility you can use one of many other techniques depending on how you want to extend them. VB can, as I already mentioned simulate inheritance via deligation. You can also use interfaces to inherite yes you guessed it interfaces.
I'm not too interested in actually doing inheritance at the moment, but could you give an example of one way it might be done in VB?
NET VB. Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace. Remember Me? Advertiser Disclosure. Advanced Search. Results 1 to 11 of Thread Tools Show Printable Version.
It should not allow any corresponding implementation code. It is up to other classes, which realize that interface, to provide the implementation. Implementation inheritance lets subclasses share common code and attributes properties. Also, implementation inheritance's ability to declare an operation abstract enables it to act similar to interface inheritance and force subclasses to implement the operation instead.
NET class can only enter into an implementation inheritance relationship with one superclass also called base or ancestor class. However, VB. NET, like VB6, lets that same class enter into as many interface inheritance relationships as it chooses.
An example may help. Say you are developing an app in which the Store object wants to ask an instance of the Stereo class to calculate availability inventory. However, the Stereo class wants to borrow the functionality already provided by its superclass, Product. The Store object might implement such functionality like this:. The real implementation of this behavior is in Product's calcInventory method.
Because VB6 doesn't support implementation inheritance you need to put some code in the Stereo class:. VB6 allows the interface, the Product class, to implement the actual behavior.
Stereo keeps an instance of Product containment then asks that reference to do some work for it delegation. This type of interface inheritance is not a true interface because it allows you to add code to Stereo to provide the actual behavior.
With VB. NET you can remove the containment and delegation code by using implementation inheritance. For example, in the Stereo class:. The Store class makes a calculation request similar to the way the Stereo class makes this request, but Stereo carries out the work much differently in VB. The Stereo instance, myStereo, doesn't contain a calcInventory method so VB looks up its superclass, Product, and executes its calcInventory procedure.
Implementation inheritance also allows you to override superclass operations. An Items class might use this to provide its own implementation of calcInventory which would cancel out the behavior provided by its Product superclass. For instance:. All of the above may sound a bit confusing if you have not used inheritance in the past.
Take a second to reread the above and you will see that it is really not that difficult. Interface inheritance tends to be a little harder to grasp for some but, again, it is not that though of a concept. Implementation inheritance allows you to reduce your code base drastically since subclasses gain the methods of their superclass. This is a mixed blessing. If you start with a poor design you will end up with code that is more difficult than ever to debug and maintain.
Code and attributes once common in the superclass may not remain common as the app's business needs evolve over time. Writing Code 6. Managing Data 7. String Manipulation 9. Else Select Case Looping MsgBox and InputBox String Functions Math Functions Format Functions Date and Time Checkbox Radio Button Create Web Browser Errors Handling Create Files Create Graphics Drawing Rectangle Drawing Ellipse and Circle
0コメント