Section 10.6. Software Engineering with Inheritance


10.6. Software Engineering with Inheritance

Novice programmers sometimes have difficulty appreciating the scope of the problems faced by developers who work on large-scale software projects in industry. People experienced with such projects say that effective software reuse improves the software-development process. Object-oriented programming facilitates software reuse, potentially shortening development and maintenance efforts.

This section discusses customizing existing software with inheritance. When a new class inherits from an existing class, the new class inherits the non-Private members of the existing class. We can customize the new class to meet our needs by including additional members and by overriding base class members. Doing this does not require the derived class programmer to change the base class's source code. Visual Basic simply requires access to the base class's assembly file so that it can compile and execute any program that uses or inherits the base class. This is attractive to independent software vendors (ISVs) because they develop proprietary classes for sale or license and make them available to users in MSIL format. Users then can derive new classes from these library classes rapidly and without accessing the ISVs' proprietary source code.

Software Engineering Observation 10.7

Despite the fact that inheriting from a class does not require access to the class's source code, developers often insist on seeing the source code to see how the class is implemented. They want to ensure that they are extending a solid class that performs well and is implemented securely.


The availability of substantial class libraries helps deliver the maximum benefits of software reuse through inheritance. Application designers build their applications with these libraries, and library designers are compensated when their libraries are included with the applications. The standard Visual Basic class libraries tend to be general purpose. Many special-purpose class libraries exist and more are being created.

Software Engineering Observation 10.8

At the design stage in an object-oriented system, the designer often finds that certain classes are closely related. The designer should "factor out" common instance variables and methods and place them in a base class. Then the designer should use inheritance to develop derived classes, specializing them with capabilities beyond those inherited from the base class.


Performance Tip 10.1

If derived classes are larger than they need to be (i.e., contain too much functionality), memory and processing resources may be wasted. Extend the base class that contains the functionality that is closest to what you need.


Reading derived class declarations can be confusing, because inherited members are not declared explicitly in the derived classes, but are nevertheless present in them. A similar problem exists in documenting derived class members.



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net