DOC PREVIEW
Toronto ECE 450 - Topics on Design Patterns Lecture Notes

This preview shows page 1-2-21-22 out of 22 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lecture 4 Topics on Design Patterns Copyright Yijun Yu 2005 Spring 2005 ECE450H1S Software Engineering II Last tutorial OpenOME a requirements engineering tool We explained the requirements design and implementation of the tool We also pointed out how to contribute to the tool After the tutorial I posted the source code to the Sourceforge You can download the branch ECE450 v1 from the CVS you can also download the packed SDK The design of OpenOME has used some design patterns such as Observer MVC Visitor Command Hope you can smell right places to apply the design patterns after the lecture Spring 2005 ECE450H1S Software Engineering II Last lecture Reengineering Engineering Goal oriented requirements engineering leads to a better understanding of quality Design Patterns can be considered as the operationalization of the quality improvements Two papers in the literature link requirements with patterns Ladan Tahvildari Kostas Kontogiannis Improving design quality using meta pattern transformations a metric based approach Journal of Software Maintenance 16 4 5 331 361 2004 Ladan Tahvildari Kostas Kontogiannis John Mylopoulos Qualitydriven software re engineering Journal of Systems and Software 66 3 225 239 2003 Spring 2005 ECE450H1S Software Engineering II Today Topics on Design Patterns 1 2 3 4 5 6 What are design patterns How are they classified How to apply design patterns How to identify design patterns Which qualities are related to the design patterns Summary Reference The Gang of Four book Erich Gamma Richard Helm Ralph Johnson John Vlissides Design Patterns Elements of Reusable Object Oriented Software 1995 Spring 2005 ECE450H1S Software Engineering II 1 What are design patterns What are the patterns Patterns in the textile cloths tiles Patterns in visualizations It is a recurring phenomenon Y Yu K Beyls and E H D Hollander Visualizing the impact of the cache on program execution In Proceedings of Fifth International Conference on Information Visualization pages 336 341 London England July 2001 IEEE Computer Society Spring 2005 ECE450H1S Software Engineering II Patterns in cache behaviour Spring 2005 ECE450H1S Software Engineering II Patterns in Design Architect Christopher Alexander A Pattern Language and A Timeless Way of Building Hanchow China Spring 2005 Pisa tower Pisa Italy ECE450H1S Eiffel tower Paris France CN Tower Toronto Canada Software Engineering II Pearl Tower Shanghai China Design Patterns Design patterns are devices that allow programs to share knowledge about their design It is reusable when the same kind of problem reoccur When there are many reusable patterns they must be classified in a common language to effectively apply the pattern to similar problems again Spring 2005 ECE450H1S Software Engineering II 2 Catalogue of design patterns Creational Abstract Factory Builder Factory Lazy Initialization Prototype Singleton etc Structural Adapter Bridge Composite Container Decorator Delegation Extensibility Fa ade Flyweight Interface Pipes and filters Proxy etc Behavioural Chain of Responsibility Command Event Listener Immutable Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor etc Spring 2005 ECE450H1S Software Engineering II A pattern language Pattern language the pattern of patterns provides a template for patterns The motivation or context that this pattern applies to Prerequisites that should be satisfied before deciding to use a pattern A description of the program structure that the pattern will define A list of the participants needed to complete a pattern Consequences of using the pattern both positive and negative Examples Spring 2005 ECE450H1S Software Engineering II The GOF pattern language Pattern Name and Classification Every pattern should have a descriptive and unique name that helps in identifying and referring to it Additionally the pattern should be classified according to a classification such as the one described earlier This classification helps in identifying the use of the pattern Intent This section should describe the goal behind the pattern and the reason for using it It resembles the problem part of the pattern Also Known As A pattern could have more than one name These names should be documented in this section Motivation This section provides a scenario consisting of a problem and a context in which this pattern can be used By relating the problem and the context this section shows when this pattern is used Applicability This section includes situations in which this pattern is usable It represents the context part of the pattern Structure A graphical representation of the pattern Class diagrams and Interaction diagrams can be used for this purpose Participants A listing of the classes and objects used in this pattern and their roles in the design Collaboration Describes how classes and objects used in the pattern interact with each other Consequences This section describes the results side effects and trade offs caused by using this pattern Implementation This section describes the implementation of the pattern and represents the solution part of the pattern It provides the techniques used in implementing this pattern and suggests ways for this implementation Sample Code An illustration of how this pattern can be used in a programming language Known Uses This section includes examples of real usages of this pattern Related Patterns This section includes other patterns that have some relation with this pattern so that they can be used along with this pattern or instead of this pattern It also includes the differences this pattern has with similar patterns Spring 2005 ECE450H1S Software Engineering II 3 How to apply design patterns Example Factory method Constructing objects based on some input such that functions inside the objects depend upon the input Consider as an example a class to read image files and make thumbnails out of them A bad example An improved one The Use of the pattern Spring 2005 ECE450H1S Software Engineering II 1 public class ImageReader 2 private int fileType 3 private String fileContents 4 private byte decodedImage 5 public ImageReader InputStream in 6 Figure out what type of file this input stream represents 7 eg gif jpeg png tif etc 8 this fileType fileType 9 decodeFile 10 11 private void decodeFile 12 switch fileType 13 case ImageReader GIF 14 do gif decoding many lines 15 break 16 case ImageReader JPEG 17 do jpeg decoding many lines 18 break 19 case ImageReader PNG 20


View Full Document
Download Topics on Design Patterns Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Topics on Design Patterns Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Topics on Design Patterns Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?