Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views8 pages

Unit III

The document explains monolithic architecture in software development, highlighting its limitations such as tight coupling and lack of modularization through an example of a program calculating the area and perimeter of a circle. It contrasts this with service-oriented architecture (SOA), which promotes modularity and reusability by using independent services that communicate through a common interface. The document also outlines the components and layers of SOA, emphasizing its advantages and disadvantages.

Uploaded by

deepaliv.patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views8 pages

Unit III

The document explains monolithic architecture in software development, highlighting its limitations such as tight coupling and lack of modularization through an example of a program calculating the area and perimeter of a circle. It contrasts this with service-oriented architecture (SOA), which promotes modularity and reusability by using independent services that communicate through a common interface. The document also outlines the components and layers of SOA, emphasizing its advantages and disadvantages.

Uploaded by

deepaliv.patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Monolithic architecture is a software development model that uses a single code base to perform

multiple functions.

a simple program that calculates the area and perimeter of a circle using a fixed value of π (pi)
would be considered monolithic because:

✅ All functionalities (area and perimeter calculations) are tightly coupled in a single codebase.
✅ It does not have modular or independent services—everything is done within one function or
script.
✅ It lacks flexibility—if you want to modify the formula (e.g., use a different value of π or switch to a
different calculation method), you would need to update the entire code.

Example of a Monolithic Approach

python

CopyEdit

# Monolithic Program: Calculate Area & Perimeter of a Circle

def calculate_circle(radius):

pi = 3.14159 # Fixed value of pi

area = pi * radius * radius

perimeter = 2 * pi * radius

return area, perimeter

radius = 5

area, perimeter = calculate_circle(radius)

print(f"Area: {area}")

print(f"Perimeter: {perimeter}")

Why is this Monolithic?

 Single Function for All Operations: Both area and perimeter are calculated within the same
function.

 Hardcoded Pi Value: If we want to use a different π value or an external library, we must


modify the code.

 No Modularization: There's no separation of concerns—everything is handled in one


function.

How to Make It More Modular (Closer to Microservices or SOA)?


1️⃣ Using Modular Functions (Better Structure but Still Monolithic)

python

CopyEdit

# Modular Approach (Still Monolithic)

def get_pi():

return 3.14159 # Modularizing Pi Value

def calculate_area(radius):

return get_pi() * radius * radius

def calculate_perimeter(radius):

return 2 * get_pi() * radius

radius = 5

print(f"Area: {calculate_area(radius)}")

print(f"Perimeter: {calculate_perimeter(radius)}")

✅ Improves structure, but still runs as a single program.

2️⃣ Service-Oriented Architecture (SOA) Approach

Each calculation is a separate service, and they communicate via a common service layer (e.g., API
calls).

python

CopyEdit

# SOA Approach: Different services for Area & Perimeter

class MathService:

def get_pi(self):

return 3.14159

class CircleService:
def __init__(self):

self.math_service = MathService() # Using another service

def calculate_area(self, radius):

return self.math_service.get_pi() * radius * radius

def calculate_perimeter(self, radius):

return 2 * self.math_service.get_pi() * radius

circle_service = CircleService()

radius = 5

print(f"Area: {circle_service.calculate_area(radius)}")

print(f"Perimeter: {circle_service.calculate_perimeter(radius)}")

✅ More modular—one service (MathService) is responsible for π, and another (CircleService)


handles circle calculations.

https://www.youtube.com/watch?v=PA9RjHI463g

https://www.youtube.com/watch?v=QDgaQD3F6kA

https://www.youtube.com/watch?v=-3gu6clLn8w

https://www.youtube.com/watch?v=WMTElFeexno

What is service-oriented architecture?

Service-oriented architecture (SOA) is a method of software development that uses software


components called services to create business applications. Each service provides a business
capability, and services can also communicate with each other across platforms and languages.
Developers use SOA to reuse services in different systems or combine several independent services
to perform complex tasks.

For example, multiple business processes in an organization require the user authentication
functionality. Instead of rewriting the authentication code for all business processes, you can create a
single authentication service and reuse it for all applications. Similarly, almost all systems across a
healthcare organization, such as patient management systems and electronic health record (EHR)
systems, need to register patients. These systems can call a single, common service to perform the
patient registration task.

SOA is a service-oriented architecture is basically a kind of design pattern where we are trying to use
different services or loosely coupled services to create a complete application.

e.g. I am developer and I am trying to create Uber app so what are the things required to create one
Uber app

1. login page

2. map where all the drivers and customers who can see where the cars are

3. payment gateway

So as a developer I can create these three services by myself od I can use the already available
services in the market.

Means I can use third party login page like Facebook, google to create login. I can use is the Google
map service for map. Same for payment gateway.

To create an application I have two choices first one create my own services which is going to take lot
of time or I can use the already available services in the market which is fast . that is the service
oriented architecture.

Advantages

1. Reusability
2. Flexibility:
3. Modularity:

Disadvantages:

1. Complexity:
2. Cost:

What are the components in service-oriented architecture?

There are four main components in service-oriented architecture (SOA).

Service

Services are the basic building blocks of SOA. They can be private—available only to internal users of
an organization—or public—accessible over the internet to all. Individually, each service has three
main features.

Service implementation
The service implementation is the code that builds the logic for performing the specific service
function, such as user authentication or bill calculation.
Service contract

The service contract defines the nature of the service and its associated terms and conditions, such
as the prerequisites for using the service, service cost, and quality of service provided.

Service interface

In SOA, other services or systems communicate with a service through its service interface. The
interface defines how you can invoke the service to perform activities or exchange data. It reduces
dependencies between services and the service requester. For example, even users with little or no
understanding of the underlying code logic can use a service through its interface.

Service provider

The service provider creates, maintains, and provides one or more services that others can use.
Organizations can create their own services or purchase them from third-party service vendors.

Service consumer

The service consumer requests the service provider to run a specific service. It can be an entire
system, application, or other service. The service contract specifies the rules that the service provider
and consumer must follow when interacting with each other. Service providers and consumers can
belong to different departments, organizations, and even industries.

Service registry

A service registry, or service repository, is a network-accessible directory of available services. It


stores service description documents from service providers. The description documents contain
information about the service and how to communicate with it. Service consumers can easily
discover the services they need by using the service registry.

How does service-oriented architecture work?

In service-oriented architecture (SOA), services function independently and provide functionality or


data exchanges to their consumers. The consumer requests information and sends input data to the
service. The service processes the data, performs the task, and sends back a response. For example,
if an application uses an authorization service, it gives the service the username and password. The
service verifies the username and password and returns an appropriate response.

Communication protocols

Services communicate using established rules that determine data transmission over a network.
These rules are called communication protocols. Some standard protocols to implement SOA include
the following:

• Simple Object Access Protocol (SOAP)


• RESTful HTTP
• Apache Thrift
• Apache ActiveMQ
• Java Message Service (JMS)

You can even use more than one protocol in your SOA implementation.
Fig shows components of SOA

Service-Oriented Architecture (SOA) Layers Model

SOA follows a layered architecture model to organize services efficiently. This model ensures
reusability, scalability, and maintainability. There are typically 5 main layers in SOA:

1️⃣ Consumer Layer (Presentation Layer)

🔹 This is the front-end layer where users interact with the application.
🔹 It includes web applications, mobile apps, or desktop applications that consume services.
🔹 Users request services via a UI or an API call.

Example:
 A user opens a food delivery app (Uber Eats, Swiggy) to order food.

 The UI sends a request to fetch restaurant details via an API.

2️⃣ Business Process Layer (Orchestration Layer) ⚙️

🔹 This layer manages the workflow and logic of business processes.


🔹 It decides how services interact with each other.
🔹 Uses orchestration (coordinating multiple services) or choreography (services working
independently).

Example:

 When a user orders food, this layer decides the sequence:


1️⃣ Check restaurant availability
2️⃣ Process payment
3️⃣ Assign delivery personnel
4️⃣ Send notifications

🔹 Uses BPM (Business Process Management) tools like Apache Camel, IBM BPM, or Camunda.

3️⃣ Service Layer (Application Layer)

🔹 Contains the actual services that perform business tasks.


🔹 Services are loosely coupled and reusable.
🔹 Services are typically SOAP or REST APIs.

Example Services in a Food Delivery App:

✅ User Service – Handles login & authentication.


✅ Order Service – Processes food orders.
✅ Payment Service – Handles transactions.
✅ Notification Service – Sends emails/SMS updates.

4️⃣ Integration Layer (Messaging Layer) 🔄

🔹 Facilitates communication between services using a middleware like Enterprise Service Bus (ESB).
🔹 Ensures services can communicate regardless of technology differences.
🔹 Uses message queues, APIs, and protocols (e.g., JMS, RabbitMQ, Kafka).

Example:

 The Order Service sends a message to the Inventory Service to check stock before
confirming an order.

 If using Kafka, services can communicate asynchronously.

5️⃣ Data Layer (Persistence Layer)


🔹 Stores and manages data for the entire system.
🔹 Can include SQL databases, NoSQL databases, or cloud storage.

Example:

✅ Customer Database – Stores user profiles & past orders.


✅ Order Database – Stores active & completed orders.
✅ Transaction Database – Stores payment history.

SOA Layers Model - Summary Table

Layer Purpose Example in Food Delivery (Uber Eats, Swiggy)

Consumer Layer User Interface & Clients Mobile app, website, chatbot

Business Process Defines workflow & business Handles order processing, assigns delivery
Layer logic agents

Implements business services Order Service, Payment Service, Notification


Service Layer
(APIs) Service

Middleware & message


Integration Layer Kafka, RabbitMQ, Enterprise Service Bus (ESB)
exchange

MySQL for user orders, MongoDB for


Data Layer Stores & manages data
restaurant menus

You might also like