Download - October 23, 2001 Software Design-Layering and Packaging1 Architecture: Layers and Packages
October 23, 2001 Software Design-Layering and Packaging
2
Architecture
Often a system is composed of multiple packages/subsystems.
Example: An information system connects to a use
interface and a persistent storage mechanism.
How does one show subsystems/packages and their interactions in UML ?
Some packages may not be just a conceptual group of things. Instead they are subsystems with behavior and interfaces. For example, java.util is not a subsystem, it is a package. A PersistenceEngine is a subsystem.
October 23, 2001 Software Design-Layering and Packaging
3
Three tier architecture (1)
UPC
Cash
Quantity
Balance
Enter Item End Sale Make Payment
Object Store
CashPresentation layer
Persistent storage
Application logicRecord Sales Authorize payments
Storage
Database
October 23, 2001 Software Design-Layering and Packaging
4
Three tier architecture (2)
Separates the application logic into a distinct middle layer.
Presentation layer (mostly) free of application processing.
Middle layer communicates with the back-end layer.
Would you prefer a two-tier architecture? (Obtained by placing application logic into the presentation layer.)
October 23, 2001 Software Design-Layering and Packaging
5
Decomposing the application layer
Application logic
Presentation POSTApplet
ReportGeneratorDBInterface
SalePayment Domain concepts
services
StorageDatabase
October 23, 2001 Software Design-Layering and Packaging
6
Multi-tiered architecture
Multi-tiered architecture useful when:
The application logic needs to be split and isolated into multiple layers.
The application logic needs to be distributed amongst several computers.
Development of components needs to be distributed amongst various developers.
October 23, 2001 Software Design-Layering and Packaging
7
Deployment
A 3-tier architecture may be deployed in various configurations.
Presentation and app logic on one computer, database on a server.
Presentation on client computer, app logic on application server, and database on a data server.
October 23, 2001 Software Design-Layering and Packaging
8
Communication Across Layers [1]
Requests from actors, i.e. system operations, go via the Presentation Layer to the Application or the Domain layer.
How would you handle requests from secondary actors?
Note that Presentation objects are not shown in the SSD.
October 23, 2001 Software Design-Layering and Packaging
9
Communication Across Layers [2]
Communication from the presentation layer to the lower layers is referred to as “downward communication.”
Communication from the lower layers to presentation layer is referred to as “upward communication.”
How to achieve such communications while minimizing coupling?
October 23, 2001 Software Design-Layering and Packaging
10
Layers and Architectural patterns [1]
Architectural layers define “big parts” of a system.
Architectural design patterns are used for designing communications amongst layers (or “big parts”).
Architectural design patterns include Façade and Observer.
October 23, 2001 Software Design-Layering and Packaging
11
Domain concepts
Packages
Core elements Sales
October 23, 2001 Software Design-Layering and Packaging
12
Package diagrams [1]
Presentation
Domain
Services
Presentation
App. logic
StorageDatabase
October 23, 2001 Software Design-Layering and Packaging
13
Package diagrams [2]
Presentation
Domain
Relational DBinterface
Communication Object DBinterface
App frameworksand support libraries
RelationalDB
OO DB
Reporting
A B
A has knowledgeof B.
October 23, 2001 Software Design-Layering and Packaging
14
Package diagrams: Coupling
Presentation
Swing Text
Domain
PricingSales
Service Access Payments
Inventory
Tech Services
Persistence Jess
Only partial coupling shown.
October 23, 2001 Software Design-Layering and Packaging
15
Package diagrams: Alternate Notation
Presentation:: Swing
Domain::Sales
Domain::POSRuleEngine
Presentation:: Text
UML path name expression: <PackageName::<TypeName>
Technical Services::Authorization
October 23, 2001 Software Design-Layering and Packaging
16
Identifying packages
Layers of an architecture represent vertical tiers.
Upward and downward communication is feasible across components in a vertical layer. This is also known as a “relaxed layer” architecture.
Partitions represent horizontal tiers, e.g. the Services layer may be divided into Security and Reporting.
October 23, 2001 Software Design-Layering and Packaging
17
Packaging: Guidelines [1]
Java provides package support. Hence reverse engineering can be used to generate package diagrams.
Packages developed during design might change during implementation. Reverse engineering is used to get the up-to-date diagrams.
October 23, 2001 Software Design-Layering and Packaging
18
Packaging: Guidelines [2]
Package functionally cohesive vertical and horizontal slices: e.g. Domain package: contains Sales and Pricing packages.
Package by work and by clusters of unstable classes.
Package a family of related interfaces.
Most responsible classes are likely to be most stable.
Factor out independent types.
October 23, 2001 Software Design-Layering and Packaging
19
Visibility between packages: Model View Separation Principle
What visibility should packages have to the Presentation Layer?: Avoid direct coupling between window objects and the “Model.”
Upward communication:
The Observer pattern: Make the GUI object appear as an object that implements an interface.
A presentation façade object that receives requests from below.
October 23, 2001 Software Design-Layering and Packaging
20
Example of “downward” communication
Domain
Register Sale
Presentation
ProcessSaleFrame UIFacadeNot a GUI class. Just a plain object that adds a level of indirection.
October 23, 2001 Software Design-Layering and Packaging
21
Example of “upward” communication
enterItem(id,qty)
:Presentation::swing:ProcessSaleFrame
:Domain::Sales:Register
makeLineItem(spec,qty)
s:DomainSales:Sale
enterItem(id,qty)
Property listener (observer)
onPropertyEvent(s,”sales.total”,total)
:cashier
Subject
October 23, 2001 Software Design-Layering and Packaging
22
Package diagrams: Domain Model Packages in POS
Domain
Core/Misc.
Sales
Products
AuthorizationTransactions
Payments
October 23, 2001 Software Design-Layering and Packaging
23
Mapping to Implementation Packages (Java)
com.foo.nextgen.ui.swing
// Presentation packages
com.foo.nextgen.ui.text
com.foo.nextgen.domain.sales
// Domain packages
com.foo.nextgen.domain.pricing
com.foo.util
// Our team creates
com.foo.boeingutilities