Page 2 : 37
Object-oriented Programming in C#
Abstract classes, Interfaces, and Patterns
* Method Combination
Method Combination
Parameter Variance
Covariance and Contravariance
* Abstract Classes - Sealed Classes
Abstract Classes
Abstract classes and abstract methods in C#
Abstract Properties
Sealed Classes and Sealed Methods
* Interfaces
Interfaces
Interfaces in C#
Examples of Interfaces
Interfaces from the C# Libraries
Sample use of IComparable
Sample use of IEnumerator and IEnumerable
Sample use of IFormattable
Explicit Interface Member Implementations
* Patterns and Techniques
The Composite design pattern
A Composite Example: Music Elements
An application of Music Elements
Implementation of MusicElement classes
A Composite example: IntSequence
A Composite example: IntSequence application
Implementation of the IntSequence classes
A Composite Example: A GUI
A Composite Example: A GUI
A Composite Example: A GUI
Cloning
Cloning in C#
The fragile base class problem
The Visitor design pattern
Natural object-oriented IntSequence traversals
Towards a Visitor solution
A Visitor example: IntSequence
Visitors - Pros and Cons
Method Combination
We sometimes talk about
method combination
when two or more methods of the same name
Op
cooperate in solving a given problem
Class B is a subclass of class A
Programmatic (imperative) control of the combination of
Op
methods
Superclass controlled
: The
Op
method in class A controls the activation of
Op
in class B
Subclass controlled
: The
Op
method in class B controls the activation of
Op
in class A
Imperative method combination
An overall (declarative) pattern controls the mutual cooperation among
Op
methods
A.
Op
does not call B.
Op
- B.
Op
does not call A.
Op
.
A separate abstraction controls how
Op
methods in different classes are combined
Declarative method combination
C# supports subclass controlled, imperative method combination via use of the notation
base.Op(...)