1 / 49

Generative Design Pattern

Generative Design Pattern. Source : 17th IEEE International Conference on Automated Software Engineering, Edinburgh, U.K., September 23-27, 2002. Author : S. MacDonald, D. Szafron, J.Schaeffer, J. Anvik, S. Bromling and K. Tan

osmond
Télécharger la présentation

Generative Design Pattern

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Generative Design Pattern Source :17th IEEE International Conference on Automated Software Engineering, Edinburgh, U.K., September 23-27, 2002. Author:S. MacDonald, D. Szafron, J.Schaeffer, J. Anvik, S. Bromling and K. Tan Student: Chih-Kun Chang Advisor: Ku-Yaw Chang

  2. Outline • Introduction • Design pattern adaptation • Constructing generative patterns • Generative pattern representation • Summary Generative Design Pattern

  3. Introduction • Generative Design Pattern 介紹 • Composite Pattern 介紹 • CO2P2S 簡介及實作 Generative Design Pattern

  4. Question 1. • Why design patterns are not used as generative constructs that support code re-use ? Ans. 1. It is difficult to generate a single body of code that adequately solves each problem in the family. 2. It is difficult to construct and edit generative design patterns. 3. Lack of a tool-independent representation • CO2P2S (Correct Object-Oriented Pattern-based Programming System ) • Meta-CO2P2S Generative Design Pattern

  5. Question 2. • It would be beneficial to use generative design patterns that generative code , why ? 1. They reduce implementation time , are less prone to programmer error. 2. Promote rapid prototyping and code reuse. 3. Support performance tuning. 4. Provide better overall software engineering benefits. Generative Design Pattern

  6. Introduction • Generative design pattern problems • Parameterized design patterns Generative Design Pattern

  7. Introduction • Generative design pattern problems • When to code generation before adaptation (AOP) during adaptation (better) after adaptation (Framework) AOP – Aspect-Oriented Programming Generative Design Pattern

  8. Introduction • before adaptation • It is very difficult to generate code before adaptation that is general for all of the problems the pattern is designed to solve. • If this problem could be solved , the code would often be too complex and often too generic to achieve good performance. Generative Design Pattern

  9. Introduction • after adaptation • The pattern quickly gathers application-specific characteristics • The generated code is only applicable to applications similar to our graphics application. Generative Design Pattern

  10. Introduction • during adaptation • an arbitrary number of adaptation and code generation cycles. • Simplest process that provides usable results. • The initial adaptation phase • The code generation phase • The final adaptation phase Generative Design Pattern

  11. Introduction • Parameterized design patterns • Published descriptive design patterns include : 1. lists of participants (關係者) 2. implementation issues (成就發佈) 3. sample code. However, they are not sufficient for generative design patterns. Generative Design Pattern

  12. Introduction • Parameterized design patterns • Each descriptive design pattern is transformed into a generative design pattern using quantitative parameters with specific domains. • The parameters can be classified into a few distinct types. Generative Design Pattern

  13. Introduction • The complete process takes three steps. Step1. the user selects an appropriate generative design pattern from a set of supported patterns. Step2. the user adapts this pattern for their application by providing parameter values. Step3. the adapted generative pattern is used to create object-oriented framework code for the chosen pattern structure. Generative Design Pattern

  14. Introduction • Patterns to frameworks to applications. The specialization flow, from generative design pattern to final application code. Generative Design Pattern

  15. Outline • Introduction • Design pattern adaptation • Constructing generative patterns • Generative pattern representation • Summary Generative Design Pattern

  16. Composite pattern • Composite pattern. “Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. • 將對象組合成樹狀結構以表示“部分-整體”的層次結構。Composite模式使得使用者對單個對象和组合對象的使用具一致性。 Generative Design Pattern

  17. The Composite design pattern • Perhaps the leaf classes are Line and Circle • the composite classes are Group (an arbitrary collection of other components) and Quadrilateral (a specific collection of four lines) Generative Design Pattern

  18. The Composite design pattern • 算術式包括數字、操作符號和另一個數字。操作數可以是數字,也可以是另一個表述式。例如,2+3 和(2+3)+(4*6)都是合法的表述式。 Generative Design Pattern

  19. Design pattern adaptation • Parameters for the Composite pattern • Tool support for setting parameters Generative Design Pattern

  20. Design pattern adaptation • The Composite design pattern has seven parameters 1.(lexical) component name. The name for the abstract component class. 2.(lexical) composite name. Thename for the abstract composit class. 3.(lexical) leaf name. The name for the abstract leaf class in the generated framework. 4.(lexical) superclass name. A name for the pattern superclass. 5.(design) safe-transparent. The location of the child management operations. 6.(design) operation list. A traversal list. 7.(performance) containers. The types of containers used. Generative Design Pattern

  21. Design pattern adaptation • seven parameters • component name , composite name , leaf name user controls • Superclass name java  If no superclass is required , the user can enterObject. C++  target language , an empty superclass name could be used. Generative Design Pattern

  22. Design pattern adaptation • seven parameters -- safe-transparent • Has parameter type Enumeration. • two value :safeandtransparent. • If the safe value is selected , the child management operations are generated in the composite class. • If the transparent value is selected , the child management operations are generated in the component class. Generative Design Pattern

  23. Design pattern adaptation • seven parameters – operation-list • Has parameter type List- a List parameter is a list of parameters of arbitrary type. • Has type Structure – has three sub-parameters. • Operation signature – has type Method Signature. Example draw( ). • Prefix – 先畫背景再畫前景 • Suffix – include all of the parameters of the operation method that calls it . Generative Design Pattern

  24. Design pattern adaptation • seven parameters – containers • The containers parameter is the only performance parameter of the Composite pattern. • Has type Dictionary. It supports an arbitrary number of abstract composite classes, with different names and implementations. • Each key in this Dictionary is an Enumeration value from : { vector , array, list , hash table, two children, three children, four children } Ex. ListComposit to support Group and FourComposite to support Quadrilateral Generative Design Pattern

  25. Design pattern adaptation • Parameters for the Composite pattern • Tool support for setting parameters Generative Design Pattern

  26. Tool support for setting parameters Generative Design Pattern

  27. Tool support for setting parameters • CO2P3S (Correct Object-Oriented Pattern-based Parallel Programming System) combines design patterns and object-oriented frameworks into a process for writing high-performance object-oriented programs that execute on multiple processors Generative Design Pattern

  28. Tool support for setting parameters • Operating systems: • Linux • Solaris • SGI Irix • Other System Requirements • A Java distribution, Version 1.2 or higher. • A Perl distribution, Version 5 or higher • Any version of GNU make • An active network connection. Generative Design Pattern

  29. Outline • Introduction • Design pattern adaptation • Constructing generative patterns • Generative pattern representation • Summary Generative Design Pattern

  30. Constructing generative patterns • Generative pattern parameter types • Framework generation • Using Javadoc for code generation • Tool support Meta-CO2P2S Generative Design Pattern

  31. Generative pattern parameter types • Generative pattern parameters allow a pattern designer to customize a pattern and alter the framework code that it generates. There are three basic parameter types. • String – simple legal string value • Enumeration – fixed set of values • List – handles the common situation where the pattern user supplies a list of other parameters, which may be of any type. Generative Design Pattern

  32. Generative pattern parameter types The specialization hierarchy for parameter types. Generative Design Pattern

  33. Generative pattern parameter types • Identifier – has a value that is any legal identifier in the target programming language. • Class Name – is included in each generative pattern. • Method Name – represents the name of a method. • Boolean – is a special case of Enumeration, where the legal values are true and false. • Structure – deals with the common case where a parameter consists of a fixed number of sub-parameters. • Method Signature – specifies the name , return type and argument types of a method. • Dictionary – maps keys to values for the code generator. This is particularly useful for multiple selection parameters. • Extended – supports the case where the parameter values have an arbitrary form. Such as a way for the pattern user to supply the parameter value and how different values affect the generated code. Generative Design Pattern

  34. Constructing generative patterns • Generative pattern parameter types • Framework generation • Using Javadoc for code generation • Tool support Meta-CO2P2S Generative Design Pattern

  35. Framework generation • String parameter is represented by a String Placeholder in the source code template. • Enumeration parameter is represented by a Guard Variable that can be assigned one value from the domain of the Enumeration parameter. Generative Design Pattern

  36. Framework generation • List parameter is represented in the code by a List Placeholder that indicates its location. • Extend parameter has no fixed transformation technique for code generation. An Extended Placeholder marks its location in the code template. Generative Design Pattern

  37. Constructing generative patterns • Generative pattern parameter types • Framework generation • Using Javadoc for code generation • Tool support Meta-CO2P2S Generative Design Pattern

  38. Using Javadoc for code generation • Javadoc is a tool whose original purpose was to generate HTML formatted API documentation for Java classes. Generative Design Pattern

  39. Constructing generative patterns • Generative pattern parameter types • Framework generation • Using Javadoc for code generation • Tool support Meta-CO2P2S Generative Design Pattern

  40. Tool support Meta-CO2P2S • Meta-CO2P2S bundles the parameter information and GUI attributes together and stores the information in a file with standard XML format . Generative Design Pattern

  41. Outline • Introduction • Design pattern adaptation • Constructing generative patterns • Generative pattern representation • Summary Generative Design Pattern

  42. Generative pattern representation • Pattern parameter representation • Uses XML format • Automating parameter value entry • A String parameter can be entered in a standard dialog box with a single text field. • An Enumeration parameter is entered by a set of labels or graphical images and associated radio buttons. • A List parameter uses a list pane , and buttons for adding and removing elements. Generative Design Pattern

  43. Generative pattern representation • Framework representation • Code generator is based on Javadoc. • It is possible to create a library of these reusable behavioral components to support parameter sharing between patterns. Generative Design Pattern

  44. Outline • Introduction • Design pattern adaptation • Constructing generative patterns • Generative pattern representation • Summary Generative Design Pattern

  45. Summary • Three new ideas: • Generative design patterns are defined by a set of typed parameters with specific legal values and a code template that generates frameworks whose structure depends on combinations of values for these parameters • Design pattern adaptation is a three-phase process • First phase involves parameter value selection • Second phase involves framework code generation • Third phase involves framework specialization. • A two part tool-independent representation of generative design patterns consists of an XML-based representation of pattern parameter values and a code template with simple parameter-based annotations. Generative Design Pattern

  46. Summary • CO2P2S currently supports • Six design patterns for parallel computing: mesh, wavefront, pipeline, search-tree, distributor and phases. • Sequential patterns: composite, decorator, abstract factory, chain (tree) of responsibility and observer. Generative Design Pattern

  47. Summary • Generative design pattern to write an application, follows four steps: ( programmer ) • Pick an appropriate set of design patterns. • Use a tool like CO2P2S to adapt design patterns to an application by selecting values for the pattern parameters. • Press a button to generate frameworks for each design pattern that has been customized for your application. • Use framework specialization to finish the application. Generative Design Pattern

  48. Summary • To create a new generative design pattern, follows four steps: ( designer) • Find an existing descriptive design pattern that applies or create a new descriptive design pattern. • Study existing generative design patterns for similar issues and parameterization requirements. • determine the legal parameter values by considering the necessary parameter values for your application and the known uses section of the pattern documentation • Use other generative design patterns to guide you, or if possible, edit an existing generative design pattern to take advantage of the code template that has already been written. Generative Design Pattern

  49. Thank you! Generative Design Pattern

More Related