Slide 1

Slide 1 text

Austin Morris [email protected] austinsmorris An Introduction to Design Patterns

Slide 2

Slide 2 text

(1977) In the beginning...

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

(1995) Let there be light…

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

What is a design pattern?

Slide 7

Slide 7 text

1.) Repeated problem What is a design pattern?

Slide 8

Slide 8 text

1.) Repeated problem 2.) Reusable solution What is a design pattern?

Slide 9

Slide 9 text

1.) Repeated problem 2.) Reusable solution 3.) Name What is a design pattern?

Slide 10

Slide 10 text

1.) Repeated problem 2.) Reusable solution 3.) Name 4.) Set of consequences What is a design pattern?

Slide 11

Slide 11 text

Why do we use design patterns?

Slide 12

Slide 12 text

Because the one constant in software development is change. Why do we use design patterns?

Slide 13

Slide 13 text

Because somebody has already solved your problem. Why do we use design patterns?

Slide 14

Slide 14 text

Because you don’t remember that thing you did that one time when the other stuff didn’t work. Why do we use design patterns?

Slide 15

Slide 15 text

Because we have to make trade-offs. Why do we use design patterns?

Slide 16

Slide 16 text

What are the design patterns?

Slide 17

Slide 17 text

GOF published 23 “original” design patterns. Then:

Slide 18

Slide 18 text

● Abstract Factory ● Builder ● Factory Method ● Prototype ● Singleton ● Adapter ● Bridge ● Composite ● Decorator ● Facade ● Flyweight ● Proxy ● Chain of Responsibility ● Command ● Interpreter ● Iterator ● Mediator ● Memento ● Observer ● State ● Strategy ● Template Method ● Visitor

Slide 19

Slide 19 text

(All the design patterns I could find in ten minutes plus the time it took to type them.) Now:

Slide 20

Slide 20 text

Abstract Client, Abstract Factory, Abstract Server, Action, Active Object, Active Record, Adapter, Application Controller, Association Table Mapping, Balking, Binding Properties, Bridge, Builder, Caretaker, Chain Of Responsibility, Class Table Inheritance, Client Session State, Coarse-Grained Lock, Concrete Table Inheritance, Command, Composite, Cursor, Data Bus, Data Mapper, Data Transfer Object, Database Session State, Decorator, Dependent Mapping, Dependents, Disable Job Request While Running Job, Domain Model, Double Checked Locking, Dynamic User Interface, Embedded Value, Event Based Asynchronous, Facade, Facet, Factory Method, Flyweight, Foreign Key Mapping, Front Controller, Gateway, Guarded Suspension, Handle Body, Hierarchical Visitor, Identity Field, Identity Map, Implicit Lock, Inheritance Mappers, Interface Segregation Principle, Interpreter, Iterator, Join, Kit, Layer Supertype, Lazy Instantiation, Lazy Load, Lock, Mapper, Mediator, Memento, Messaging, Metadata Mapping, Mock Object, Model View Controller, Module, Money, Monitor, Monostate, Multiton, Null Object, Object Pool, Observer, Optimistic Offline Lock, Page Controller, Pessimistic Offline Lock, Plugin, Policy, Prototype, Proxy, Publish Subscribe, Pub Sub, Query Object, Reactor, Read Write Lock, Record Set, Registry, Remote Facade, Repository, Resource Acquisition is Initialization, Row Data Gateway, Scheduled Task, Scheduler, Separated Interface, Serialized Large Object, Server Session State, Servant, Service Layer, Service Locator, Service Stub, Single Table Inheritance, Singleton, Special Case, Specification, State, States, Static User Interface, Strategy, Surrogate, Table Data Gateway, Table Module, Template Method, Template View, Thread Pool, Thread Specific Storage, Token, Transaction, Transaction Script, Transfold, Transform View, Translator, Two Step View, Unit of Work, Value Object, Virtual Constructor, Visitor, Wrapper

Slide 21

Slide 21 text

“Original” Design Pattern Categories

Slide 22

Slide 22 text

“... abstract the instantiation process... make a system independent of how its objects are created, composed, and represented.” Creational

Slide 23

Slide 23 text

● Abstract Factory ● Builder ● Factory Method ● Prototype ● Singleton ● Adapter ● Bridge ● Composite ● Decorator ● Facade ● Flyweight ● Proxy ● Chain of Responsibility ● Command ● Interpreter ● Iterator ● Mediator ● Memento ● Observer ● State ● Strategy ● Template Method ● Visitor

Slide 24

Slide 24 text

“...concerned with how classes and objects are composed to form larger structures.” Structural

Slide 25

Slide 25 text

● Abstract Factory ● Builder ● Factory Method ● Prototype ● Singleton ● Adapter ● Bridge ● Composite ● Decorator ● Facade ● Flyweight ● Proxy ● Chain of Responsibility ● Command ● Interpreter ● Iterator ● Mediator ● Memento ● Observer ● State ● Strategy ● Template Method ● Visitor

Slide 26

Slide 26 text

“...concerned with algorithms and the assignment of responsibility between objects… shift focus of flow of control to the way objects are interconnected.” Behavioral

Slide 27

Slide 27 text

● Abstract Factory ● Builder ● Factory Method ● Prototype ● Singleton ● Adapter ● Bridge ● Composite ● Decorator ● Facade ● Flyweight ● Proxy ● Chain of Responsibility ● Command ● Interpreter ● Iterator ● Mediator ● Memento ● Observer ● State ● Strategy ● Template Method ● Visitor

Slide 28

Slide 28 text

Design patterns are not:

Slide 29

Slide 29 text

Invented.

Slide 30

Slide 30 text

Invented. Design patterns are discovered through repeated application to generic problems.

Slide 31

Slide 31 text

Design patterns are not:

Slide 32

Slide 32 text

The end goal.

Slide 33

Slide 33 text

They are the means to an end. The end goal.

Slide 34

Slide 34 text

Design patterns are not:

Slide 35

Slide 35 text

Design principles.

Slide 36

Slide 36 text

Design patterns allow you to apply good design principles. Design principles.

Slide 37

Slide 37 text

In this case, interface means abstraction. “Program to an interface, not an implementation.”

Slide 38

Slide 38 text

Abstract Factory - use an interface to create objects. The type is determined at runtime. “Program to an interface, not an implementation.”

Slide 39

Slide 39 text

Adapter - convert an existing interface into one that a client expects. “Program to an interface, not an implementation.”

Slide 40

Slide 40 text

Template Method - Define a skeleton algorithm that subclasses implement. “Program to an interface, not an implementation.”

Slide 41

Slide 41 text

Has-a is “better” than Is-a. “Favor object composition over class inheritance.”

Slide 42

Slide 42 text

Composite - has objects in a hierarchy. “Favor object composition over class inheritance.”

Slide 43

Slide 43 text

Strategy - an object has a variable behavior. “Favor object composition over class inheritance.”

Slide 44

Slide 44 text

Iterator - has objects that it iterates through. “Favor object composition over class inheritance.”

Slide 45

Slide 45 text

Single Responsibility Principle Open/Closed Principle Liskov Substitution Principle. Interface Segregation Principle Dependency Inversion Principle S.O.L.I.D.

Slide 46

Slide 46 text

Abstract Client, Abstract Factory, Abstract Server, Action, Active Object, Active Record, Adapter, Application Controller, Association Table Mapping, Balking, Binding Properties, Bridge, Builder, Caretaker, Chain Of Responsibility, Class Table Inheritance, Client Session State, Coarse-Grained Lock, Concrete Table Inheritance, Command, Composite, Cursor, Data Bus, Data Mapper, Data Transfer Object, Database Session State, Decorator, Dependent Mapping, Dependents, Disable Job Request While Running Job, Domain Model, Double Checked Locking, Dynamic User Interface, Embedded Value, Event Based Asynchronous, Facade, Facet, Factory Method, Flyweight, Foreign Key Mapping, Front Controller, Gateway, Guarded Suspension, Handle Body, Hierarchical Visitor, Identity Field, Identity Map, Implicit Lock, Inheritance Mappers, Interface Segregation Principle, Interpreter, Iterator, Join, Kit, Layer Supertype, Lazy Instantiation, Lazy Load, Lock, Mapper, Mediator, Memento, Messaging, Metadata Mapping, Mock Object, Model View Controller, Module, Money, Monitor, Monostate, Multiton, Null Object, Object Pool, Observer, Optimistic Offline Lock, Page Controller, Pessimistic Offline Lock, Plugin, Policy, Prototype, Proxy, Publish Subscribe, Pub Sub, Query Object, Reactor, Read Write Lock, Record Set, Registry, Remote Facade, Repository, Resource Acquisition is Initialization, Row Data Gateway, Scheduled Task, Scheduler, Separated Interface, Serialized Large Object, Server Session State, Servant, Service Layer, Service Locator, Service Stub, Single Table Inheritance, Singleton, Special Case, Specification, State, States, Static User Interface, Strategy, Surrogate, Table Data Gateway, Table Module, Template Method, Template View, Thread Pool, Thread Specific Storage, Token, Transaction, Transaction Script, Transfold, Transform View, Translator, Two Step View, Unit of Work, Value Object, Virtual Constructor, Visitor, Wrapper

Slide 47

Slide 47 text

How can I learn more?

Slide 48

Slide 48 text

How can I learn more? 1.) Collect buzzwords.

Slide 49

Slide 49 text

How can I learn more? 1.) Collect buzzwords. 2.) Connect buzzwords.

Slide 50

Slide 50 text

How can I learn more? 1.) Collect buzzwords. 2.) Connect buzzwords. 3.) Write code.

Slide 51

Slide 51 text

Recommended Reading

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

Austin’s Opinion: Mandatory reference for anybody who wants to incorporate design patterns in their software.

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

Austin’s Opinion: Mandatory reading for anybody who wants to write great software. Talks about patterns for domain modeling.

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

Austin’s Opinion: Optional reading - If you are already using a good framework/ORM, you are already using most of these patterns.

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Austin’s Opinion: A great, easy-reading alternative to textbook-style books. Recommended by original GOF authors.

Slide 60

Slide 60 text

Questions? [email protected]