Docsity

Design Patterns - Principles of Software Development - Lecture Notes, Study notes of Software Engineering

Toggle sidebar
bg1
So far, we have concentrated on reusable software.
○
Adesign pattern is a reusable practice for designing
software.
○
Simply stated, a pattern is a proven way of solving
some problem.
○
So far, we've concentrated on principles that guide
practice.
○
A design pattern is a practice based upon principles.
○
Design patterns
Design Patterns
Monday, November 09, 2009
10:29 AM
Patterns Page 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Design Patterns - Principles of Software Development - Lecture Notes and more Study notes Software Engineering in PDF only on Docsity!

○ So far, we have concentrated on reusable software.

A design pattern is a reusable practice for designing

software.

Simply stated, a pattern is a proven way of solving

some problem.

So far, we've concentrated on principles that guide

practice.

○ A design pattern is a practice based upon principles.

Design patterns

Design Patterns

Monday, November 09, 2009

10:29 AM

Docsity.com

Description with blanks in it.

You "fill in the blanks" to get software.

What kinds of things fit in the blanks.

(preconditions)

What you can expect if you put them

there. (postconditions)

There is documentation on

Naïve concept of a pattern

Naïve concept of a pattern

Wednesday, September 26, 2012

4:38 PM

Docsity.com

Avoid " re-inventing the wheel ".

Leverage proven solutions.

Gain proven benefits.

Limit to known risks.

Design pattern goals:

Design pattern intentions

Monday, November 09, 2009

2:13 PM

Docsity.com

If lots of people have successfully used an approach, then

it is most likely a good approach.

○

If a few people have successfully used it, it is less

attractive and less proven.

○

The basic motivation for patterns is economy of scale.

the way they use it is likely to be free of bugs, and

that particular way is unlikely to become

deprecated.

If 1/2 of the known internet developers use a specific

library or toolkit, then

○

More specifically,

Pattern implementations gain validity by adoption.

This is a " 500 - lb gorilla " approach to choosing technological

solutions.

Economy of scale

Monday, November 09, 2009

12:01 PM

Docsity.com

A clear mission or purpose ("value proposition")

A clear method to be applied.

Proof of successful application.

Pattern essentials

Pattern essentials

Monday, November 09, 2009

2:14 PM

Docsity.com

If a large number of people have used a solution, and

They critically analyzed and understood what it did, then

You can use it and know what you'll get out of it.

Pattern "logic"

Pattern "logic"

Monday, November 09, 2009

11:13 AM

Docsity.com

○ The context: web applications

○ The problem: database interaction with web pages.

Define primitive operations on a database as

functions.

Functions are methods of a "database object" that

makes the appropriate changes to the database.

□ Create

□ Read

□ Update

□ Delete

Enabling libraries instantiate common operations: 

This is the so-called " CRUD model" of database

interaction.

○ The solution: object-relational modeling ( ORM )

Attributes of the solution: encapsulates database

operations, increases inherent portability (and ease of

porting) of solution.

Example: encapsulation as a pattern

Example 1: encapsulation as a pattern

Monday, November 09, 2009

10:37 AM

Docsity.com

The context: web applications

The problem: communication between local JavaScript

and remote server (Web 2.0).

Code information as JavaScript structures.

Web client uses client library to encode structures

as text data.

Text data is sent to server.

Server uses server library to decode data, and

encode answer.

Client receives response from server in kind.

The solution: JavaScript Object Notation ( JSON ).

Attributes of the solution: leverages existing debugged

libraries for server-client interaction, including tested

and reliable encoding and decoding. One doesn't

have to write encoding and decoding "again".

Example: algorithm as a pattern

Example 2: algorithm as a pattern

Monday, November 09, 2009

10:43 AM

Docsity.com

The context: making an application out of several

geographically distributed services.

The problem: communication between remote web

services.

Express service requests in SOAP or REST.

Express answers as XML.

Define preconditions and postconditions as

Xschemas.

The solution: Service-Oriented Architecture ( SOA )

Attributes of the solution: easier to design, decouples

parts of solution for parallel development and

maintenance, makes resulting code easier to "push into

the cloud" for economic reasons.

Example: protocol as a pattern.

Example 4: protocol as a pattern

Monday, November 09, 2009

10:52 AM

Docsity.com

Algorithmic: a proven method for solving an

algorithmic problem, e.g., greedy heuristic for traveling

salesman.

Abstraction: allow decoupling of parts of a problem to

allow independent development.

Architectural: a proven architecture for a kind of

solution, e.g., MVC for web applications; ORM for

database interactions.

Protocol: a proven method for communication

between asynchronous components.

... and many more ...

Kinds of design patterns:

Kinds of design patterns

Monday, November 09, 2009

10:56 AM

Docsity.com

defining what is done when one "visits" a node.

Docsity.com

Known limits : patterns have limitations.

Square peg; round hole : patterns can't be applied to

just any problem without thinking about it.

Not a pattern : a pattern isn't a pattern until it's

proven by practice. A "personal pattern" is an

oxymoron.

Pattern limits

Pattern limits

Monday, November 09, 2009

11:17 AM

Docsity.com

SOA: not applicable when all interaction is local (too

expensive to encode and decode)

ORM: not applicable when all database interaction is

custom (e.g., user-built queries)

MVC: not applicable when application is too simple to

gain from separation.

When is a pattern inappropriate?

A cost of adoption

A benefit from adoption

Cost must be less than value!

In general, a pattern has

Inapplicability of patterns

Monday, November 09, 2009

11:21 AM

Docsity.com

Pattern: MVC

Problem: new kind of database interaction, e.g., Amazon

S3 (scalable storage service).

Difficulty: MVC tied to existing ORM software.

"Square peg in round hole"

ignore MVC and proceed with classical web

development

craft a new ORM to plug into existing MVC.

Two approaches:

Agile solution: both.

Example of pattern inapplicability

Example of inapplicability

Monday, November 09, 2009

3:31 PM

Docsity.com