Please enable JavaScript.
Coggle requires JavaScript to display documents.
The Java Design Patterns Course - Coggle Diagram
The Java Design Patterns Course
Section 1: Introduction
SOLID Design
Principals
lead to Design
Patterns
. The principals help you to write modular, cohesive and loosely coupled code.
Design Patterns: An abstraction above the level of classes/objects or components. Proven, time tested solutions to commonly recurring problems.
Gang of Four are a subset of patterns you must know
Creational
Structural
Behavioral
There are also architectural patterns as well as Framework-specific patterns.
There are
23 Gang of Four patterns
DesignPattern
{
Pattern Name:
Problem:
Solution:
Consequences:
}
Why?
They are the best solutions. Enables
software reuse.
Tried and tested.
Makes you one of the best designers out there. Design patterns are
high quality
and it improves team communication.
Abstraction at a high level like design patterns helps to
design a correct high quality design earlier and more quickly.
improves evolvability of codebase.
Some patterns are used together. Some are alternatives. Some result in similar designs with different intents.
Organize by Purpose
Creational
: process of object creation
Structural
: deal with composition of classes/objects
Behavioral
: how do classes interact and distribute responsibility
Organize by scope:
Class Patterns
: established via Inheritance
Object patterns
: estasblished via Composition
Creational Patterns
program should not depend on how objects are created and arranged
pattern provides a way to create objects.
class : defer some part of object creation to subclass
object: defer it to another object
factory, abstract factory, builder prototype, singleton
Structural Patterns
how classes and objects can be combned to form larger structures.
composite, proxy, adapter, bridge, facade,
Behavior Patterns
communication between objects
describe complex control flow through inheritance
flexibility in comunications
algorithms and responsibilities between objcets
how to segregate objects to be both dependent and independent
Design Principles -> Design Patterns.
Design Problem -> Context -> so check your toolbox of patterns for what can be applied to the context.
Start from the outside and work inward. Each pattern defines the context for the remaining patterns.
CREATIONAL
1. Factory Method
responsibility is to instantiate the objects needed by the client
use this to decouple client code from the concrete classes you need to instantiate
Concrete Creator
-the most common implementation of this pattern
use a single method with a switch , input is a String - pro : dont have eto create a subclass for each factory type
Static Factory
Abstract Creator
2. Abstract Factory Method
interface for creating FAMILIES of related objects without specifying their concrete classes
a factory of factories
create objects via abstraction (doesnt care how products are created)
USES the Factory method pattern to create the actual products
therefore it is a higher level than the factory method
use this when u have families of products to create and want to make sure theclients create products that belong together
con : need to extend interface, teherefore changes would be required in all subclasses which already implement the interface
you have a factory for each product interface
3. Singleton
4. Builder
5. Prototype