0% found this document useful (0 votes)
8 views

Design Patterns in U See Book

Uploaded by

Leonardo Hidrovo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Design Patterns in U See Book

Uploaded by

Leonardo Hidrovo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Learn the most important Design patterns

with real-life examples in C#

Dr Milan Milanovic
Microsoft MVP
Table Of Contents

What are Design Pa�erns? 3

Design Pa�ern Types 4

Don’t fall into the Design Pa�erns trap 8

Crea�onal Design Pa�erns 10

Structural Pa�erns 18

Behavioral Pa�erns 33

How To select The Correct Design Pa�ern 49

BONUS: Design Pa�erns Cheat Sheet 51

Resources to learn more 52


What are Design Pa�erns?

This book is accompanied by a live GitHub repo with all examples

3
Design Pa�ern Types

4
-

-
-

-
-

5
-

- -

6
-

- s

7
Don’t fall into the Design Pa�erns trap

Image credits (@flaviocopes on Twitter)

8
-

9
Crea�onal Design Pa�erns

Singleton

an anti-

10
11
-

Factory method

12
13
-

14
15
)

16
Other excit

Abstratct Factory:

Prototype:

17
Structural Pa�erns

Adapter

18
19
sage -

20
21
22
-

23
24
25
Decorator

26
27
28
T

Facade Pa�ern
Usage: It provides a simplified interface to a complex subsystem.

Real-world example: Let's say we are visiting a hotel. We need various services - ordering
room service, booking spa appointments, requesting housekeeping. Instead of contacting
each department individually, you call the front desk. The front desk acts as a facade, hiding
the complexity of the underlying systems. They take your request, communicate with the
relevant department (kitchen, spa, housekeeping), and deliver the service, making
everything seem effortless. You don't need to know how each department works; the facade
provides a simplified interface to access them all.

The remark about usage: Facades have the potential to transform into god objects
connected to every application class.

29
30
An example in C#

31
-
implementa�on in C#.

32
Behavioral Pa�erns

Facade Pa�ern

- -

33
34
35
Observer

sage

36
37
38
Command

39
40
41
State

It c

42
43
44
Template method

45
46
47
48
How To Select The Correct Design Pa�ern

49
check here.

50
51
Resources to learn more

-
-

52

You might also like