You are on page 1of 24

Architecture: Layers and

Packages

October 23, 2001 Software Design-Layering and Pa 1


ckaging
Architecture

 Often a system is composed of multiple packages/subsystems.

 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.

 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 ?

October 23, 2001 Software Design-Layering and Pa 2


ckaging
Three tier architecture (1)
Object Store

UPC Quantity
Presentation layer
Cash

Cash Balance

Enter Item End Sale Make Payment

Application logic
Record Sales Authorize payments

Storage
Persistent storage
Database
October 23, 2001 Software Design-Layering and Pa 3
ckaging
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 Pa 4


ckaging
Decomposing the application layer

Presentation POSTApplet

Payment Sale Domain concepts


Application logic
DBInterface ReportGenerator services

Storage
Database

October 23, 2001 Software Design-Layering and Pa 5


ckaging
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 Pa 6


ckaging
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 Pa 7


ckaging
Communication Across Layers [1]

 Requests from actors, i.e. system operations, go via the


Presentation Layer to the Application or the Domain
layer.

 Note that Presentation objects are not shown in the SSD.

 How would you handle requests from secondary actors?

October 23, 2001 Software Design-Layering and Pa 8


ckaging
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 Pa 9


ckaging
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 Pa 10


ckaging
Packages

Domain concepts

Core elements Sales

October 23, 2001 Software Design-Layering and Pa 11


ckaging
Package diagrams [1]

Presentation Presentation

Domain
App. logic

Services

Storage
Database

October 23, 2001 Software Design-Layering and Pa 12


ckaging
Package diagrams [2]

Presentation

Domain

Relational DB Communication Object DB Reporting


interface interface

App frameworks
and support libraries A B

A has knowledge
OO DB of B.
Relational
October 23, 2001 DB Software Design-Layering and Pa 13
ckaging
Package diagrams: Coupling
Presentation

Swing Text

Domain

Sales Pricing Tech Services

Persistence Jess
Service Access Payments

Inventory
Only partial coupling shown.
October 23, 2001 Software Design-Layering and Pa 14
ckaging
Package diagrams: Alternate Notation

Presentation:: Swing Presentation:: Text

Domain::Sales

Domain::
POSRuleEngine

Technical Services::
UML path name expression: Authorization
<PackageName::<TypeName>

October 23, 2001 Software Design-Layering and Pa 15


ckaging
Identifying packages

 Layers of an architecture represent vertical tiers.

 Partitions represent horizontal tiers, e.g. the Services


layer may be divided into Security and Reporting.

 Upward and downward communication is feasible across


components in a vertical layer. This is also known as a
“relaxed layer” architecture.

October 23, 2001 Software Design-Layering and Pa 16


ckaging
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 Pa 17


ckaging
Packaging: Guidelines [2]

 Package functionally cohesive vertical and horizontal slices:


e.g. Domain package: contains Sales and Pricing packages.

 Package a family of related interfaces.

 Package by work and by clusters of unstable classes.

 Most responsible classes are likely to be most stable.

 Factor out independent types.

October 23, 2001 Software Design-Layering and Pa 18


ckaging
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 Pa 19


ckaging
Example of “downward” communication

Presentation

ProcessSaleFrame UIFacade
Not a GUI class. Just a
plain object that adds a
level of indirection.
Domain

Register Sale

October 23, 2001 Software Design-Layering and Pa 20


ckaging
Example of “upward” communication
Property listener (observer)
:Presentation:: :Domain:: s:Domain
swing:Process Sales:Register Sales:Sale
SaleFrame
:cashier
enterItem(id,qty)
enterItem(id,qty) Subject
makeLineItem(spec,qty)

onPropertyEvent(s,”sales.total”,total)

October 23, 2001 Software Design-Layering and Pa 21


ckaging
Package diagrams: Domain Model Packages
in POS

Domain

Core/Misc. Payments Products

Authorization
Sales
Transactions

October 23, 2001 Software Design-Layering and Pa 22


ckaging
Mapping to Implementation Packages (Java)

// Presentation packages
com.foo.nextgen.ui.swing
com.foo.nextgen.ui.text

// Domain packages
com.foo.nextgen.domain.sales
com.foo.nextgen.domain.pricing

// Our team creates


com.foo.util
com.foo.boeingutilities

October 23, 2001 Software Design-Layering and Pa 23


ckaging
Summary

 What did we learn?


 What is architecture?
 Why use multi-tiered architecture?
 What is deployment?
 What are package diagrams?

October 23, 2001 Software Design-Layering and Pa 24


ckaging

You might also like