I want to design an online book reader. The first step is describing all the use cases which I have listed below:
- I should be able to search a book by title.
- I should be able to borrow a book.
- I should be able to bookmark a borrowed book.
- The system should allow one user per book at a time.
- The system should allow to add a new book.
- The system should allow to delete an existing book.
That said, I know now I need some Service Objects which would operate on Entities / Value Objects to get the thing done. I am deferring the database design / decision for now as its not considered a good practice. For the similar reasons Delivery mechanisms too is deferred.
After some reading I came to the conclusion that I would need the following:
Services (Algorithms without any states, depends on entities / values)
- SearchBook (Takes a title and gives the result back)
- BorrowService (Checks if a book can be borrowed)
- Member service (Enroll/Unroll members in a library)
Entities (real world mutable objects with unique ID)
- Library
- Book (ISBN number as a UID)
- User (Email as UID, it can be author or reader)
Associations
An author can have many books under his name, a user can only borrow one book at a time. A library can hold many books at a time, it can have many members too.
Notes
- For simplicity there will be only single library / store.
- No two users can read the same book at a time.
Questions
- I am not able to find any value object till now or I am not able to recognize / find it?
- I have followed Clean Architecture for some time and helped to build a toy project before. What is the difference between this and DDD?
- Am I on the right track?
Best Answer
Did you consider the Book "Implementing Domain Driven Design" by "Vaugh Vernon"? It gives a view on the concepts behind DDD from an implementation perspective with lots of really good real-live examples.
Regarding your explicit questions:
Clean Architecture, as stated by Maciej ChaĆapuk, is orthogonal to DDD. It is a very sound and solid concept to structure your system and gives room for domain modelling concepts like DDD.
I would not put too much thought into the explicit structure of this bounded context. Try to write a very broad acceptance test of a basic use case against the outer system boundary. Try to implement it with the fewest possible interactors while keeping a reasonable separation between the created components. Write Unit Tests if applicable.
I prefer this outside-in approach ("Growing Object Oriented Software, guided by Tests" is a good reference here), since it drives a domain model that is less gold plated and more fitting to the actual use cases.