Trusted Components Reuse, Contracts and Patterns Prof. Dr. Bertrand - - PowerPoint PPT Presentation

trusted components
SMART_READER_LITE
LIVE PREVIEW

Trusted Components Reuse, Contracts and Patterns Prof. Dr. Bertrand - - PowerPoint PPT Presentation

1 Last update: 2 November 2004 Trusted Components Reuse, Contracts and Patterns Prof. Dr. Bertrand Meyer Dr. Karine Arnout Chair of Softw are Engineering Trusted Components: Reuse, Contracts and Patterns - Lecture 7 2 Lecture 7: Pattern


slide-1
SLIDE 1

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

1

Chair of Softw are Engineering

Last update: 2 November 2004

Trusted Components

Reuse, Contracts and Patterns

  • Prof. Dr. Bertrand Meyer
  • Dr. Karine Arnout
slide-2
SLIDE 2

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

2

Chair of Softw are Engineering

Lecture 7: Pattern Wizard, project presentation

slide-3
SLIDE 3

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

3

Chair of Softw are Engineering

Agenda for today

Pattern Wizard Project presentation

slide-4
SLIDE 4

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

4

Chair of Softw are Engineering

Componentizability classification

2.1 Skeleton 2.1.2 No method 2.1.1 Method 2.3 Some library support 1. Componentizable 2.2 Possible skeleton 2. Non-componentizable 1.3 Newly componentized 1.1 Built-in 1.2 Library- supported 1.3.2 Componentizable but not comprehensive 1.3.1 Fully componentizable 1.3.3 Componentizable but unfaithful 1.3.4 Componentizable but useless Design pattern 2.4 Design idea 1.4 Possible component Prototype Flyweight Observer Mediator Abstract Factory Factory Method Visitor Command Composite Chain of Responsibility Builder Proxy State Strategy Memento Decorator Adapter Template Method Bridge Singleton Iterator Facade Interpreter

slide-5
SLIDE 5

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

5

Chair of Softw are Engineering

Why an automatic code generation tool?

Interesting for: Non-componentizable patterns → Supported by the Pattern Wizard Componentizable but not comprehensive Fully componentizable patterns that cannot be applied to a given problem (e.g. performance) → Will be supported in the next version Demo

slide-6
SLIDE 6

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

6

Chair of Softw are Engineering

Pattern Wizard

  • Applicable to non-componentizable patterns
  • Automatically generates skeleton classes

→ Generated code

slide-7
SLIDE 7

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

7

Chair of Softw are Engineering

Overall architecture

PATTERN_ WIZARD + PW_INITIAL_ WINDOW * PW_INITIAL_ WINDOW_IMP * PW_PATTERN_ VERTICAL_BOX + PW_DECORATOR_ VERTICAL_BOX + PW_DECORATOR_ INFORMATION * PW_PATTERN_ INFORMATION * PW_PATTERN_ CODE_GENERATOR + PW_DECORATOR_ CODE_GENERATOR PW_SKELETON_ NAMES

gui model generation

PW_ SUPPORT

support

slide-8
SLIDE 8

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

8

Chair of Softw are Engineering

Graphical User Interface

PW_PATTERN_SELECTOR EV_HORIZONTAL_BOX PW_CONTROL_BOX EV_TITLED_WINDOW EV_VERTICAL_BOX

slide-9
SLIDE 9

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

9

Chair of Softw are Engineering

Overall architecture

PATTERN_ WIZARD + PW_INITIAL_ WINDOW * PW_INITIAL_ WINDOW_IMP * PW_PATTERN_ VERTICAL_BOX + PW_DECORATOR_V ERTICAL_BOX + PW_DECORATOR_ INFORMATION * PW_PATTERN_ INFORMATION * PW_PATTERN_ CODE_GENERATOR + PW_DECORATOR_ CODE_GENERATOR PW_SKELETON_ NAMES

gui model generation

PW_ SUPPORT

support

slide-10
SLIDE 10

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

10

Chair of Softw are Engineering

Class PW_DECORATOR_INFORMATION

class PW_DECORATOR_INFORMATION feature component_class_name: STRING feature_name: STRING effective_component_class_name: STRING … end

slide-11
SLIDE 11

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

11

Chair of Softw are Engineering

Class PW_INITIAL_WINDOW_IMP

deferred class PW_INITIAL_WINDOW_IMP ... feature { NONE} -- Implementation (Pattern information) decorator_info: PW_DECORATOR_INFORMATION is

  • - Selected information about the chosen pattern

require decorator_pattern_vbox_not_void: decorator_pattern_vbox / = Void local frame: PW_DECORATOR_PROPERTY_SELECTOR do create Result frame : = decorator_pattern_vbox.pattern_properties_frame Result.set_component_class_name (frame.component_class_name) Result.set_feature_name (...) ... if frame.is_component_with_additional_attribute_generation then Result.set_component_with_additional_attribute_generation (True) ... end if frame.is_component_with_additional_behavior_generation then ... end ensure decorator_info_not_void: Result / = Void end end

slide-12
SLIDE 12

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

12

Chair of Softw are Engineering

Overall architecture

PATTERN_ WIZARD + PW_INITIAL_ WINDOW * PW_INITIAL_ WINDOW_IMP * PW_PATTERN_ VERTICAL_BOX + PW_DECORATOR_V ERTICAL_BOX + PW_DECORATOR_ INFORMATION * PW_PATTERN_ INFORMATION * PW_PATTERN_ CODE_GENERATOR + PW_DECORATOR_ CODE_GENERATOR PW_SKELETON_ NAMES

gui model generation

PW_ SUPPORT

support

slide-13
SLIDE 13

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

13

Chair of Softw are Engineering

Class PW_PATTERN_CODE_GENERATOR

deferred class PW_PATTERN_CODE_GENERATOR feature -- Access pattern_info: PW_PATTERN_INFORMATION

  • - Pattern information needed for the code generation
  • - (name of classes, name of features, etc.)

project_directory: STRING

  • - Path of the project directory (where the code will be generated)

feature -- Status report root_class_and_ace_file_generation: BOOLEAN

  • - Should a root class and an Ace file be generated?

feature -- Element change set_pattern_info (a_pattern_info: like pattern_info) is … set_project_directory (a_project_directory: like project_directory) is … set_root_class_and_ace_file_generation (a_value: like root_class_and_ace_file_generation) is … feature -- Generation generate

  • - Generate code for this pattern.

require pattern_info_not_void: pattern_info / = Void pattern_info_complete: pattern_info.is_complete invariant project_directory_not_empty_and_exists_if_not_void: project_directory / = Void im plies (not project_directory.is_empty and directory_exists (project_directory)) end

slide-14
SLIDE 14

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

14

Chair of Softw are Engineering

Skeleton file for code generation

deferred class < DECORATOR_COMPONENT_CLASS_NAME> feature -- Basic Operation < DECORATOR_FEATURE_NAME> is

  • - Do something.

deferred end end

slide-15
SLIDE 15

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

15

Chair of Softw are Engineering

Feature generate

deferred class PW_PATTERN_CODE_GENERATOR ... feature -- Generation generate is

  • - Generate code for this pattern.

require pattern_info_not_void: pattern_info / = Void pattern_info_complete: pattern_info.is_complete do if root_class_and_ace_file_generation then generate_ace_file generate_root_class end generate_pattern_code end ... end

slide-16
SLIDE 16

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

16

Chair of Softw are Engineering

Implementation feature generate_code

deferred class interface PW_PATTERN_CODE_GENERATOR ... feature { NONE} -- Implementation (Code generation) generate_code (a_new_file_name, a_skeleton_file_name: STRING; some_changes: LINKED_LIST [ TUPLE [ STRING, STRING] ]

  • - Generate new file with file name a_new_file_name from the skeleton
  • - corresponding to a_skeleton_file_name by reproducing the skeleton
  • - code into the new file after some_changes, replacing a value by
  • - another. (some_changes should be of the form:
  • - LINKED_LIST [ [ old_string, new_string] , ...]

require a_new_file_name_not_void: a_new_file_name / = Void a_new_file_name_not_empty: not a_new_file_name.is_empty a_skeleton_file_name_not_void: a_skeleton_file_name / = Void a_skeleton_file_name_not_empty: not a_skeleton_file_name.is_empty a_skeleton_file_exists: file_exists (a_skeleton_file_name) some_changes_not_void: some_changes / = Void no_void_change: not some_changes.has (Void)

  • - no_void_old_string: forall c in some_changes, c.item (1) / = Void
  • - no_void_new_string: forall c in some_changes, c.item (2) / = Void

… end

slide-17
SLIDE 17

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

17

Chair of Softw are Engineering

Related work

Existing tool by Budinsky, Finnie, Yu, and Vlissides [ Budinsky 1996] Goal: fast turn-around, flexibility 3-part architecture: “Presenter”: HTML browser for user interaction; transmits input as Perl scripts “Mapper”: Perl interpreter COGENT (Code GENeration Template) interpreter: Code generator The Pattern Wizard brings a fully O-O design and implementation using Eiffel. (No such tool in Eiffel before.)

slide-18
SLIDE 18

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

18

Chair of Softw are Engineering

Future work

Enable choosing the root class name and creation procedure name Enable using existing files and add to them the pattern code Support other patterns Possibly support other languages

Your project

slide-19
SLIDE 19

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

19

Chair of Softw are Engineering

Agenda for today

Pattern Wizard Project presentation

slide-20
SLIDE 20

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

20

Chair of Softw are Engineering

Grading

Exam (2h): 40% 2 February 2005 Project: 60% Deadline: 4 February 2005 Extension of a “Pattern Wizard”

slide-21
SLIDE 21

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

21

Chair of Softw are Engineering

The project

Pattern Wizard Design + implementation in Eiffel GUI + Business model Documentation User guide: how to use the tool Developer guide: description of the architecture, main classes, limitations, how to extend the tool Test suite Thorough set of test cases

slide-22
SLIDE 22

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

22

Chair of Softw are Engineering

What you need to do

Enable choosing the root class name and creation procedure name Enable using existing files and add to them the pattern code Support two componentizable patterns: Abstract Factory Visitor

slide-23
SLIDE 23

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

23

Chair of Softw are Engineering

Grading criteria

  • Design (30 points)

Soundness (5 points) Extendibility (5 points) Ease of use (5 points) Minimal requirements (15 points)

  • Quality of contracts (20 points)
  • Documentation (20 points)

User guide (10 points) Developer guide (10 points)

  • Test (10 points)

Quality of test suite (5 points) Correctness of the tool (5 points)

  • Quality of code (10 points)

Style guidelines (5 points) Quality of code (5 points)

  • Effort devoted to the project (10 points)
slide-24
SLIDE 24

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

24

Chair of Softw are Engineering

Complementary material

  • From Patterns to Components:

Chapter 21: Pattern Wizard

  • Further reading:

Jan Bosch. “Design Patterns as Language Constructs”, JOOP, Vol.11, No.2, p 18-32, February 1998. Frank Budinsky et al. “Automatic Code Generation from Design Patterns”, IBM Systems Journal, 1996. http: / / www.research.ibm.com/ designpatterns/ pubs/ codegen .pdf. Craig Chambers et al. “A debate on language and tool support for design patterns”, 2000. http: / / delivery.acm.org/ 10.1145/ 330000/ 325731/ p277- chambers.pdf?key1= 325731&key2= 2236080701&coll= porta l&dl= ACM&CFID= 14710319&CFTOKEN= 16321913.

slide-25
SLIDE 25

Trusted Components: Reuse, Contracts and Patterns - Lecture 7

25

Chair of Softw are Engineering

End of lecture 7