U
U
user_of_toster2021-04-06 13:07:30
Software design
user_of_toster, 2021-04-06 13:07:30

How not to violate the dependency rule?

I'm trying to follow a clean architecture. The domain has the following interface:

interface PostRepository {
    save() {};
    remove() {};
}


Uncle Bob writes that the repository should be in the 3rd layer (interface adapters):
If the database is a SQL database, then all the SQL should be restricted to this layer, and in particular to the parts of this layer that have to do with the database.


However, isn't the dependency created from the inside out? From adapter layer to framework layer (SQL)? There is a dependence on freyfworkok, isn't it? The situation is exactly the same with controllers.

If you place adapters in the 4th layer (frameworks), then the adapters layer will be empty.
If you write adapters in the 3rd layer, then there will be a dependence on the 4th layer (framework)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
part_os, 2021-04-06
@part_os

At the domain level, you only place the interface, there is no dependence on the framework, it's just an interface that you need to implement and use. And at the level of infrastructure already private. If you want to change the ORM or the database, you will only need to implement these interfaces so that nothing changes in the application.
Here is another good article about architecture
https://m.habr.com/en/post/267125/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question