Upcoming SlideShare
×

# Itp design patterns - 2003

190 views

Published on

Published in: Design
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
190
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
3
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Itp design patterns - 2003

1. 1. 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
2. 2. 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[...])
3. 3. 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 with typeof and an appropriate cast and method call is performed.
4. 4. Design Patterns| A pattern to the rescue! Any problems here? Whats terrible about this code? Which pattern is suitable for it? Types of Patterns - Classification - GOF
5. 5. 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
6. 6. Design Patterns| Model – View - Controller Request Response nd Controller ma ta De Da Model View
7. 7. Design Patterns| Model – View - Presenter Model Demand Data Presenter View Interface View Implementation Response Request
8. 8. 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
9. 9. 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
10. 10. Design Patterns| Demo