Cyberpunk Keanu
01/04/2020, 9:42 AMwasyl
01/04/2020, 11:39 AMCyberpunk Keanu
01/04/2020, 11:43 AMwasyl
01/04/2020, 8:47 PMwasyl
01/04/2020, 8:49 PMCyberpunk Keanu
01/06/2020, 6:30 AMwasyl
01/06/2020, 8:47 AMall my data entities objects are to be in the domain moduleThatâs not accurate, your domain models should be in domain module. Any data entities coupled to libraries specifically must not be in domain module
MyObjectBox class need an applicationcontext to be passed to build it. So it has to be in the presentation module alwaysAlso not accurate,
presentation should only concern itself with presentation, as its name suggests.
Think of it like this: clean architecture promises that e.g. database library is abstracted away in such a way, you could easily swap it at later point. If your domain uses object box models, and your presentation uses objectbox classes, it means objectbox is coupled with all layers of your application and is not swappable at all!wasyl
01/06/2020, 8:52 AMdomain module has your domain models, e.g. Post(id, author, text)
- domain module also has your data access interface: interface PostRepository { fun getPosts(): List<Post>; fun getPostsByAuthor(author): List<Post>
- data:objectbox module has objectbox specific implementation, including models (like @Entity PostEntity) and repository class (class ObjectBoxPostsRepository(MyObjectBox): PostsRepository).
- objectbox module depends on Object box library and on domain module. domain module doesnât depend on anything
- presentation has no dependency on objectbox module, instead domain module exposes some ways for presentation to act on PostsRepository (for example use cases, commands/queries etc)wasyl
01/06/2020, 8:54 AMObjectBoxPostsRepository will retrieve entities from object box, map it to domain objects and return. This way domain doesnât know anything about the library used. Last step for all of this to work is to use a dependency injection framework (or do everything manually) and whenever a domain class depends on PostsRepository, it will have ObjectBoxPostsRepository passed at runtime. Iâd typically use Dagger and have the configuration in app modulewasyl
01/06/2020, 8:56 AM