Docsity

Object-Oriented Software Engineering: Forward Engineering & Design, Essays (high school) of Computer science

Partial preview of the text

Download Object-Oriented Software Engineering: Forward Engineering & Design and more Essays (high school) Computer science in PDF only on Docsity!

Object-Oriented Software EngineeringConquering Complex and Changing Systems

Chapter 7,

Object Design

Exercise 6.

6.4 Consider a legacy, fax-based, problem-reporting system for

an aircraft manufacturer. You are part of a reengineering

project replacing the core of the system by a computer-based

system, which includes a database and a notification system.

The client requires the fax to remain an entry point for

problem reports. You propose an E-mail entry point.

Describe a subsystem decomposition, and possibly a design

pattern, which would allow both interfaces.

Exercise 6.

6.5 You are designing the access control policies for a Web-

based retail store:

w Customers access the store via the Web, browse product information, input their address and payment information, and purchase products. w Suppliers can add new products, update product information, and receive orders. w The store owner sets the retail prices, makes tailored offers to customers based on their purchasing profiles, and provides marketing services.

You have to deal with three actors: StoreAdministrator,

Supplier, and Customer. Design an access control policy for

all three actors. Customers can be created via the Web,

whereas Suppliers are created by the StoreAdministrator.

Possible solution for exercise 6.

Product CustomerInfo SupplierInfo Order Anonymous GetInfo() Create() Customer GetInfo() GetPrice()

UpdateInfo() Create()

Supplier Create() GetInfo() UpdateInfo()

UpdateInfo() Process()

StoreAdministrator UpdatePrice() VerifyInfo() Create() Examine()

Web Browser (UI Framework)

Web Server

HTTP

State Profil

A1: Application Server

State State State State

State

A2: Application Server

Profil Profil Profil

Profil

Database Server (Database Framework)

Reengineering Terminology

♦ Reverse Engineering:

w Discovery (or Recovery) of an object model from the code.

♦ Forward Engineering:

w Automatic generation of code from an object model w Requirements Engineering, Requirements Analysis, System Design, Object Design, Implementation, Testing, Delivery

♦ Discipline:

w Always change the object model, then generate code (for sure do this when you change the interface of a public method/class.) t Generate code under time pressure

  • Patch the code!

♦ Roundtrip Engineering

w Forward Engineering + reverse engineering w Inventory analysis: Determine the Delta between OM and Code w Together-J and Rationale have tools for reverse engineering

♦ Reengineering (Project Management Issue):

w New functionality (customer dreams up new stuff) w New technology (technology enablers)

Object Design Issues

♦ Full definition of associations

♦ Full definition of classes (System Design: Service, Object

Design: API)

♦ Specify the contract for each component

♦ Choice of algorithms and data structures

♦ Detection of new application-domain independent classes

(example: Cache)

♦ Optimization

♦ Increase of inheritance

♦ Decision on control

♦ Packaging

Terminology of Activities

♦ Object-Oriented Methodologies

w System Design t Decomposition into subsystems w Object Design t Implementation language chosen t Data structures and algorithms chosen

♦ SA/SD (structured analysis/structured design) uses different

terminology:

w Preliminary Design t Decomposition into subsystems t Data structures are chosen w Detailed Design t Algorithms are chosen t Data structures are refined t Implementation language is chosen t Typically in parallel with preliminary design, not separate stage

Service Specification

♦ Requirements analysis

w Identifies attributes and operations without specifying their types or their parameters.

♦ Object design

w Add visibility information w Add type signature information w Add contracts (Bertrand Meyer, Eiffel)

Add Visibility

UML defines three levels of visibility:

♦ Private:

w A private attribute can be accessed only by the class in which it is defined. w A private operation can be invoked only by the class in which it is defined. w Private attributes and operations cannot be accessed by subclasses or other classes.

♦ Protected:

w A protected attribute or operation can be accessed by the class in which it is defined and on any descendent of the class.

♦ Public:

w A public attribute or operation can be accessed by any class.

Information Hiding Design Principles

♦ Only the operations of a class are allowed to manipulate its

attributes

w Access attributes only via operations.

♦ Hide external objects at subsystem boundary

w Define abstract class interfaces which mediate between system and external world as well as between subsystems

♦ Do not apply an operation to the result of another operation.

w Write a new operation that combines the two operations.

Add Type Signature Information

Hashtable

+put(key:Object,entry:Object) +get(key:Object):Object +remove(key:Object) +containsKey(key:Object):boolean +size():int

-numElements:int

Hashtable

+put() +get() +remove() +containsKey() +size()

-numElements:int

Expressing constraints in UML

♦ OCL (Object Constraint Language)

w OCL allows constraints to be formally specified on single model elements or groups of model elements w A constraint is expressed as an OCL expression returning the value true or false. OCL is not a procedural language (cannot constrain control flow).

♦ OCL expressions for Hashtable operation put():

w Invariant: t context Hashtable inv: numElements >= 0

w Precondition: t context Hashtable::put(key, entry) pre:!containsKey(key)

Context is a class OCL expression operation

w Post-condition: t context Hashtable::put(key, entry) post: containsKey(key) and get(key) = entry

Expressing Constraints in UML

♦ A constraint can also be depicted as a note attached to the

constrained UML element by a dependency relationship.

HashTable

put(key,entry:Object) get(key):Object remove(key:Object) containsKey(key:Object):boolean

<> numElements >= 0

<> !containsKey(key) <> containsKey(key) <> containsKey(key)

<> get(key) == entry

<> !containsKey(key)

size():int

numElements:int