+ All Categories
Home > Design > Itp design patterns - 2003

Itp design patterns - 2003

Date post: 24-May-2015
Category:
Upload: shibu-s-r
View: 96 times
Download: 0 times
Share this document with a friend
Popular Tags:
12
Transcript
Page 1: Itp design patterns - 2003
Page 2: Itp design patterns - 2003

Design Patterns| What is a Pattern?

A Design Pattern is essentially a description of a commonly occurring object-oriented design problem and how to solve it

A Design Pattern is essentially a description of a commonly occurring object-oriented design problem and how to solve it

Page 3: Itp design patterns - 2003

Design Patterns| An object-oriented design problem

Imagine a system that uses a number of temperature sensors to monitor the condition of a hardware device of some sort.

The first model of the device uses Indus, Inc. TS7000 sensors.

Indus supplies a simple Java class to interface with the sensors:

class TS7000 {native double getTemp();...

}Here is some monitoring code that simply calculates the mean temperature reported by the sensors.

double sum = 0.0;for (int i = 0; i < sensors.length; i++)sum += sensors[i].getTemp();double meanTemp = sum / sensors.length;

Note that sensors is declared as an array of TS7000 objects.

(TS7000 sensors[ ] = new TS7000[...])

Imagine a system that uses a number of temperature sensors to monitor the condition of a hardware device of some sort.

The first model of the device uses Indus, Inc. TS7000 sensors.

Indus supplies a simple Java class to interface with the sensors:

class TS7000 {native double getTemp();...

}Here is some monitoring code that simply calculates the mean temperature reported by the sensors.

double sum = 0.0;for (int i = 0; i < sensors.length; i++)sum += sensors[i].getTemp();double meanTemp = sum / sensors.length;

Note that sensors is declared as an array of TS7000 objects.

(TS7000 sensors[ ] = new TS7000[...])

Page 4: Itp design patterns - 2003

Design Patterns| An object-oriented design problem

The second model of the device uses more temperature sensors and the design uses a mix of TS7000s and sensors from a new vendor, eSoft.

The eSoftsensors are SuperTemps and a hardware interfacing class is supplied:

class SuperTempReader {//// NOTE: temperature is Celsius tenths of a degree//native double current_reading();...}

Here is a terrible way to accommodate both types of sensors:for (int i = 0; i < sensors.length; i++)

{

if (sensors[i] typeof TS7000)sum += ((TS7000)sensors[i]).getTemp();else// Must be a SuperTemp!sum +=((SuperTempReader)sensors[i]).current_reading() * 10;

}In this case sensors is an array of Objects. The type is tested withtypeof and an appropriate cast and method call is performed.

The second model of the device uses more temperature sensors and the design uses a mix of TS7000s and sensors from a new vendor, eSoft.

The eSoftsensors are SuperTemps and a hardware interfacing class is supplied:

class SuperTempReader {//// NOTE: temperature is Celsius tenths of a degree//native double current_reading();...}

Here is a terrible way to accommodate both types of sensors:for (int i = 0; i < sensors.length; i++)

{

if (sensors[i] typeof TS7000)sum += ((TS7000)sensors[i]).getTemp();else// Must be a SuperTemp!sum +=((SuperTempReader)sensors[i]).current_reading() * 10;

}In this case sensors is an array of Objects. The type is tested withtypeof and an appropriate cast and method call is performed.

Page 5: Itp design patterns - 2003

Design Patterns| A pattern to the rescue!

Any problems here?

What's terrible about this code?

Which pattern is suitable for it?

Types of Patterns- Classification- GOF

Any problems here?

What's terrible about this code?

Which pattern is suitable for it?

Types of Patterns- Classification- GOF

Page 6: Itp design patterns - 2003

Design Patterns| Patterns for Web application development

Web development Issues- automated testing- UI are hard to test- Changing nature of web- Frequent changes in UI Design

How to solve this issue?- Separate UI and Business Objects

MVC- Model View Controller

MVP- Model View Presenter

Web development Issues- automated testing- UI are hard to test- Changing nature of web- Frequent changes in UI Design

How to solve this issue?- Separate UI and Business Objects

MVC- Model View Controller

MVP- Model View Presenter

Page 7: Itp design patterns - 2003

Design Patterns| Model – View - Controller

Controller

Model View

Deman

d

Data

Response

Request

Page 8: Itp design patterns - 2003

Design Patterns| Model – View - Presenter

Presenter

Model

View Implementation

Dem

and

Dat

a

ResponseRequ

est

View Interface

Page 9: Itp design patterns - 2003

Design Patterns| ASP.NET MVC 3

A part of the ASP.NET Web application framework

It enables clean separation of concerns, testability, and TDD by default

It is highly extensible and pluggable

A part of the ASP.NET Web application framework

It enables clean separation of concerns, testability, and TDD by default

It is highly extensible and pluggable

Page 10: Itp design patterns - 2003

Design Patterns| Web Client Software Factory

Quickly incorporate many of the proven practices and patterns of building Web client applications

Provides proven solutions to common challenges found while building and operating large transaction processing enterprise Web sites

Support for the Model-View-Presenter pattern

Contains a collection of reusable components and libraries, Visual Studio 2005 and Visual Studio 2008 solution templates, wizards and extensions, How-to topics, automated tests, extensive architecture documentation, patterns, and a reference implementation

Quickly incorporate many of the proven practices and patterns of building Web client applications

Provides proven solutions to common challenges found while building and operating large transaction processing enterprise Web sites

Support for the Model-View-Presenter pattern

Contains a collection of reusable components and libraries, Visual Studio 2005 and Visual Studio 2008 solution templates, wizards and extensions, How-to topics, automated tests, extensive architecture documentation, patterns, and a reference implementation

Page 11: Itp design patterns - 2003

Design Patterns| Demo

Page 12: Itp design patterns - 2003

Recommended