340 likes | 474 Views
GROUP #. 13. Code Generation with Design Patterns. THIS PRESENTATION DIFFERENT. WHAT’S ANNOYING ABOUT DESIGN PATTERNS?. HOW WE CAN ADDRESS THIS!. WHAT IS NOT FUN ABOUT DESIGN PATTERNS?. HAVING TO CODE THEM OVER AND OVER!!. ALL THE “MONKEY BUSINESS”!!!!. pretty much same code over
E N D
GROUP # 13
Code Generation with Design Patterns
THIS PRESENTATION DIFFERENT WHAT’S ANNOYING ABOUT DESIGN PATTERNS? HOW WE CAN ADDRESS THIS!
WHAT IS NOT FUN ABOUT DESIGN PATTERNS? HAVING TO CODE THEM OVER AND OVER!!
ALL THE “MONKEY BUSINESS”!!!! pretty much same code over and over names change key principles don’t NO MORE MONKEY BUSINESS!!!!!* * may not eliminate all monkey business
What are Design Patterns • Capture expertise • Proven, general solution • Rationale • Implementation freedom • Deeper understanding • Names form a vocabulary
Representing Design Patterns • How can we represent design patterns to aid in code generation? • Must learn how to: • Discover and recognize them • Represent and apply them
Design Pattern Format 1. Name 2. Intent 3. Also Known As 4. Motivation 5. Applicability 6. Structure 7. Participants
Design Pattern Format 8. Collaborations 9. Consequences 10. Implementation 11. Sample Code 12. Known Uses 13. Related Patterns
Problems with Design Patterns • Pattern writing takes time • Most examples are in Smalltalk or C++ • They are not code Patterns don't generate anything —people do!
Why are Design Patterns important? • Communicate design knowledge • Build consensus • Promote thought rather than action • Work with awareness • Allow potential for design re-use
Automatic Code Generation • Motivations • Steps for automatic code generation • Section Pages • Code Generation Page • Generating Declarations • Choosing Trade-offs • Other Generation Options
Motivations • design pattern describes the system but does not provide any code • Want a tool to translate design patterns into useful code • The automatic code generation tool will create all the declarations and definitions from the design pattern for the code
Steps for Automatic Code Generation with the Tool • Section Pages • Code Generation Page • Generating Declarations • Choosing Trade-offs • Other Options
Section pages • Tool will display the design patterns in different pages • Intent section: describes the purpose of the design pattern • Motivation section: describes the design of the system
Code Generation Page • Allows the user to enter information to generate a custom implementation of the design pattern • Fields to define the names for the pattern participants
Generating Declarations • Shows the generated classes defined in the design pattern • Classes are generated from the design pattern described • Can be customized by setting the trade-offs
Choosing Trade-offs • Allows the user to select specific trade-offs for the pattern specified (optional) • Specifies how the different classes can interact with each other • Chooses where the operations are declared
Other Generation Options • Allows user to control other generation parameters • Examples: • Include standard C++ operations • Generate execution trace in the operation • Limit file names to a certain size • Include a main testing routine in the class
System Architecture • Tool Designer Goals • Tool User Goals • Characteristics • Examples
Tool Designers Goals • Fast turn around time • Flexible system • Ability to interpret what the user wants
Tool User Goals • Useful and easy • Accessibility to an integrated information source on design patterns • Easy feedback mechanism • Ability to adapt code (design) to change
Characteristics of a Tool • Reuses aspects from other tools and systems • Make thorough use of the information provided by the user • Modularized design
Example of “Threshold Computer Systems” Solution • Recognize patterns • Build a pattern language in XML • Move from XML to implementation language (Java, C++, etc.)
Automagic Code Generation with Design Patterns Looked at: Design Patterns in General A tool that might help cut the “monkey business” How such tools work Which in the future means: More time designing, less time coding! NO MORE MONKEY BUSINESS!* *some monkey business may be necessary. your mileage will vary.
Know Your Last 485 Presentation! FIRST QUESTION: What isn’t fun about design patterns? SECOND QUESTION: Name two qualities in a design pattern code generation tool that users want. THIRD QUESTION: Name two options that a code generation tool has that a user can use to customize code implementation FOURTH QUESTION (FINAL QUESTION): How long did it take to create 23 design patterns?
REFERENCES www.research.ibm.com/journal/sj/352/budinsky.html http://studwww.rug.ac.be/~wbossart/ao/gen.pdf http://researchweb.watson.ibm.com/designpatterns/pubs/top10misc.pdf www.research.ibm.com/designpatterns/pubs/codegen.pdf www.qwan.com/AboutUs/generatePatternsUsingXml.pdf SUPPLIES LIMITED, ORDER NOW!!!