Component Based Architecture

Revamping the architecture thoughts

Mar 31, 2019 · 8 min read


Almost every application, framework, online tutorial, everything these days is around the idea of layered architecture, where we have controllers, service, and data model layers.

  • They can’t communicate or don’t communicate.
  • They don’t match the code.
  • They are just a bunch of fluffy boxes.

Layered architecture

Perhaps, this is the most widely used, it is everywhere. Almost all the applications are built around it. It is easy to understand and good to start.

  • The business layer: enforce the business rules on the data (customer can’t withdraw from an empty account)
  • The data layer: connects to the database to query, and update the data. These are often called data access objects (DAO).
Layered architecture — Link
Layered architecture — Link

Ports and adapters architecture

Onion architecture, and hexagonal architecture are all around the idea of decoupling the domain objects from its implementation.

Ports and adapters, onion, hexagonal architecture — Link
private OrderService orderService 
= new OrderService(new JDBCOrdersRepository())

Feature-based architecture

In this pattern, we organize the code based on what it does from the functional perspective. It is a vertical slicing. We group together code related to a certain feature.

Feature-based architecture — Link

Component-based architecture

A hybrid approach between layered and feature-based architecture.

Component-based architecture — Link
  • Components can talk to each other through their interface unlike in feature-based architecture where service classes are hidden, and the only way to communicate is through the controller.

C4 Model

The C4 model is a formalized approach used to visualise software architecture based on the idea of components.



How do you know which pattern is better?

Thank you for reading!

Feel free to reach out on LinkedIn or Medium.

OmarElGabry's Blog

This is my freedom area. Don't underestimate it. The devil is in the detail.


Written by

Software Engineer. Going to the moon 🌑. When I die, turn my blog into a story.

OmarElGabry's Blog

This is my freedom area. Don't underestimate it. The devil is in the detail.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade