Lesson 11 Domain Driven Development ‐ Making it make sense - FranGarc/LearningPath GitHub Wiki
This is an approach to software development that focuses on understanding and modeling the problem/issue which is to be addressed by the software. We call domain to the set of concepts, rules, and processes that the software is intended to model or support.
So far we've been building features more focused on getting them done than thinking on more general terms. So it's time to stop, review, and think "what are we building here?". Beyond "an app that consumes this particular API", what are we building?
- Decide the purpose of the app. What problem/need/issue does it address?
- Review your Domain and DTO models. Do the classes (or their attributes) names make sense with what they're suppose to represent? If not, it's time to refactor-rename them.
- Review your code as a whole. Does the package structure and names make sense? Would arranging it by feature make it more semantically meaningful?
I am building a Pokedex, sort of an encyclopedia that only deals in Pokemon. That involves: listing and describing Pokemon.
The List/Grid of the first screen could be seen as the Index of the Encyclopedia. Hence, each element in that set should be called "Index Item", since they're just the name of the pokemon and the reference to where the full information is.
I change our current List<Pokemon>
to List<PokedexIndexElement>
, and then I can then rename the PokemonDetail
to PokemonArticle
. Why not just Pokemon? Because in the context of "encyclopedia", it makes more sense to talk about Articles. It also leaves the "Pokemon" concept free for a future "these are my Pokemon" feature I may want to implement.
I also re-arrange the ui code
ui\
|
|--- common\
| |
| --- components\
| |
| --- navigation\
| |
| --- theme\
|
|--- extensions\
|
|--- pokedex\
| |
| --- model\
| |
| --- screens\
| |
| --- pokedexindex\
| |
| --- pokemonarticle\
|
--- MainActivity
In the future, some of the ui Model classes currently in pokedex may need to be rearranged to the common package if a new feature also uses them, but for now this arrangement should suffice.
- Domain Entities
- DDD - Domain Driven Development