11.6 Software Engineering with Inheritance

This section discusses customizing existing software with inheritance. When a new class extends an existing class, the new class inherits the 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. C# simply requires access to the compiled base-class code, so it can compile and execute any app that uses or extends the base class. This powerful capability is attractive to independent software vendors (ISVs), who can develop proprietary classes for sale or license and make them available to users in class libraries. Users then can derive new classes from these library classes rapidly, without accessing the ISVs’ proprietary source code.

Software Engineering Observation 11.5

Although inheriting from a class does not require access to the class’s source code, developers often insist on seeing the source code to understand how the class is implemented. They may, for example, want to ensure that they’re extending a class that performs well and is implemented securely.

Students sometimes have difficulty appreciating the scope of the problems faced by designers 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 times. The availability of substantial and useful class libraries helps deliver the maximum benefits of software reuse through inheritance.

Software Engineering Observation 11.6

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

 

Software Engineering Observation 11.7

Declaring a derived class does not affect its base class’s source code. Inheritance preserves the integrity of the base class.

 

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset