l5 - february 22, 2006copyright thomas pole 2003-2006, all rights reserved 1 lecture 5:...

22
L5 - February 22 , 2006 copyright Thomas Pole 200 3-2006, all rights reserv ed 1 Lecture 5: Graphically Based Code Generation and Text Chapter 4: Paradigm Shift

Upload: alvin-weaver

Post on 20-Jan-2018

213 views

Category:

Documents


0 download

DESCRIPTION

L5 - February 22, 2006copyright Thomas Pole , all rights reserved 3 Chapter 3: Questions Dealing with Change Your questions: My Questions:

TRANSCRIPT

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

1

Lecture 5: Graphically Based Code Generation

and Text Chapter 4:Paradigm Shift

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

2

Agenda• Review Text Chapter 3: Dealing with Change

– Questions from Chapter 3• Lecture: Graphically Based Code Generation• Special Topic: Capturing Variability in Reusable

Assets’ Designs• Text: “Software Factories”

Chapter 4, Paradigm Shift• Reverse Quiz • Q&A

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

3

Chapter 3: QuestionsDealing with Change

• Your questions:

• My Questions:

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

4

Lecture 5: Graphically Based Code Generation

• Definition: Generating source code for a module or sub-system (in very, very rare cases whole systems) from a graphical specification. – (yup, the same as the def. for last week’s Specification

Based Code Generation lecture with the addition of one word, Graphical is just a format for specification.)

– Specification is written in a language and/or graphical representation, or both. e.g. UML, ER Diagrams

– These specification languages are usually limited in scope by engineering domain (e.g. GUI development) or application domain (e.g. business automation)

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

5

Graphical Specification is Still a Specification Based Approach

• Most of what we said last week about specification based code generation still applies:– Code generators are almost always domain specific.

• These may be engineering domains or application domains.• Remember, not all domain specific reuse technologies are code

generators.

– Early successes in specification based code generation, most of which are domain specific are in well understood, relatively broadly applicable domains:

• GUI Generation, Database applications, work flow apps.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

6

Examples of Graphically Based Code Generation Products

• GUI Generation:– Visual Basic– Visual C++ MFC

• Database Applications/Sub-Systems– PowerBuilder– Access

• Assisted Spec Based and Graphical Generation– Visual Studio Database Project Wizard

• Assisted Specification Based Generation of Database, Graphical Based table relations.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

7

Graphically Based Code GenerationThe (Usual) Approach

• Create: Create the Project, or Add to a Project.• Draw and Annotate: Using a set of specific symbols, their

associated meanings and defined relationships among the symbols, and definable properties (annotations) a picture is drawn using an editor designed for the purpose.

• Generate: The editor or an associated tool is used to “compile” the picture, generating a set of code which produces a significant portion of the system or sub-system defined by the picture.

• Complete: Then associated tools and/or components from libraries along with custom code are used to complete the system.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

8

GUI Generation Example: Visual Basic - 1

• Create Project– New Project, type Visual Basic – Windows Application

• Generates an application with one GUI form.• View GUI or View Code• Expand generated code.

• Draw and Annotate: – Add a text box, and a button.– Annotate the symbols (button and textbox)– Re-Draw (drag and drop, stretch, etc.)

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

9

GUI Generation Example: Visual Basic - 2

• Generate– Sometimes, done synchronously with ‘draw and

annotate’. Sometimes you implicitly invoke generation.– Click right and ‘View Code”’ on the button.– Double click on a GUI symbol (e.g. a button) and look

at the code again, you’ll see new generated code.• Complete

– Use drop down list of local variables/objects.– Add code as appropriate.– F5 to build and run.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

10

Microsoft Visual Studio and Microsoft Foundation Class (MFC) tools:

CodeGenerationMfc• Drag and Drop definition of a GUI

– EditField– Button

• Generation of code to react to GUI events• Generation of code for code objects that represent GUI objects.• Linking behavior to events to objects.• Generation of a template GUI

– Borders– Min/Max behavior

• All of this is from generated Code– Can be edited with generator, or manually or both (if you’re careful)– Manual edits can override generated code changes, and vice versa.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

11

GUI Generation Example: VC++/MFC – 1

• Create Project– New Project, type Visual C++/MFC Application

• Application Type: select ‘Dialog based’• Choose: User Interface Features, etc. (early annotation)

– Generates an application with one GUI form.• View GUI or View Code• Expand generated code.

• Draw and Annotate: – Add a edit control (VB’s ‘text box’), and a button.– Annotate the symbols (button and edit control)– Re-Draw (drag and drop, stretch, etc.)

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

12

GUI Generation Example: VC++/MFC – 2• Generate

– Sometimes, done synchronously with ‘draw and annotate’. Sometimes you implicitly invoke generation.

– Click right on the edit control and select ‘add variable’.• Define it, then switch to “Class View”.

– Go back to Resource view, click right on button, and select ‘Add event Handler’, then ‘add and edit’.

• Complete– Use class view to navigate objects and members

(variables)– Add code as appropriate.– F5 to build and run.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

13

Other Graphical Specification Generation Examples:

• We’ll hold this for another week – when time is available.

• Visual Studio Database Project• Rational XDE Generates Architectural Design

Level Code from UML “drawn” specifications.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

14

Other Specification Driven Technologies• Some Specification Based technologies do not

generate code.– Some Specification Based generators generate

executable systems, without producing human readable code.

– Some interactively work with user, question and answer based, then generates formal requirements statement.

– Some generate designs directly from requirements statements, but not code or executables.

– Some generators generate source code, often partial implementations from designs.

• Example: IBM’s Rational XDE

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

15

Special Topic: Variation Points and Variants

• Capturing Variability in Reusable Assets’ Designs– Commonality/Variability analysis identifies ways in

which all the possible uses of an asset are similar (commonality), as well as the ways in which they can differ (variation).

– The ways they differ is by picking one of several ways a specific feature or attributes can be implemented.

– The feature or attribute is the variation point.– All the possible ways in which that feature (variation

point) can be implemented are the variation point’s variants.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

16

Variation Point• Reusable Software Asset: A component that can be

used to categorize information. – Application example: categorizing books in a library.– Each piece of information (an asset) can be ‘tagged’ as

belonging to a category, or classification.– Administrators of asset collections can tag assets, untag

assets, and retag assets.– Researchers can define a search made up of classification

tags, search for a list of assets that match that classification, and then retrieve assets from that list.

• Variation Points: How classification terms (tags) can be defined, organized, used, etc.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

17

Variation Point’s Variants• Simple Flat Classification

– A list of terms is defined, and there is no relationship among terms.– Any asset can be classified by any one term. – When a researcher searches on that term, they get a list of assets tagged

by that term.• Simple Hierarchical Classification

– A structure of terms id defined, where some terms (e.g. Automobile) are specialized sub-classes (e.g. truck or car) of other super-classes.

– Any asset can be classified by any one term.– When a researcher searches on that term, they get a list of all assets

tagged by that term AS WELL AS all assets tagged by its sub-classes terms.

• Compound Flat Classification– An asset can be tagged by multiple terms, -and/or-– A researcher can put multiple terms in a search.

• Faceted Classification– Hierarchical with multiple root classes

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

18

Break

• 15 minutes• Next: “Software Factories”,

Ch 2: Dealing with Complexity

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

19

Ch 4: Paradigm Shift • “The Structure of Scientific Revolutions”, 1970,

Thomas Kuhn– Physicist, Philosopher, Historian (of science)– “The Copernican Revolution”, 1957– “The Function of Measurement in modern physical

science”, 1961– “The Essential Tension, Selected Studies in Scientific

Tradition and Change”, 1977– “Black-Body Theory and the Quantum Discontinuity

(1894-1912)” ,1987– Originator of the expression, “Paradigm Shift”

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

20

Ex. 2 Reusable Asset Design• Revisit your exercise 1 submission

– If you feel you need to change your exercise 1 submission to be able to complete exercise 2, you may do so by resubmitting a new exercise 1 reusable asset description and CV analysis, along with exercise 2.

• Describe the high level design of your reusable asset. In the design explicitly address:– Identify in your design the commonality and variability

you described in exercise 1 as variation point(s) and variants.

– Identify which portions of your reusable asset will be via static source code, by parameterized code, and by generated code.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

21

Reverse Quiz

• Quiz covers: Anything we have covered in class up through tonight’s session.

• You write down 1 to 3 questions that you think would be appropriate for a quiz on this material.

• Pass the questions up to the instructor.• The instructor takes the quiz.• You get the answers.

L5 - February 22, 2006 copyright Thomas Pole 2003-2006, all rights reserved

22

Questions?

• Read the introduction through chapter 5, “Software Factories” for next week.

• Submit Exercise 2 by email prior to 7:30 PM Tuesday February 28 (7:30 PM the day before class)