tailieunhanh - Lecture note Java methods A & AB: Object-oriented programming and data structures: Chapter 26 - Maria Litvin, Gary Litvin

Chapter 26 - Design patterns. After you have mastered the material in this chapter, you will be able to explore the concept of design pattern; get familiar with six introductory design patterns: Façade, strategy, singleton, decorator, composite, MVC (Model-View-Controller). | Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Design Patterns 26- This is a brief introduction to patterns. Hundreds of design patterns have been described in books, at conferences, online, etc. Objectives: Explore the concept of design pattern Get familiar with six introductory design patterns: Façade Strategy Singleton Decorator Composite MVC (Model-View-Controller) 26- Being aware that OO design patterns exist helps you pay more attention to the design stage of your project before rushing to write code. Design Patterns Design patterns aim to provide ideas and recipes for sound OO software design. The origin of the idea can be traced to some influential books on architecture by Christopher Alexander (for example, The Timeless Way of Building, 1979). Hundreds of OO design patterns have been published since 1995 in books, web sites, etc. | Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Design Patterns 26- This is a brief introduction to patterns. Hundreds of design patterns have been described in books, at conferences, online, etc. Objectives: Explore the concept of design pattern Get familiar with six introductory design patterns: Façade Strategy Singleton Decorator Composite MVC (Model-View-Controller) 26- Being aware that OO design patterns exist helps you pay more attention to the design stage of your project before rushing to write code. Design Patterns Design patterns aim to provide ideas and recipes for sound OO software design. The origin of the idea can be traced to some influential books on architecture by Christopher Alexander (for example, The Timeless Way of Building, 1979). Hundreds of OO design patterns have been published since 1995 in books, web sites, etc. 26- The Internet gives ready access to the “pattern” community. Just Google “design patterns.” is a good place to start. Design Patterns (cont’d) A typical description of a design pattern includes: name brief statement of purpose description the types of classes and objects involved structural diagram example(s) 26- Design patterns are not specific to Java. Code examples may or may not be given. Façade Design Pattern Serves to facilitate the use of a complicated subsystem or package of classes Replaces multiple complex interfaces to several classes with one simplified interface to the whole subsystem EasySound 26- If systems and frameworks were designed with the user in mind, they would include façade classes. Façade (cont’d) Can be used to encapsulate a process that involves several steps. For example: . Rectangle ocrArea = new Rectangle(200, 20, 120, 30); ImageEditor imageEditor = new ImageEditor(); image = (image, ocrArea); TextLocator .