You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say we have two concepts: Book and BookBeingSold. Book have methods like read, rate, and have properties like title and author. BookBeingSold have the same methods and properties but it also have additional methods buy, cancel, changePrice, and property price. The database have two tables books (id, title, author) and books-being-sold (id, book_id, price, is_deleted).
What should code look like for this scenario in DDD way? Should we create two separate modules book and bookBeingSold and two separate repositories? Should we inherit one module from another? Or we should just have one module book and one repository?
The text was updated successfully, but these errors were encountered:
classProduct{price: number;productType: string;// <- product type is a "book" hereproductId: string;// <- book idbuy(){...}cancel{...}changePrice{...}}
rate method that you mentioned belongs to a Product too IMO and not to a Book (unless your Book has non-generic ways of rating it that are different from other Products).
With this approach you can add more products, not only books.
The key of DDD is analyzing and defining proper bounded contexts for each entity/aggregate/module. Book and Product are two unrelated concepts that shouldn't be mixed.
Repository owner
locked and limited conversation to collaborators
Aug 6, 2022
Let's say we have two concepts:
Book
andBookBeingSold
.Book
have methods likeread
,rate
, and have properties liketitle
andauthor
.BookBeingSold
have the same methods and properties but it also have additional methodsbuy
,cancel
,changePrice
, and propertyprice
. The database have two tablesbooks
(id, title, author) andbooks-being-sold
(id, book_id, price, is_deleted).What should code look like for this scenario in DDD way? Should we create two separate modules
book
andbookBeingSold
and two separate repositories? Should we inherit one module from another? Or we should just have one modulebook
and one repository?The text was updated successfully, but these errors were encountered: