Design Patterns

OO Concepts

Object

instance of a class where the object
can be a combination of
variables, functions, and data structures

Class

template definition of the
methods and variables in
a particular kind of object

Other

Abstraction

Polymorphism

Inheritance

Encapsulation

What?

Outline of a reusable solution to a general problem encountered in a particular context

Gang of Four

Gamma, Helm, Johnson, Vlissides

Ingredients of Making
a Design Pattern

Context
design situation giving rise to a design problem

Problem
set of forces occurring in that context

Solution
A form or rule that can be applied to resolve these forces

Pattern Template

Context
Problem
Forces
Solution
Antipatterns
Related patterns
References

Types of Design Patterns

Creational Patterns
To create objects of the right class for a problem

Abstract Factory

Builder

Prototype

Singelton

Factory(Class)

Structural Patterns
To form larger structures
from individual parts,
generally of different classes

Adapter (Class)

Adapter

Bridge

Composite

Decorator

Facade

Flyweight

Proxy

Behavioral Patterns
To describe interactions between objects

Interpreter (Class)

Template Method(Class)

Chain of Responsibility

Command

Iterator

Mediator

Memento

Observer

State

Strategy

Visitor

Anti Patterns

Viewpoints

Development AntiPatterns
Technical problems and solutions
encountered by programmers

Architectural AntiPatterns

Managerial AntiPatterns
Common problems in software
processes and development organizations

Software Refactoring

A form of code modification, used to improve the software structure in support of subsequent extension and long-term maintenance

Define a migration (or refactoring)
from negative solutions to positive solutions

Point out trouble &
a way out of it

Pattern vs Anti

Patterns

Anti-patterns

Describe desirable behavior

Describe
situations one had better avoid

Deductive Writing Process

Iterative Writing Process


Document Solution
&
Define Problem

Identify Anti Pattern
Define refactored solution
Define Anti pattern solution
Define Symptoms & Consequences

Inductive Presentation

Problem> therefore Solution

Rhetorical Presentation

Bad solutions happen>
How to prevent them?

Intention>Logically unique solution

Intention>
Awareness of situation &
alternative solutions

Two Solutions

1> problematic
generates negative consequences

2>refactored solution

mistaken solution maximizes the catastrophe

Root Causes for Anti Patterns

Haste:
Tight deadlines often lead to neglecting important activities

Apathy:
The attitude of not caring about solving known problems

Narrow-Mindedness:
Refusal of developers to learn proven solutions

Sloth:
Sloth is the “healthy sign” of a lazy developer or manager, who makes poor decisions based upon an “easy answer”: adaptation of the most simple “solution”.

Avarice:
Greed in creating a system can result in very complex, and difficult to maintain software

Ignorance:
lack of motivation to understand things

Pride:
The Failure to reuse existing software packages because they were not invented by a specific company.

AntiPattern Template

Name:

Also Known As:

Most Frequent Scale:
Where it fits in SDLM Model

Refactored Solution Name:

Refactored Solution Type:
type of improvement resulted
(Software, Technology, Process, and Role improvements)

Root Causes

Unbalanced Forces:
Ignored/Mis used/ Over used

Anecdotal Evidence
Common phrases that describe the problem

Background

General Form
characteristics

Symptoms and Consequences

Typical Causes

Known Exceptions

Refactored Solutions

Variations

An example of the AntiPattern
based on real-world experience

Related Solutions

Applicability to Other Viewpoints and Scales