Logical Architecture and UML Package Diagrams
Logical Architecture and UML Package Diagrams
Logical Architecture and Layers Logical architecture: the large-scale organization of software classes into packages, subsystems, and layers.
Logical because no decisions about deployment are implied. (See Chap. 37.)
Layer: a very coarse-grained grouping of classes, packages, or subsystems that has cohesive responsibility for a major aspect of the system.
Swing
Web
Domain
Sales
Payments
Taxes
Technical Services
Persistence
Logging
RulesEngine
Swing
Web
Sales
UI UI::Swing UI::Web
Swing Domain::Sales
Design with Layers Organize the large-scale logical structure of a system into discrete layers of distinct, related responsibilities.
Cohesive separation of concerns. Lower layers are general services. Higher layers are more application-specific.
handles application layer requests implementation of domain rules domain services (POS, Inventory) - services may be used by just one application, but there is also the possibility of multi-application services
very general low-level business services used in many business domains CurrencyConverter
low-level technical services, utilities, and frameworks data structures, threads, math, file, DB, and network I/O
dependency
handles presentation layer requests workflow session state window/page transitions consolidation/transformation of disparate data for presentation
Benefits of a Layered Architecture Separation of concerns: E.g., UI objects should not do application logic (a window object should not calculate taxes) nor should a domain layer object create windows or capture mouse events.
Reduced coupling and dependencies. Improved cohesion. Increased potential for reuse. Increased clarity.
Related complexity is encapsulated and decomposable. Some layers can be replaced with new implementations. Lower layers contain reusable functions. Some layers can be distributed.
Especially Domain and Technical Services.
Designing the Domain Layer How do we design the application logic with objects? Create software objects with names and information similar to the real-world domain. Assign application logic responsibilities to these domain objects.
E.g., a Sale object is able to calculate its total.
The application logic layer is more accurately called a domain layer when designed this way.
Domain layer of the architecture in the UP Design Model The object-oriented developer has taken inspiration from the real world domain in creating software classes. Therefore, the representational gap between how stakeholders conceive the domain, and its representation in software, has been lowered.
Domain
Inventory
Tax
Logging
Technical Services
Foundation
Persistence
MySQL Inventory
Foundation
UML notation: A UML component, or replaceable, modular part of the physical system UML notation: A physical database in the UML.
The Model-View Separation Principle Model: the domain layer of objects. View: user interface (UI) objects. Model objects should not have direct knowledge of view objects.
Do not connect or couple non-UI objects directly to UI objects.
E.g., dont let a Sale object have a reference to a Java Swing JFrame window object.
UI Swing :System : Cashier makeNewSale() : Cashier enterItem(id, quantity) description, total Domain endSale() ... makeNewSale() enterItem() endSale() ... ProcessSale Frame makeNewSale() enterItem() endSale()
the system operations handled by the system in an SSD represent the operation calls on the Application or Domain layer from the UI layer
The Observer Pattern If model (domain) objects do not have direct knowledge of view (UI) objects, how can a Register or Sale object get a window to refresh its display when a total changes? The Observer pattern (p. 463) allows domain objects to send messages to UI objects viewed only in terms of an interface.
E.g., known not as concrete window class, but as implementation of PropertyListener interface.