Get hands-on experience with each Gang of Four design pattern using C#. For each of the patterns, you'll see at least one real-world scenario, a coding example, and a complete implementation including output.
In the first part of Design Patterns in C#, you will cover the 23 Gang of Four (GoF) design patterns, before moving onto some alternative design patterns, including the Simple Factory Pattern, the Null Object Pattern, and the MVC Pattern. The final part winds up with a conclusion and criticisms of design patterns with chapters on anti-patterns and memory leaks. By working through easy-to-follow examples, you will understand the concepts in depth and have a collection of programs to port over to your own projects.
Along the way, the author discusses the different creational, structural, and behavioral patterns and why such classifications are useful. In each of these chapters, there is a Q&A session that clears up any doubts and covers the pros and cons of each of these patterns.He finishes the book with FAQs that will help you consolidate your knowledge. This book presents the topic of design patterns in C# in such a way that anyone can grasp the idea.
What You Will Learn
Work with each of the design patterns
Implement the design patterns in real-world applications
Select an alternative to these patterns by comparing their pros and cons
Use Visual Studio Community Edition 2017 to write code and generate output
Who This Book Is For
Software developers, software testers, and software architects.
Author(s): Vaskaran Sarcar
Publisher: Apress
Year: 2018
Language: English
Pages: 455
Table of Contents
About the Author
About the Technical Reviewers
Acknowledgments
Foreword
Preface
Guidelines for Using This Book
Part I: Gang of Four Design Patterns
I.A: Creational Patterns
Chapter 1: Singleton Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Discussion
Implementation
Output
Challenges
Q&A Session
Chapter 2: Prototype Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Demonstration
Output
Chapter 3: Builder Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 4: Factory Method Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Modified Implementation
Modified Output
Analysis
Q&A Session
Chapter 5: Abstract Factory Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
Conclusion
I.B: Structural Patterns
Chapter 6: Proxy Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Modified Implementation
Modified Output
Chapter 7: Decorator Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 8: Adapter Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Modified Illustration
Key Characteristics of the Modified Implementation
Modified Solution Explorer View
Modified Implementation
Modified Output
Types of Adapters
Object Adapters
Class Adapters
Q&A Session
Chapter 9: Facade Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 10: Flyweight Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Improvements to the Program
Modified Class Diagram
Modified Solution Explorer View
Modified Implementation
Modified Output
Q&A Session
Chapter 11: Composite Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 12: Bridge Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
I.C: Behavioral Patterns
Chapter 13: Visitor Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Modified Illustration
Key Characteristics of the Modified Example
Step 1
Step 2
Step 3
Step 4
Step 5
Modified Solution Explorer View
Modified Implementation
Modified Output
Q&A Session
Chapter 14: Observer Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Analysis of the Output
Q&A Session
Chapter 15: Strategy (Policy) Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 16: Template Method Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
Modified Implementation
Modified Output
Chapter 17: Command Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Modified Class Diagram
Modified Solution Explorer View
Modified Implementation
Modified Output
Chapter 18: Iterator Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 19: Memento Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Modified Implementation
Modified Output
Chapter 20: State Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 21: Mediator Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Analysis
Q&A Session
Modified Illustration
Modified Implementation
Modified Output
Chapter 22: Chain of Responsibility Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 23: Interpreter Pattern
GoF Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
Part II: Additional Design Patterns
Chapter 24: Simple Factory Pattern
Definition
Concept
Real-Life Example
Computer World Example
Illustration
Class Diagram
Directed Graph Document
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 25: Null Object Pattern
Definition
Concept
A Faulty Program
Output with Valid Inputs
Analysis with Unwanted Input
Encountered Exception
Immediate Remedy
Analysis
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
Chapter 26: MVC Pattern
Definition
Concept
Key Points to Remember
Variation 1
Variation 2
Variation 3
Real-Life Example
Computer World Example
Illustration
Class Diagram
Solution Explorer View
Implementation
Output
Q&A Session
Part III: Final Thoughts on Design Patterns
Chapter 27: Criticisms of Design Patterns
Q&A Session
Chapter 28: Anti-patterns
What Is an Anti-pattern?
Q&A Session
Chapter 29: Sealing the Leaks in Your Applications
How Garbage Collection Works
Demonstration 1
Output
Analysis
Q&A Session 1
Quiz
Quiz
Quiz
Quiz
Understanding Memory Leaks
Demonstration 2
Snapshots
Analysis
Modified Code
Snapshots
Analysis
Q&A Session 2
Chapter 30: FAQ
Appendix A: Brief Overview of GoF Design Patterns
Key Points
Q&A Session
Appendix B: Some Useful Resources
Appendix C: The Road Ahead
Index