Comprehensive Guide to Distributed Programming, Middleware, and Software Quality
Three-Layer Architecture in Distributed Programming
A distributed system is frequently structured into three distinct layers, often referred to as the Three-Layer Architecture. These layers can reside on different machines and require communication mechanisms to interact over a network.
Presentation Layer: This layer provides the user interface to the client. It is the primary point of interaction for the user.
Application Logic Layer: This layer defines the core functionality and business logic of the system. It processes the rules that govern how data can be created, stored, and changed.
Resource Manager Layer: This layer manages the data required by the application logic. This management is typically handled through a database.
Middleware and Distributed System Communication
Middleware serves as a foundational component of distributed systems. It is a software layer positioned between the operating system and the applications residing on different network nodes.
Function: Middleware enables distributed components to communicate without requiring developers to manually manage low-level network details.
Communication Types:
Synchronous Communication (Sync):
The sender transmits a request and waits for a response from the receiver before continuing its own processing.
Characteristics: The sender is blocked until the response arrives. Both the client and the server must typically be available at the same time.
Example: Checking a bank balance before allowing a withdrawal. The system must wait for the definitive result before proceeding.
Asynchronous Communication (Async):
The sender sends a message and continues its processing tasks without waiting for an immediate response.
Characteristics: The receiver can process the message at a later time. The sender remains unblocked.
Examples: Sending an email or processing a large image. The system does not require an immediate result to continue operation.
Remote Procedure Call (RPC)
RPC is a synchronous mechanism that allows a program to execute a function on a remote computer as if it were a local function call. It is designed to hide the complexities of the network from the developer.
Mechanism: A developer writes a call like
. While it looks like a normal function call, the actual execution happens on another machine.Stubs:
Client Stub: Located on the sender side. It packs the function parameters into a message through a process called Marshaling and sends them over the network.
Server Stub: Located on the receiver side. It unpacks the message through Unmarshaling to call the actual function on the server.
Advantages of RPC:
Hides network complexity.
Makes remote calls appear as local function calls.
Provides an easy programming abstraction.
Disadvantages of RPC:
Both client and server must be active simultaneously (Tightly coupled).
Failure recovery is often complex.
Network issues make remote calls less reliable than local calls.
Message-Oriented Middleware (MOM)
MOM supports asynchronous communication. Instead of calling a function directly, components exchange messages through a queue or a broker (Message Broker).
Key Characteristics:
Asynchronous: The sender transmits the message and continues working.
Reliable: Messages can be stored in persistent queues.
Loose Coupling: The sender and receiver do not need to be active at the same time.
Examples of Brokers: Apache Kafka, RabbitMQ.
Main Disadvantage: Introduces extra components (brokers or event services), which increases architectural complexity and can result in slower performance.
Communication Pattern: MOM often uses a Publish-Subscribe (Pub-Sub) pattern.
Publisher: Sends messages into the system.
Subscriber: Receives messages that match its specific interests.
Message Filtering:
Topic-based Filtering: Subscribers receive messages depending on the topics they have subscribed to.
Content-based Filtering: Subscribers receive messages based on the actual content within the message.
Advanced Message Queuing Protocol (AMQP)
AMQP is a standard protocol for reliable message exchange between systems. It supports asynchronous communication and facilitates proper communication between different platforms and programming languages.
Application Delivery Models: ASP and SaaS
Application Service Provider (ASP): A company that hosts and manages software for customers. Customers access the application over the internet rather than installing and maintaining it on their own servers.
Example: Salesforce. It stores customer information, tracks sales, manages leads, and creates reports.
Software-as-a-Service (SaaS): A software delivery model where software is centrally hosted and licensed on a subscription basis.
Examples: ChatGPT, Canva, Claude Code.
Web Services
Web services provide a standardized way to expose applications as services, helping solve integration problems and enabling the development of internet-native applications.
Types of Web Services
Informational Services: Provide data access through applications or request-response interactions.
Complex Services: Combine multiple services and coordinate complex application logic.
Web Service Programming Styles
Synchronous / RPC Style: The client invokes the service with arguments and waits for a response.
Asynchronous / Document Style: The client sends a full document as a parameter, and processing may occur asynchronously.
Core Characteristics and Definitions
Well-definedness: A web service must define the rules for interacting with it.
Service Interface: Defines the visible functionalities of the service and how external applications can access them.
Service Implementation: The actual code that realizes the service interface and performs the required work.
Advantages and Disadvantages of Web Services
Advantages:
Standard way to expose applications.
Solves application integration problems.
Allows internet-native application development.
Enables software component reuse.
Supports cross-platform communication.
Disadvantages:
Usually less performant than traditional middleware.
May lack business semantics.
Can suffer from standardization issues.
Network communication adds overhead.
Simple Object Access Protocol (SOAP)
SOAP is a messaging protocol used by web services to exchange structured information. It is often connected with RPC-style communication.
SOAP and HTTP: SOAP is often sent over HTTP (Hypertext Transfer Protocol). It uses standard web ports: and . This allows SOAP to use existing web infrastructure.
Message Structure (XML Document):
Envelope: The root element that identifies the document as a SOAP message.
Header: Optional metadata, including security or routing information.
Body: Contains the actual application data or the method call.
Fault: Used for reporting standardized errors.
Advantages of SOAP:
Strong standardization.
XML-based structure.
Supports strict contracts.
Features enterprise-level standards like WS-Security.
Disadvantages of SOAP:
Slower than REST.
More verbose/heavy due to XML.
More rigid and complex.
Extensible Markup Language (XML)
XML is a plain text document format used to store structured data through customizable tags. Below is an example structure:
<?xml version="1.0"?>
<!DOCTYPE customers [
<!ENTITY add1 "15, G Street, Chennai, india">
<!ENTITY add2 "25, C Street, Bangalore, india">
]>
<customers>
<CUSTOMER>
<NAME> James </NAME>
<ADDRESS> &add1; </ADDRESS>
<PHONE>805056</PHONE>
</CUSTOMER>
<CUSTOMER>
<NAME>Jerry </NAME>
<ADDRESS>&add2;</ADDRESS>
<PHONE>8904425</PHONE>
</CUSTOMER>
</customers>
Representational State Transfer (REST)
REST is a set of design rules for building web software and services. Services utilizing REST are known as RESTful services.
Core REST Principles
Statelessness: The server does not store client context between requests.
Client-Server Architecture: The client (handling the UI) and the server (handling data and logic) are separated.
Uniform Interface: Resources are accessed in a consistent way through URIs (Uniform Resource Identifiers) and HTTP methods.
Cacheability: Responses must specify whether they can be stored and reused. Example:
ext{Cache-Control: max-age=3600}indicates a response can be cached for one hour.
Uniform Interface Components
URIs: Example:
/users/1.HTTP Methods:
GET: Retrieve a resource.
POST: Create a new resource.
PUT: Replace or update a resource.
PATCH: Partially update a resource.
DELETE: Remove a resource.
Standard Media Types: REST supports data formats such as JSON (most common for being lightweight), XML, Plain Text, and HTML.
Advantages and Disadvantages of REST
Advantages:
Scalable due to statelessness.
Good performance with lightweight formats like JSON.
Flexible and easy to test.
Cross-platform compatibility.
Simpler than SOAP for many applications.
Disadvantages:
No built-in strict contract (requires external documentation like Swagger/OpenAPI).
Security is not built-in (relies on HTTPS, OAuth, etc.).
SOAP vs. REST Comparison Summary
Feature | SOAP | REST |
|---|---|---|
Type | Protocol | Architectural Style |
Data Format | XML only | JSON, XML, Text, HTML |
Orientation | Function/RPC-oriented | Resource-oriented |
Strictness | More strict and standardized | More flexible and lightweight |
Security | Built-in enterprise standards | Relies on HTTP standards/external mechanisms |
Performance | Heavier messages | Usually faster and simpler |
Software Quality and ISO 25010
Software Quality is the degree to which a software system, component, or process satisfies specified requirements and customer expectations.
Views of Quality:
User View: Quality means "fitness for purpose" (helping users achieve goals).
Manufacturing View: Software matches the defined technical requirements.
Quality Standards: Supported by ISO 9001, CMMI, and ISO 25010.
ISO 25010 Product Quality Model
This model defines 8 characteristics for evaluating software product quality:
Functional Suitability: Software provides functions needed by users (e.g., functional completeness).
Performance Efficiency: Software performs well relative to resources used (e.g., response time, resource usage).
Compatibility: Software works with other systems or shares environments (e.g., interoperability with payment systems).
Usability: Software is easy and effective to use (e.g., learnability).
Reliability: Software works correctly under specified conditions over time (e.g., availability or uptime).
Security: Software protects data and controls access (e.g., number of vulnerabilities, confidentiality).
Maintainability: Software can be modified easily by developers (e.g., modularity).
Portability: Software can be transferred to different environments (e.g., installability on different operating systems).