Skip to content

Commit

Permalink
Added better explanation and updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sugan0tech committed Oct 17, 2023
1 parent cf06c64 commit 24d5063
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
43 changes: 30 additions & 13 deletions vertical-slice-architecture/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Vertical-Slice-Architecture
aka: Layer-By-Feature
title: Vertical Slice Architecture
aka: Layer By Feature
category: Architectural
language: en
tag:
Expand All @@ -9,21 +9,38 @@ tag:

## Intent

package the application based on features. Each feature will have its own set of layers (
Models, Services, Repository and Controllers ).
Organize the application according to its features.
Each feature will comprise its distinct set of layers (Models, Services, Repository, and Controllers).

## Explanation

> With vertical slice architecture we can have high cohesion within package and low coupling
> among the packages. In Conceptual term
Real-World Examples (Consider E-commerce)

> Consider that you are going to make a backend service for a online e-commerce application.
> initially you make it with usual grouping of controllers, models etc. but as the application
> grows more it's requires implementation of new features. Let's say that you thought of having
> orders, customers and products associated layers. But now you need to include another set of
> features with Cart system and wishlists. Now it's really hard to integrate those features it
> requires lot's of dependency modifications and mocking. So if you make the package by feature
> it will be really feasible for future additions. General example.
> In the context of an e-commerce application, the concept of vertical slice architecture becomes clear.
> Imagine you're building a backend service for an online store.
> Initially, you may organize it with the typical grouping of controllers, models, and other components.
> As the application grows, the need arises to implement new features.
> For instance, you might have distinct layers for orders, customers, and products. However, as the application
> evolves, you realize the necessity of integrating additional features like a Cart system and wishlists.
> At this point, integrating these new features into the existing structure becomes challenging.
> It demands significant dependency modifications and mocking, which can be time-consuming and error-prone.
> This is where vertical slice architecture proves its value.
> By structuring the application based on features,
> you create self-contained modules that encapsulate all the necessary components
> (Models, Services, Repository, and Controllers) for a particular feature.
> When you need to add new features, you can do so in a more isolated and manageable manner.
In Plain Words

> Vertical slice architecture is like organizing your toolbox.
> Instead of having all your tools mixed together, you group them based on the type of task they perform.
> This way, when you need a specific tool for a particular job,
> you can quickly find it without rummaging through a jumble of items.
> Similarly, in software development, vertical slice architecture involves organizing the codebase based on features.
> Each feature has its own self-contained set of components, making it easier to add, modify, or remove features without disrupting the entire application.
## Class diagram

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* Main application.
* The main objective of this code sample is for you to have a look at how the view, entity, repository and Service are
* organized.
* No matter what application you are building Layer by Feature will always give the upper hand of better
* maintainability.
* This application is designed with a vertical slice architecture, organizing features such as
* customer management, order processing, and product catalog in separate modules. Each feature encapsulates
* its own set of components (Models, Services, Repository, and Controllers), promoting high cohesion
* within each module and low coupling between them. This architecture allows for seamless integration of new
* features and functionalities as the application evolves over time.
*/

@SpringBootApplication
Expand Down

0 comments on commit 24d5063

Please sign in to comment.