Principles and Styles of Software Architecture
Principles of Architecture
- Abstraction
- Encapsulation
- Separation of Responsibilities
- Coupling and Cohesion
- No Duplication
- Parameterization and Configurability
- Clarity and Simplicity
- Separation of Interface and Implementation
Benefits of Studying Software Architecture
Understanding the details of selected architectures helps determine the best design alternatives.
Impact of Architecture on Software
Software architecture allows us to reason and plan for:
- System Reliability
- Evolution
- Reuse
- Efficiency
- Improved Maintenance
- Etc.
Problems with a Lack of Architecture
- Poor Performance
- Costly Maintenance
- Poorly Designed for Evolution
- Limited Reuse
- Inefficient Projects
What is Architecture?
- High-level structural view
- Defines a style or combination of styles for a solution
- Focuses on non-functional requirements
- Functional requirements are met through application modeling and design
- Essential for the success or failure of a project
The architecture of a software system is the structure or structures of the system, comprising:
- Software elements
- Externally visible properties of those elements
- Relations between them
Types of Software Structures
There are two types of structures relevant to an architect:
- Static Structures (organizational design time)
- Dynamic Structure (organization at runtime)
Static Elements
Deal with system design, including its elements and their relationships. These internal design elements include:
Software:
- Modules
- Classes
- Packages
- Stored Procedures
Internal Data Elements:
- Classes
- Entity/Relational Tables
- Data Files
- Documents (XML/HTML)
- Etc.
Hardware Internals:
- CPU
- Computer Hardware Components (monitor, keyboard, etc.)
- Network Components
The static arrangement of these elements (software and data) defines (depending on the context) partnerships, relationships, or connectedness between them.
System Dynamics Structures
Show how the system operates at runtime.
Externally Visible Properties
External properties manifest in two ways:
- Behavior visible to the outside
- Quality Attributes
Behavior Visible to the Outside
These properties relate to the system’s function from an outside observer’s perspective. More specifically, it relates to the functional interactions between the system and its environment.
Quality Attributes
External properties related to non-functional system requirements such as performance, safety, and maintenance.
Candidate Architecture
A candidate architecture for a particular organization comprises dynamic and static structures that potentially exhibit the required behavior and quality attributes.
The relationship between a system’s externally visible properties and its internal composition is as follows:
- Externally visible behavior (what it does) is determined by the combined behavior of the internal elements.
- The quality properties of a system, like performance, scalability, and reliability (how it does), emerge from the quality properties of the internal elements.
Component Element (Architectural)
A component or architectural element is a cornerstone for building a system. Components must have clearly defined attributes:
- A set of responsibilities
- A limit or extent
- A set of interfaces that define the services the component provides to other components
Stakeholders
A stakeholder in an architecture is a person, group, or entity with an interest in developing a system.
Architectural Styles
An architectural style is a descriptive mechanism to differentiate one building from another. While inventing a new software architecture for each information system is possible, it’s common to adopt an existing architecture based on its advantages and disadvantages for a particular case. Some universal architectures include:
Client-Server
The software distributes its computational burden into two separate parts without a clear assignment of roles. It consists of a client making requests to another program (server) that responds.
Client-Server Components:
- Presentation Logic: Interacts with an end-user device (terminal, barcode reader, laptop)
- Business Logic: Uses user information and the database for transactions under business rules constraints
- Database Logic: Manipulates data within the application
- Database Processing: The actual processing of data from the database by the DBMS
Client/Server Benefits:
- Centralization of control
- Scalability
- Easy maintenance
Client/Server Disadvantages:
- Traffic congestion
- Increased cost
Layered Architecture
A specialized client-server architecture where the load is divided into three layers with a clear division of functions: presentation (user interface), calculation (business modeling), and storage (persistence). A layer only interacts with the one below it.
Layers and Levels:
- Presentation Layer: Visible to the user (GUI)
- Business Layer: Where programs run, receive user requests, and send responses after processing
- Data Layer: Where data resides and is accessed
The terms “layers” and “levels” are not identical. “Layers” refer to the logical segmentation of a solution (presentation, business logic, data), while “levels” correspond to how logical layers are physically distributed.
Pipes and Filters
- Each component has inputs and outputs
- Output can start before finishing input reading
- Components transform data (filters)
- Connectors transmit data (pipes)
This style emphasizes the incremental transformation of data through various components.
Advantages of Pipes and Filters:
- Easy to understand and compose filters
- Supports reuse of filters in other systems
- Easy to maintain and improve by replacing or adding filters
- Supports concurrent execution
Blackboard
Consists of a central data repository (blackboard) and active components surrounding it.
- Components examine the blackboard, perform tasks, and write conclusions back to it
- Components can work on results generated by others
- Computation ends when a desired condition is achieved on the blackboard
A control component can activate processing components based on a schedule or by inspecting the blackboard to determine the best element to act next.
Blackboard Style Quality Attributes:
Performance: A strength due to parallel processing and focused computation.
Maintainability: A strong aspect as components are independent and can be added or removed without affecting others.
Reliability: Considerations include data integrity on the blackboard and error handling in components.
Object-Oriented Systems
- OO style organizes the system in terms of communication between objects.
- Objects are entities that contain state and operations to access and change its status.
An object usually need to send messages to other objects, so each object is required to keep references to objects to which it relates.