Software Development Summary
Design Patterns
- Provide general reusable solutions to one type of problem during software development,
provide an architecture
o Develop classes, interfaces, relationships, inheritance hierarchies
o Design must be specific to problem but flexible to reuse
o Recommended use of existing design patterns by experienced OO programmers –
avoid reinventing the wheel, experience, not code reuse (add to repository)
OO design principles
o Identify aspects of application that vary + stay same
o Program to interface (supertype/abstract class, by exploiting polymorphism), not
implementation
o Favour ‘object composition’ over class inheritance – more flexible, change
behaviour/object at runtime
o Open/close principle – classes open for extension, closed for modification
o Dependency inversion principle – depend upon abstractions, not concrete classes
o Polymorphism – code working with an interface can work with other classes
implementing interface instead of programming to concrete example making
codebase susceptible to change
- Creational – abstraction of instantiation process
o Factory o Abstract o Prototype
factory o Builder
o Singleton
- Structural – composition of classes + objects
o Adapter o Decorator o Proxy
o Bridge o Façade
o Composite o Flyweight
- Behavioural – interactions between objects
o Chain of o Iterator o State
responsibili o Mediator o Strategy
ty o Memento o Template
o Command o Observer o Visitor
o Interpreter
,Software Development Summary
Factory pattern
- Defines interface for creating object, lets subclasses decide which class to instantiate, lets
class defer instantiation to subclasses
- Varying argument to shop constructors
-
- createPizza() – abstract method
- Creator – abstract class
- Concrete classes – extend creator, provide concrete implementation of factory method
(often parameterised)
- Uses inheritance (extends class + overrides factory methods), gives complete object in one
shot
Abstract factory pattern
o Uses composition (defines abstract type for creating family of products + lets
subclasses decide how produces) + returns family of related classes
o Provides interface for creating families of related/dependent objects without
specifying concrete classes
o Decouples code from factory
o Reduces dependencies on concrete classes
o Useful when creating multiple families of one product/ providing library of products
without exposing details
, Software Development Summary
Builder pattern
o Encapsulates product, can be built in steps
o Separates construction of a complex object from its representation so construction
processes can create different representations
o Exposes attributes, hides how to set them
o
o Builder – specifies interface for creating parts of complex object
o ConcreteBuilder – objects of create and assemble parts making up the Product
through Builder interface
o Director – object responsible for construction of complex object, delegates actual
creation and assembly to Builder interface
o Product – complex object created by ConcreteBuilder objects, consists of multiple
parts of these
o Advantages:
Encapsulates way constructed
Allows object construction in mutli-step and varying process
Hides internal representation from client
Design Patterns
- Provide general reusable solutions to one type of problem during software development,
provide an architecture
o Develop classes, interfaces, relationships, inheritance hierarchies
o Design must be specific to problem but flexible to reuse
o Recommended use of existing design patterns by experienced OO programmers –
avoid reinventing the wheel, experience, not code reuse (add to repository)
OO design principles
o Identify aspects of application that vary + stay same
o Program to interface (supertype/abstract class, by exploiting polymorphism), not
implementation
o Favour ‘object composition’ over class inheritance – more flexible, change
behaviour/object at runtime
o Open/close principle – classes open for extension, closed for modification
o Dependency inversion principle – depend upon abstractions, not concrete classes
o Polymorphism – code working with an interface can work with other classes
implementing interface instead of programming to concrete example making
codebase susceptible to change
- Creational – abstraction of instantiation process
o Factory o Abstract o Prototype
factory o Builder
o Singleton
- Structural – composition of classes + objects
o Adapter o Decorator o Proxy
o Bridge o Façade
o Composite o Flyweight
- Behavioural – interactions between objects
o Chain of o Iterator o State
responsibili o Mediator o Strategy
ty o Memento o Template
o Command o Observer o Visitor
o Interpreter
,Software Development Summary
Factory pattern
- Defines interface for creating object, lets subclasses decide which class to instantiate, lets
class defer instantiation to subclasses
- Varying argument to shop constructors
-
- createPizza() – abstract method
- Creator – abstract class
- Concrete classes – extend creator, provide concrete implementation of factory method
(often parameterised)
- Uses inheritance (extends class + overrides factory methods), gives complete object in one
shot
Abstract factory pattern
o Uses composition (defines abstract type for creating family of products + lets
subclasses decide how produces) + returns family of related classes
o Provides interface for creating families of related/dependent objects without
specifying concrete classes
o Decouples code from factory
o Reduces dependencies on concrete classes
o Useful when creating multiple families of one product/ providing library of products
without exposing details
, Software Development Summary
Builder pattern
o Encapsulates product, can be built in steps
o Separates construction of a complex object from its representation so construction
processes can create different representations
o Exposes attributes, hides how to set them
o
o Builder – specifies interface for creating parts of complex object
o ConcreteBuilder – objects of create and assemble parts making up the Product
through Builder interface
o Director – object responsible for construction of complex object, delegates actual
creation and assembly to Builder interface
o Product – complex object created by ConcreteBuilder objects, consists of multiple
parts of these
o Advantages:
Encapsulates way constructed
Allows object construction in mutli-step and varying process
Hides internal representation from client