DEV Community

Bertil Muth
Bertil Muth

Posted on • Originally published at bertilmuth.Medium on

Modern Clean Architecture

Guggenheim Museum in New York

Clean Architecture is a term coined by Robert C. Martin. The main idea: Entities and use cases are independent of frameworks, UI, the database and external services.

Continue reading on Medium (paywall free) »

Latest comments (6)

Collapse
 
efpage profile image
Eckehard

Hy Bertil,

part of these Ideas where possible using OO. We have build some apps years ago that used a kind of "abstraction layer" to any technology base we used. This was in many cases convenient, as each layer had some features that made live a bit easier.

Years later we hat to update some of these apps to a new platform, which was amazingly simple if our abstraction was good enough. You just had to change your base classes and most of the app did not change at all.

Currently I try to apply some of these Ideas to web technology, but using OO today is a bit frowned upon. Anyway, good Ideas will prevail in the long run.

Collapse
 
bertilmuth profile image
Bertil Muth

Hi Eckehard,

sounds like an interesting project you've been working on.
I think that one of the main ideas of Clean Architecture, Dependecy Injection, can be applied in almost every programming language.

That is: you can separate code that executes business logic from framework / infrastructure specific code in almost every programming language, OO or not.

Currently, I'm teaching a student of mine how to do that in JavaScript.
In JavaScript, you can pass callback functions as function arguments.
Even in a language like C, you can pass callback functions as function pointers to other functions.

What do you think?

Collapse
 
efpage profile image
Eckehard

We have been working with Delphi for a long time, but wanted to be more Platform independant. As Javascript has developed very nicely over the last years, we decided to switch completely. So, we use the browser engine as a programming plattform. The traditional HTML-CSS-JS approach is not very handy for our work, so we created a new platform that is a bit more flexble. Please check out solution DML and let me know what you think.

But - regardless of the platform - the Idea of a "Clean Architecture" sound very interesting to me. I´m not sure if I got all the details of the concept, but generally the Idea of separating UI and functional units is very appealing to me.

I have a working example of a ToDo List on the project page. That features pesistance and a simple object oriented approach. Maybe this could be a good example how to switch from traditional architecture to a "Clean Architecture".

Thread Thread
 
bertilmuth profile image
Bertil Muth

The DML project looks interesting. It looks like it could save you from creating boilerplate code, and possibly make your code more readable.
In your ToDo List example, I have the impression that the object performs the functionality of adding, removing items etc. And it updates the UI. In a Clean Architecture, those two would be separated in 2 different objects. But given an example of such a small scope, I understand if you consider this overengineering.

Thread Thread
 
bertilmuth profile image
Bertil Muth

I think about writing an article about Dependency Injection in JavaScript, since this is at the heart of ports&adapters and Clean Architecture.

Is this something you'd be interested in, Eckehard?
What about the other devs on this platform, anybody interested?

Thread Thread
 
efpage profile image
Eckehard

Small scopes make it easy to understand the principles, so your input is very welcome.

The clue with DML is the option to remove any external dependencies, that you usually get with HTML and CSS. DOM-elements are directly bound to local variables, so, the DOM element becomes part of an object. This is very similar to what you get with WebComponents, but with the full power of a class based approach. WebComponents are well encapsulated, but are part of the HTML-system. This is like using a race car on a wilderness path.

OO is well siuted to create reusable code partitions, but it does not solve any possible problem. Separating logical partitions of your code using a clean architecture might be a good option, so I´m very interested to learn more about this approach.