27
Intro to Design Patterns Funu Joel

Design Patterns (by Joel Funu at DevCongress 2013)

Embed Size (px)

DESCRIPTION

A tech talk on Design Patterns delivered by Joel Funu at DevCongress 2013 on 24th August, 2013.

Citation preview

Page 1: Design Patterns (by Joel Funu at DevCongress 2013)

Intro to Design PatternsFunu Joel

Page 2: Design Patterns (by Joel Funu at DevCongress 2013)

Overview★ What design patterns are.

★ Why they are important.

★ Some OO basics and Design Principles

★ Classifications of Design Patterns

★ Examples

Page 3: Design Patterns (by Joel Funu at DevCongress 2013)

What are Design Patterns?

Page 4: Design Patterns (by Joel Funu at DevCongress 2013)

Definitions★ A pattern describes a problem which occurs over and

over again in our environment, and then describes the

core of the solution to that problem, in such a way that

you can use this solution a million times. (Alexander,

1977).

★ A design pattern is a general, reusable solution to a

common problem in software design.(gof, 1995).

Page 5: Design Patterns (by Joel Funu at DevCongress 2013)

Elements of a pattern design★ The pattern name

○ It is used to describe a design problem, its solutions and consequences in a word or two.

★ The problem○ It describes when to apply the pattern.

★ The solution○ It describes the elements that make up the design, their

relationships, responsibilities and collaborations

★ The consequences.○ the results an tradeoffs of applying the pattern

Page 6: Design Patterns (by Joel Funu at DevCongress 2013)

Why are they important?

Page 7: Design Patterns (by Joel Funu at DevCongress 2013)

Benefits of design patterns★ They provide proven solutions to software

development issues.

★ They make communications between developers more efficient.

★ They make it easier to change and maintain software.

Page 8: Design Patterns (by Joel Funu at DevCongress 2013)

Benefits of design patterns★ They prevent from wasting your time hacking

your way into a solution.

★ They shift your level of thinking to higher perspective.

★ They enable design efficient and scalable applications.

Page 9: Design Patterns (by Joel Funu at DevCongress 2013)

OO basics and design principles

Page 10: Design Patterns (by Joel Funu at DevCongress 2013)

objected oriented basics★ Abstraction

★ Encapsulation

★ Polymorphism

★ Inheritance

Page 11: Design Patterns (by Joel Funu at DevCongress 2013)

object oriented design principles★ Separate what varies from what stays the

same .

★ Favor composition over inheritance.

★ Always program to interfaces not implementations.

Page 12: Design Patterns (by Joel Funu at DevCongress 2013)

principles cont'd★ Strive for loosely coupled design between

objects.

★ Classes should be open to extension but closed for modification.(open-close principle)

Page 13: Design Patterns (by Joel Funu at DevCongress 2013)

Classifications of Design Patterns

Page 14: Design Patterns (by Joel Funu at DevCongress 2013)

Classifications★ Creational Design Patterns

★ Behavioural Design Patterns

★ Structural Design Patterns

Page 15: Design Patterns (by Joel Funu at DevCongress 2013)

Creational Patterns

“These are design patterns that deal

with object creation mechanisms.”

Page 16: Design Patterns (by Joel Funu at DevCongress 2013)

Types of creational patterns★ Factory method pattern

★ Abstract factory pattern

★ Builder pattern

★ Prototype pattern

★ Singleton pattern

Page 17: Design Patterns (by Joel Funu at DevCongress 2013)

Factory method pattern

“ ”

Page 18: Design Patterns (by Joel Funu at DevCongress 2013)

UML representation

Page 19: Design Patterns (by Joel Funu at DevCongress 2013)

Code representation

Page 20: Design Patterns (by Joel Funu at DevCongress 2013)

Behavioral Patterns

“are patterns that identify common communication patterns between objects and realize them to increase flexibility in these communication.”

Page 21: Design Patterns (by Joel Funu at DevCongress 2013)

Types of behavioral patterns★ Strategy ★ Observer ★ State ★ Command ★ Iterator ★ Mediator★ Memento ★ Template method★ Visitor

Page 22: Design Patterns (by Joel Funu at DevCongress 2013)

Strategy Pattern

“ ”

Page 23: Design Patterns (by Joel Funu at DevCongress 2013)

UML representation

Page 24: Design Patterns (by Joel Funu at DevCongress 2013)

Structural Patterns

“these are patterns that identify simple ways to realize relationships between

entities.”

Page 25: Design Patterns (by Joel Funu at DevCongress 2013)

Types of structural patterns★ Adapter

★ Bridge

★ Decorator

★ Composite

★ Facade

★ Flyweight

★ Proxy

Page 26: Design Patterns (by Joel Funu at DevCongress 2013)

Proxy Pattern

“allows you to provide an interface to other objects by creating a wrapper

class as the proxy ”

Page 27: Design Patterns (by Joel Funu at DevCongress 2013)

UML representation