Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Clean Architecture to architectures #95

Open
bit-jkraushaar opened this issue May 5, 2023 · 6 comments
Open

Add Clean Architecture to architectures #95

bit-jkraushaar opened this issue May 5, 2023 · 6 comments
Assignees
Labels
lifecycle: waiting-for-feedback Feedback by the original reporter needed module: architecture Architectural style related support type: enhancement New feature or request

Comments

@bit-jkraushaar
Copy link

I've checked if this was proposed in the past, but have not found anything on this topic.

I love the idea of xmolecules / jmolecules, but I miss Clean Architecture as alternative to Onion and Hexagonal architecture.

Are there any circumstances which prohibit implementation of this architecture? (e.g., licensing issues)

@odrotbohm
Copy link
Member

odrotbohm commented Jul 10, 2023

There's no real impediment to doing this except the question: what would that look like? Uncle Bob's article basically used Onion Architect, gave the rings different names, and made up a new word that could be associated with him. There are folks, that claim it's not even a new, separate style.

In other words, I wonder how useful it is to basically copy the OA implementation and rename the rings. IMO, CA only adds negligible (if at all) value over the “alternatives” (which they really aren't because they're effectively the same).

@odrotbohm odrotbohm self-assigned this Jul 10, 2023
@odrotbohm odrotbohm added type: enhancement New feature or request module: architecture Architectural style related support lifecycle: waiting-for-feedback Feedback by the original reporter needed labels Jul 10, 2023
@bit-jkraushaar
Copy link
Author

I agree that both architectures look very similar. I also agree that it is possible to use the existing Onion Architecture annotations to represent Clean Architectures. In my opinion, the meaning of the layers slightly differs from OA to CA. I also think that CA is a little bit more rigid regarding how data passes the layer boundaries.

In my understanding, xmolecules is all about making architecture explicit in the code. If a team decides to adopt Clean Architecture (even if some people may say it's only a relabeled OA), it would be nice to make it explicit using dedicated annotations.

@odrotbohm
Copy link
Member

Let's open this up a little. We would need a set of well-defined, sort of specified concepts and some sort of authority to point to (at least a blog post or the like) that we could introduce annotations for. What would also be beneficial is a set of relationship rules between these concepts. Happy to take suggestions for such an arrangement.

@bit-jkraushaar
Copy link
Author

Based on the previously mentioned article, I propose the following concepts:

  • Interface Adapter Ring: Presenters, Gateways, Controllers
  • Application Business Rules Ring: Use Cases
  • Enterprise Business Rules Ring: Entities
  • Frameworks & Drivers Ring: UI, Web, Devices, DB, External Interfaces

Furthermore: All dependencies are directed inwards. That means also that controllers are not allowed to access gateways. At the borders between the rings only simple data structures may be exchanged.

The book defines some more, stricter rules (I had to quote them from the head, because I am just moving and have already packed the book away):

  • Dependency always only on abstractions
  • Dependency always only from the next lower ring
  • Framework code only in the outermost ring

To be honest, though, I've mostly bent these stricter rules in my projects so far. Sometimes pragmatism wins over strict adherence to rules. ;-)

@odrotbohm
Copy link
Member

Putting the Frameworks & Drivers Ring to the side as it describes externals to the system, not parts of it, we are basically back at the Infrastructure (Interface Adapter Ring), Application (Application Business Ring), Domain (Enterprise Business Rules Ring) arrangement of Onion Architecture with exact the same dependency rules, aren't we?

What I think is also a bit unfortunate, and IMO proof that the entire remix of existing ideas is actually of less quality than the originals that have inspired it, is that the core of the system is dumbed down to “entities”, a term that had been established in the DDD context at the time CA was originally described.

@bit-jkraushaar
Copy link
Author

How about this compromise: we create a way to further describe the existing annotations from the Onion architecture, e.g. using a "description" property (working term) or a custom annotation.

As I wrote before, I am aware that the two architectures are very similar. The main point is to make the decision for one or the other architecture explicit in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle: waiting-for-feedback Feedback by the original reporter needed module: architecture Architectural style related support type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants