199. Design Patterns Using C#
This course is extremely hands-on and students are required to have intermediate to advanced
programming using C# in order to take full advantage of this course. A case study is implemented
throughout the course and students will be able to experience and understand how various design patterns
work together while implementing a real application
LEARNING OBJECTIVES
·
By the end of the course,
students will be able to effectively identify and apply common design patterns using
C#
Course Duration: 5
days
Prerequisites:
·
NET Platform
·
Visual Studio 2005
·
Intermediate to Advanced
C# Programming
·
UML (not mandatory)
1.
Introduction
A Brief History of Patterns
Description of Patterns
Pattern Name
2.
Overview of UML
Class Diagram
Collaboration Diagram
Statechart Diagram
3.
Fundamental Design Patterns
3.1. Delegation (When not to use Inheritance)
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET Usage
Code Example
Related Patterns
3.2. Interface
Synopsis
Context
Forces
Solution
Implementation
Delegates
Constructors
Consequences
.NET Usage
Code Example
Related Patterns
3.3. Abstract Base Class
Synopsis
Context
Forces
Solution
AbstractBaseclass
ConcreteClass1, ConcreteClass2, . . .
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
3.4. Interface and Abstract Class
Synopsis
Context
Forces
Solution
Consequences
.NET API Usage
Code Example
Related Patterns
3.5. Immutable
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
3.6. Proxy
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
4. Creational Patterns
4.1. Factory Method
Synopsis
Context
Forces
Solution
Implementation
Class Determination by Configuration
Data-Driven Class Determination
Consequences
.NET API Usage
Code Example
Related Patterns
4.2. Abstract Factory
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
4.3. Builder
Synopsis
Context
Forces
Solution
Implementation
The Build Process
Consequences
.NET API Usage
Code Example
Related Patterns
4.4. Prototype
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
4.5. Singleton
Synopsis
Context
Forces
Solution
Implementation
Concurrent GetInstance Calls
Consequences
.NET API Usage
Code Example
Related Patterns
4.6. Object Pool
Synopsis
Context
Forces
Solution
Reusable
Client
ReusablePool
Implementation
Hiding the Object Pool
Delegating Object Creation
Ensuring a Maximum Number of Instances
Data Structure
Limiting the Size of the Pool
Managing Stateful Objects
Consequences
Code Example
Related Patterns
5.
Partitioning Patterns
5.1. Filter
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
5.2. Composite
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET Usage
Code Example
Related Patterns
5.3. Read-Only Interface
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
6.
Structural Patterns
6.1. Adapter
Synopsis
Context
Forces
Implementation
Consequences
Code Example
Related Patterns
6.2. Iterator
Synopsis
Context
Forces
Solution
Implementation
Generics
Additional Functions
Multiple Orderings
Null Iterator
Modification to the Underlying Collection
Consequences
.NET API Usage
Code Example
Related Patterns
6.3. Bridge
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Example
Related Patterns
6.4. Façade
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Example
Related Patterns
6.5. Flyweight
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Example
Related Patterns
6.6. Dynamic Linkage
Synopsis
Context
Forces
Solution
Implementation
Incompatible Classes
Security Risk
Consequences
.NET API Usage
Code Example
Related Patterns
6.7. Virtual Proxy
Synopsis
Context
Forces
Solution
Service
Client
ServiceProxy
IService
Implementation
Shared Service Objects
Deferred Class Loading
Consequences
Code Example
Related Patterns
6.8. Decorator
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
6.9. Cache Management
Synopsis
Context
Forces
Solution
Implementation
Structural Considerations
Implementation of the Cache
Performance-Tuning a Cache
GetHashCode( )
Consequences
Code Example
Related Patterns
7.
Behavioral Patterns
7.1. Chain of Responsibility
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
7.2. Command
Synopsis
Context
Forces
Solution
Implementation
Undo/Redo
Avoid User Interface Dependencies
Consequences
.NET API Usage
Code Example
Related Patterns
7.3. Little Language
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
7.4. Mediator
Synopsis
Context
Forces
Solution
Colleague1, Colleague2 . . .
EventHandler1, EventHandler . . .
Mediator
Implementation
Recursive Events
Consequences
Code Example
Related Patterns
7.5. Snapshot
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
7.6. Observer
Synopsis
Context
Forces
Solution
Implementation
Observing the Observable
Eliminating the Multicaster
Batching Notifications
Veto
Consequences
.NET API Usage
Code Example
Related Patterns
7.7. State
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
7.8. Strategy
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
7.9. Null Object
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
7.10. Template Method
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
7.11. Visitor
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
7.12. Hashed Adapter Objects
Synopsis
Context
Forces
Solution
Implementation
The Hash Table Data Structure
Alternate Data Structures
Consequences
Code Example
Related Patterns
8.
Concurrency Patterns
8.1. Single Threaded Execution
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
8.2. Static Locking Order
Synopsis
Context
Forces
Solution
Consequences
Implementation
Known Uses
Code Example
Related Patterns
8.3. Lock Object
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
8.4. Guarded Suspension
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
8.5. Balking
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
8.6. Scheduler
Synopsis
Context
Forces
Solution
Implementation
Consequences
Code Example
Related Patterns
8.7. Read/Write Lock
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
8.8. Producer-Consumer
Synopsis
Context
Forces
Solution
Implementation
Consequences
.NET API Usage
Code Example
Related Patterns
8.9. Double Buffering
Synopsis
Context
Forces
Solution
Implementation
Multiple Buffers
Threads
Exception Handling
Consequences
.NET API Usage
Code Example
Related Patterns
8.10. Asynchronous Processing
Synopsis
Context
Forces
Solution
Implementation
Request Management and Thread Allocation
Outcome Management
Consequences
.NET API Usage
Code Example
Related Patterns
8.11. Future
Synopsis
Context
Forces
Solution
Implementation
Polling
Proxy
Launching a Synchronous Computation
Rendezvous
Exceptions
Consequences
.NET API Usage
Code Example
Related Patterns
System Requirements
The following software is required:
·
Windows XP Professional with Service Pack 2
·
Visual Studio 2005 or Visual C# 2005 Express Edition
A good minimal hardware profile for this course would have a Pentium
500-MHz or equivalent CPU, 256 MB of RAM