Page 11 : 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
Interfaces
An interface corresponds to a fully abstract class. No matters of substance is found in the interface, just declarations of intent
An
interface
describes signatures of operations, but it does not implement any of them
Interfaces
Classes and structs can implement one or more interfaces
An interface can be used as a type, just like classes
Variables and parameters can be declared of interface types
Interfaces can be organized in multiple inheritance hierarchies
Sketches of the classes Vehicle, FixedProperty, Bus, and House - for the exercise.
The interface ITaxable