21
Patterns in Software Engineering Lecturer: Raman Ramsin Lecture 19 Analysis Patterns Part 2 Department of Computer Engineering 1 Sharif University of Technology Part 2

Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering

Lecturer: Raman Ramsin

Lecture 19

Analysis PatternsPart 2

Department of Computer Engineering1

Sharif University of Technology

Part 2

Page 2: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting PatternsSupporting Patterns

Th ti tt d ib h t t k l i ttThe supporting patterns describe how to take analysis patterns and apply them:

Layered Architecture for Information Systems: These patterns consider the architecture for a client/server information system and how such a system can be layered to improve its maintainability.y y p y

Patterns for Type Model Design Templates: These patterns focus on how conceptual models can be implemented, suggesting common p p , gg gpatterns to turn analysis patterns into software.

Association Patterns: These patterns focus on examining modeling techniques themselves and how advanced modeling constructs can be viewed as patterns.

Department of Computer Engineering2

Sharif University of Technology

Page 3: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Layered Architectures - Two-Tier Architecturepp g y

P bl P titi i ft li t/ tProblem: Partitioning software on a client/server system.

Solution: Put the user interface on the client and the database on the server.on the server.

The user interface classes access the database directly.

Department of Computer Engineering3

Sharif University of Technology

Page 4: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Layered Architectures - Three-Tier Architecturepp g y

Problem:

Th t ti hit t l th i t f t ti htl t thThe two-tier architecture couples the user interface too tightly to the database design.

The database interface cannot support a rich model of the domainThe database interface cannot support a rich model of the domain.

Solution: Have three logical tiers: application, domain, and database.

Department of Computer Engineering4

Sharif University of Technology

Page 5: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Layered Architectures - Tiered Architecturespp g y

Two Tier Three Tier

Department of Computer Engineering5

Sharif University of Technology

Page 6: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Layered Architectures - Presentation & Application Logicpp g y g

Problem: Application software handles both interpretation of the domain model and driving the user interface.the domain model and driving the user interface.

Solution:

Separate the application tier into presentation (user interface) and Sepa ate t e app cat o t e to p ese tat o (use te ace) a dapplication logic (dealing with the domain model).

Structure the application logic as a set of facades for the presentation.pp g p

Department of Computer Engineering6

Sharif University of Technology

Page 7: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Layered Architectures - Presentation & Application Logicpp g y g

Department of Computer Engineering7

Sharif University of Technology

Page 8: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Layered Architectures - Database Interactionpp g y

Problem: Working with a database.

Solution:Solution:

Let the domain classes be responsible for saving themselves in the databasedatabase.

Create a separate layer to handle the interactions between database and domain objectsdomain objects.

Department of Computer Engineering8

Sharif University of Technology

Page 9: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Type Model Design Templates – Implementing Associationspp g yp g p

Problem: Implementing a conceptual associationProblem: Implementing a conceptual association.

Solution:

Choose one direction to implement and use an operation and a pointerChoose one direction to implement, and use an operation and a pointer.

Put operations and pointers in both directions.

Put operations in both directions but a pointer only in one. Use lookup for the other direction.

Put operations in both directions, and use a table and lookup for the pointers.

Department of Computer Engineering9

Sharif University of Technology

Page 10: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Type Model Design Templates – Implementing Generalizationspp g y g

Problem: Implementing generalization, especially if multipleProblem: Implementing generalization, especially if multiple and dynamic classification is involved.

Solution:

Use inheritance.

Use classes for each combination of subtypes with multiple inheritanceUse classes for each combination of subtypes with multiple inheritance.

Use an internal flag.

Delegate to a hidden class (state pattern).

Copy and replace.

Department of Computer Engineering10

Sharif University of Technology

Page 11: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Type Model Design Templates – Object Creationpp g yp g p j

P bl C i bjProblem: Creating an object.

Solution: Use a creation method with arguments for all mandatory and immutable mappingsmandatory and immutable mappings.

Department of Computer Engineering11

Sharif University of Technology

Page 12: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Type Model Design Templates – Object Destructionpp g yp g p j

Problem: Destroying an object.

Solution: Have a specific destruction method.

Define how much the delete should cascade.

Department of Computer Engineering12

Sharif University of Technology

Page 13: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Type Model Design Templates - Entry Pointpp g yp g p y

Problem: Starting to look for objectsProblem: Starting to look for objects.

Solution:

Let the class be responsible for storing and finding its instancesLet the class be responsible for storing and finding its instances.

Have a registrar find and store objects.

Department of Computer Engineering13

Sharif University of Technology

Page 14: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Type Model Design Templates – Implementing Constraintspp g yp g p

P bl I l ti t i tProblem: Implementing constraints.

Solution: Give each object an operation to check its constraint. Call it at the end of modifiers when debugging.Call it at the end of modifiers when debugging.

Department of Computer Engineering14

Sharif University of Technology

Page 15: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Association Patterns - Associative Typepp g yp

Problem: Adding features to an association.

Solution: Create a type for the association.

Use a special notation.

Department of Computer Engineering15

Sharif University of Technology

Page 16: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Association Patterns - Associative Typepp g yp

Department of Computer Engineering16

Sharif University of Technology

Page 17: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Association Patterns - Keyed Mappingpp g y pp g

P bl R i l i i h k d ffProblem: Representing values in a mapping that are keyed off another type.

Solution: Use a keyed mappingSolution: Use a keyed mapping.

Department of Computer Engineering17

Sharif University of Technology

Page 18: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Association Patterns - Keyed Mappingpp g y pp g

Department of Computer Engineering18

Sharif University of Technology

Page 19: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Association Patterns - Historic Mappingpp g pp g

Problem: Recording previous values of a mapping.

Solution: Use a historic mapping.

Department of Computer Engineering19

Sharif University of Technology

Page 20: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

Supporting Patterns: Association Patterns - Historic Mappingpp g pp g

Department of Computer Engineering20

Sharif University of Technology

Page 21: Patterns in Software Engineeringsharif.edu/~ramsin/index_files/pselecture19.pdf · 2008-06-04 · Patterns in Software Engineering – Lecture 19 Supporting PatternsSupporting Patterns

Patterns in Software Engineering – Lecture 19

R fReference

Fowler, M., Analysis Patterns: Reusable Object Models, Addison-Wesley, 1997.

Department of Computer Engineering21

Sharif University of Technology