240 likes | 349 Views
Architecture: Layers and Packages. Architecture. Often a system is composed of multiple packages/subsystems.
E N D
Architecture: Layers and Packages Software Design-Layering and Packaging
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 ? Software Design-Layering and Packaging
Object Store UPC Quantity Cash Cash Balance Record Sales Authorize payments End Sale Enter Item Make Payment Storage Three tier architecture (1) Presentation layer Application logic Persistent storage Database Software Design-Layering and Packaging
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.) Software Design-Layering and Packaging
Payment Sale DBInterface ReportGenerator Database Decomposing the application layer POSTApplet Presentation Domain concepts Application logic services Storage Software Design-Layering and Packaging
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. Software Design-Layering and Packaging
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. Software Design-Layering and Packaging
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? Software Design-Layering and Packaging
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? Software Design-Layering and Packaging
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. Software Design-Layering and Packaging
Sales Core elements Packages Domain concepts Software Design-Layering and Packaging
Domain Services Presentation Database Package diagrams [1] Presentation App. logic Storage Software Design-Layering and Packaging
Domain Presentation Object DB interface Relational DB interface Communication Reporting B A A has knowledge of B. Relational DB OO DB Package diagrams [2] App frameworks and support libraries Software Design-Layering and Packaging
Presentation Swing Text Pricing Sales Payments Persistence Jess Domain Tech Services Service Access Inventory Package diagrams: Coupling Only partial coupling shown. Software Design-Layering and Packaging
Presentation:: Swing Presentation:: Text Domain::Sales Domain:: POSRuleEngine Technical Services:: Authorization Package diagrams: Alternate Notation UML path name expression: <PackageName::<TypeName> Software Design-Layering and Packaging
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. Software Design-Layering and Packaging
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. Software Design-Layering and Packaging
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. Software Design-Layering and Packaging
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. Software Design-Layering and Packaging
Domain Presentation Not a GUI class. Just a plain object that adds a level of indirection. Register ProcessSaleFrame Sale UIFacade Example of “downward” communication Software Design-Layering and Packaging
Property listener (observer) :Domain:: Sales:Register s:Domain Sales:Sale :cashier enterItem(id,qty) enterItem(id,qty) makeLineItem(spec,qty) Subject onPropertyEvent(s,”sales.total”,total) Example of “upward” communication :Presentation::swing:ProcessSaleFrame Software Design-Layering and Packaging
Domain Core/Misc. Sales Products Payments Authorization Transactions Package diagrams: Domain Model Packages in POS Software Design-Layering and Packaging
Mapping to Implementation Packages (Java) com.foo.nextgen.ui.swing // Presentation packages 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 Software Design-Layering and Packaging
Summary • What did we learn? • What is architecture? • Why use multi-tiered architecture? • What is deployment? • What are package diagrams? Software Design-Layering and Packaging