Dmytro Parfeniuk
1 min readSep 13, 2023

--

1. I think that the main purpose of the Protocol class in Python is a bit different. IMHO, abc.ABC fits your situation a bit better.

2. Also, I guess using IRepository might confuse people since we don't have any sort of interfaces in Python

3. If you used Interfaces as a rough word I think it does not match your case since interfaces outline the way of the communication between components. Let's say the communication interface to the database is a class called "DbConnection", etc

4. There is no reason to keep the idea of interfaces in Python like in Java / C# because Python actually supports multiple inheritance

5. And the last thing. I guess that domain/model layer from DDD by Eric Evans (the creator of DDD) is not about the data model. It is the main algorithmic part of the whole application and the repository pattern that corresponds to the interaction with the books table should be placed in domain/books/repository.py instead. On the other hand, the class BaseRepository(ABC) could be placed somewhere in the infrastructure layer

P.S. This is only my opinion. Thanks for the article :)

--

--

No responses yet