It's good practice to execute different types of tasks on different dispatchers (or thread pools). for IO operation better to use https://t.co/9NSJvd05AM. Pass dispatcher through class constructor to make testing easier.
#androiddev
You should not allow direct access to the data layer from the UI layer, everything goes through the domain layer. An advantage of making this restriction is that it stops your UI from bypassing domain layer logic.
#androiddev#android
The logic for mapping the Domain models into Presentation and vice versa should be in the Presentation layer. Models in this layer can be platform-dependent (e.g. Parcelable) and be more UI-specific.
#androiddev#architecture#domain#presentation
The model on this layer shouldn’t be Parcalable or any other platform-dependent code. This layer is the source of truth in the project and should be platform-independent, so we can reuse it for different platforms (e.g. Kotlin multiplatform project).
#androiddev
Avoid names based on an implementation detail — for example, UserSQLiteDataSource—because repositories that use that data source shouldn't know how the data is saved. Following this rule will allow you to change the implementation of the data source.
#androiddev
Some unit tests should be avoided because of their low value. The golden rule is not to cover a framework or library components and interactions with them that do not contain business logic.
#androiddev#tests
Often we need fake data for testing and the nice way to organize fake data is to use the ObjectMother pattern. It’s useful to have a nice library to generate fake data for tests. It’s useful when you’re developing a new project and need some pretty data for showcase.
#androiddev
The separate data models give us the flexibility to customize it to fit the transport protocol. It provides better separation of concerns, for example, members of a team could work individually on the different layers of a feature if the model class is defined beforehand.
I want to emphasize on that the Domain layer should be the most stable in your app architecture. That means independent from other layers and platform-independent code which makes it safer to make changes without causing unexpected problems.
#androiddev#architecture
My advice is to follow the Dependency Inversion Principle (DIP). The domain layer should communicate with the data layer only via the interface, for example, repository or service. Those interfaces must be placed in the domain layer and implemented in the data layer.
#androiddev
The main idea of the use case is to be a simple and lightweight piece of business logic and only have responsibility over a single functionality to follow the single responsibility principle.
#androiddev#architecture#solid#usecase