The main task of software architecture is to design components and their connections in a software application. That process is a critical component of the software development life cycle (SDLC) design stage. In the best-case scenario, the software architecture style of choice needs to address all company’s technological needs and reflect its long-term vision.
Besides, according to Robert Martin, author of “Clean Architecture”, software architecture has to facilitate four major product goals. These are end-to-end software development, tech maintenance, use cases and operation, and deployment. But which architecture style should you choose, and what are its benefits over another in a project? In this article, I’ll elaborate on some of the most crucial aspects of software architecture styles.
What is good (clean) architecture?
Before we dive into the details around the three exceptionally widespread architecture styles in software projects, we only need to touch on the universal properties of clean architecture.
Robert Martin, author of “Clean Architecture,” says that “The only way to go fast is to go well”. It is worth taking your time to do things well as opposed to releasing working but inflexible solutions with bugs. Later on, these might require additional fixing, and it all becomes inefficient. A well-designed and neatly structured architecture helps your business minimize both business and technical risks. Or, as our CTO Angel Gruev puts it in his blog post on the importance of clean architecture:
“Software is something flexible and was intended to change the behaviour of machines easily. If it loses this ability, then it can no longer reflect the changes in the business needs, and so it becomes not only useless but also a burden.”
With that in mind, here are the top five features of clean architecture:
- Relevance – Which are the high-level system-specific requirements and decisions?
- Maintainability – How much effort and resources will the system’s technical maintenance require?
- Adaptability – – Will the architecture be easily integratable and adaptable to existing software products in the company?
- Scalability – Based on its software architecture, will the solution be future-oriented and scalable as the business grows?
- Security – How secure does the connection in a web application need to be, and does the app need SSL certificates or data encryption?
Overview of software architecture styles
The term “software architecture” doesn’t refer to а detailed design of a software system. Instead, it describes the primary connections between various requirements and abstraction layers of the system. Thus, the choice of a specific architecture type impacts the non-functional, qualitative properties of the system. Prior to deciding on the architecture style of an application, developers must be aware of both functional and non-functional requirements. For example, let’s say a web application should load payment information whenever users click on “purchase”. This would be a functional requirement. Non-functional ones can be the app’s response time or system load, e.g. a max. number of users paying at the same time.
As you can see, software architecture lays the solid foundation of a reliable, scalable and high-performing application.
Let’s now shed light on architecture styles and architecture and design patterns. While some software developers may use the three interchangeably, others see things differently. They insist on more explicit, narrowly-focused definitions and treat architecture patterns as having more than styles. In his article, Herberto Graca, a Dutch developer and software architect, explains each one of them:
- Architectural styles reflect the highest level of granularity, the primary modules in a custom software application, as well as the interaction between those modules. Notable examples include monolithic, service-based and event-driven architectures.
- Architectural patterns refer to a specific solution to a recurring problem. Patterns impact an application both vertically (layer communication) and horizontally (code structure). Some of the most widely used ones today are microservices, event-driven and layered (n-tier) architecture patterns.
- Design patterns are the ones with the lowest impact on the code base and the entire application. They have a more local focus, influencing only certain aspects of the entire code, such as factory classes or object states.
A monolithic software architecture style is the traditional unified model for designing software as one cohesive unit. In software architecture, monoliths are software structures that provide many functions together in one fixed service that can’t be separated. By design, monolithic software is independent and consists of only three instances:
- user interface (UI)
- server-side application
These three elements and all their components, such as the front-end logic of the UI and the back-end processes of the server logic, are all stored in the same massive code base. Normally, this design makes it extremely inflexible to bring new changes into the system. If developers need to make any changes and updates, they have to build and deploy the entire stack from scratch. And this is an expensive and time-consuming venture.
However old this type of architecture may be, we can’t say it’s obsolete as it still finds use cases. In fact, Martic Fowler, a software developer and author, advocates for using the monolithic approach when first building a new app and then refactoring it into layered or microservices types (see below).
The biggest advantage of monoliths is that most apps have lots of overlapping points, e.g. user logging or data security functions. These are easier to manage in monolithic architectures as everything runs through the same app, and it’s easy to connect components horizontally.
Additionally, app performance might also benefit from this architecture style since there is no communication between individual services but only in one cohesive unit.
Monolithic vs. layered architecture
As I mentioned above, whenever a software project gets too big and complicated, the monolithic architecture becomes obsolete. In such cases, developers can begin building additional layers (or tiers) to the business logic of the application that will suit the complexity of the app better. In layered architecture, software architects build various operating system components on top of one another. Each new layer (n>1) aims to reduce the complexity of the whole app. One prominent example of a layered architecture subtype is the 3-Tier architecture that separates the logic between a presentation layer (webserver), an application layer (business logic) and a data access layer (database).
The transitions between the different layers happen through interfaces, whereby the transitions must be clean without sudden “jumps” (e.g. from an application program directly into the data structure). In the layered architecture, communication takes place via the interfaces of each individual intermediate layer. Compared to monolithic architecture, the most important advantage of the layered one is that it introduces the so-called separation of concerns (SoC) principle. The SoC principle divides an application into distinct sections, each of which is responsible for something else, allowing app cohesion and better code clarity.
Main goals of the monolithic architecture
These are the top three goals of monolithic architectures:
- Easy to test apps – fewer app components equal fewer testing variables and quicker and easier testing and QA.
- Lower latency – having more than one component can slow down the system reaction time and request processing speed, but monolithic architecture aims to accelerate response time and improve performance.
- Reduced business costs only one application needs to be set up for logging, monitoring and testing, reducing the total overhead.
The monolithic structure best suits projects in the following three case scenarios:
- A product in an early development stage: If you’re building a product that hasn’t proven its viability yet, the monolithic architecture is a reasonable choice. It enables you to release new versions in short intervals as part of further development.
- Small-scale projects: For small-scale projects with small-sized teams and a simple business logic, a monolith often makes more sense at first. As the business expands, the monolith application can be refactored into a layered one or microservices-based.
- Quick “go live”: In case you need faster time-to-market and the project needs to “go live” quickly, monoliths are the best option because of their fast development and quicker testing.
Service-oriented architecture (SOA)
The main idea behind the service-oriented architecture (SOA) is to divide the system logic between several independent services. This is in contrast to keeping it in a large unified model like it is in the traditional monolithic architecture. The small system chunks are loosely-coupled services. Each service represents one business feature or process and can interact with the others through the Enterprise Service Bus (ESB). Ideally, the SOA architecture is based on business processes whose individual abstraction levels act as the basis for concrete service implementations.
Then, depending on the needs of the particular business process, each service embodies the code and data integrations needed to execute the process. Examples from a healthcare software application with SOA structure include:
- checking the patient’s insurance status
- calculating risk factors based on lifestyle habits
- personalising the medical healthcare journey with visuals.
Since services in SOA are rather small and changes in one of them do not affect the others, QA experts can do performance tests quicker.
SOA vs. Microservices
The most widespread software architecture pattern among the SOA architecture style is microservices. While SOA is an enterprise-wide concept, the microservice architecture is an application-specific one. It’s used to break down complex applications into smaller, independently deployed pieces called “services”. One of the greatest benefits of the SOA approach is that it improves the collaboration between business and IT. Thus, SOA allows business analysts to work more effectively with developers to uncover important insights. For example, these could be business process scopes or a potential business impact of changing an existing process.
Microservices, on the other hand, come with some specifics, such as their own technology stack, including a database and data management model. Plus, microservices have the so-called “limited context”, meaning one microservice is only responsible for one business function. Their typical way of communication with each other is through a combination of REST APIs, event streaming, and message brokers. They’re managed using DevOps practices. Among the greatest advantages of choosing microservices is that components can be scaled independently. This helps reduce inefficiencies and costs associated with scaling entire applications. Besides, development teams can use different tech stacks and even different programming languages for different components, which supports agility and flexibility.
Main goals of the SOA architecture
Here are the main ideas behind SOA:
- Independence – SOA aims to structure the software solution’s components or business processes into independent services. These are activated only when needed, providing high system availability.
- Easy integration – this approach provides a way of publishing available services and their functionalities. Input/Output makes the services easily integrable into software applications.
- Effective control – – SOA effectively controls independent services and avoids governance issues.
SOA- suitable projects
The three most suitable project types for SOA are as follows:
- Core and business-critical applications such as eCommerce platforms, transportation software, messaging systems, etc.
- Modernization and migration of monolith legacy systems that are becoming obsolete.
- Data integration platforms that access multiple databases such as complex ERP or CRM systems.
Event-driven architecture (EDA)
Events are the main means of controlling the application’s flow within the event-oriented programming paradigm and event-driven architecture (EDA). For instance, such an event can be some type of user input. Also, a message outside of the defined system limits that affect the program flow can also be set as an event. Event-driven software contains handling routines that trigger a program’s internal corresponding reaction to the external influence. A typical event usually consists of three basic elements:
- a timestamp (when did it occur)
- a source (what triggered the event)
- a type (what happened exactly).
The main benefit of an event-driven architecture is that it allows a large number of producers and consumers to exchange status and response information in near real-time, e.g. a FinTech software solution or a mHealth app. Plus, EDA is most effective when existing business rules, triggers, and business procedures are available to the event broker (middleware software). The event broker then takes care of forwarding the message to all software components (event consumers) that have registered for events of this type.
SOA vs. EDA architectures
Event-driven architecture is not intended to replace the SOA architecture approach but to complement it. Both approaches have different notions depending on the business logic. While the service-oriented architecture is linear & process-oriented and relies heavily on pre-defined business processes, the event-driven architecture cherishes the flexibility of adapting business processes on the go. This can make EDA-based apps more flexible than SOA-based ones.
The decision to use one over the other will depend on the specific functional and non-functional requirements of your business software. The end goal of your desired application will determine your choice of software architecture. For example, will the software product have to integrate with your existing infrastructure and take over the communication between different applications? In this case, SOA would be the better option. However, if your wish is to create a business app around events and maximise the use of existing data, then EDA is the to-do choice.
Main goals of the EDA architecture
The key drivers behind the EDA architecture are:
- Flexibility – using event-driven architecture allows scaling software applications up and down when needed. It can also handle massive data amounts for advanced analytics.
- Asynchronous communication – EDA’s communications are asynchronous without blocking. This means that if an event triggers a service and starts responding to the event, it doesn’t block other services from running or responding. This aspect makes EDA more flexible and adaptable than a monolithic one.
- Cost reductions – in EDA, everything happens in response to an event. Therefore, network bandwidth consumption, CPU utilization and encryptions are comparatively lower than other software architecture styles.
The following projects are best suited for EDA architecture:
- Heterogeneous systems – a heterogeneous system runs on multiple different tech stacks, and using EDA helps to effortlessly exchange information between them. The event router takes responsibility for the interoperability between the systems.
- Real-time reacting apps – EDA is an ideal software architecture if the project requires some real-time reactions to occurring events, such as stock trading apps, custom processing or supply networks.
- Monitoring systems – EDA capabilities could really benefit tracking, scheduling or monitoring systems with massive amounts of data. Plus, if your project requires a full record of all events’ history, EDA is the right choice of architecture.
Now that we’ve covered the basic properties of every good architecture and you know the most widely used software architecture styles, you’ll be able to make a better-informed decision about your next tech project. In case you need further support, our experienced developers would be glad to consult you about the software architecture development your particular project will benefit most from.