Chapter 4. Object-Orientation

only for RuBoard

Several different mechanisms of reuse are available in Visual Basic. Implementation inheritance allows you to derive a child class from a parent class. The behaviors of the parent class are inherited by the child and possibly extended. The parent class typically contains general operations (if any), while the child class contains more specialized behaviors. The relationship is known as an is-a relationship (i.e., a Car is a Vehicle ).

The second type of reuse, which is often confusing to beginning programmers, is containment . In containment, one class contains another, representing a has-a relationship. For instance, a Vehicle has a Motor .

Finally, in Chapter 5, you will learn about interface-based programming . Interfaces represent services that don't necessarily conform to class boundaries. The relationship could be described as a provides-a relationship. A Vehicle , for example, can be painted , but so can a House . These two objects are completely different, unrelated in almost every way. Although painting either object would involve vastly different work, a common description of the process (characterized by a common verb, such as "to paint") is possible.

While the syntax of each type of reuse is simple, the when and the why require more of an explanation. For instance, not all relationships defined in terms of is-a are appropriate for inheritance. Improper modeling of these relationships accounts for many of the design errors in an object-oriented system ("too much" design actually causes most design errors). Therefore, it is worth discussing their proper use. Inheritance is one of the most fundamental aspects of object-oriented programming. A thorough understanding of both how it works and when you should use it is essential to a successful object-oriented system.

only for RuBoard


Object-Oriented Programming with Visual Basic. Net
Object-Oriented Programming with Visual Basic .NET
ISBN: 0596001460
EAN: 2147483647
Year: 2001
Pages: 112
Authors: J.P. Hamilton

Similar book on Amazon

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