If I understand it well, the Room domain model is what Domain-Driven Design (DDD) call Entity / Aggregate root entity, I think it would be better to compare rooms by id only because e.g. the price can change but the room is the same. At this moment the room is represented as a value object (DDD). I would model it like this:
Size = NewType("Size", int)
Price = NewType("Price", Decimal)
Address = NewType("Address", str)
Description = NewType("Description", str)
class Room:
"""
An aggregate root entity.
"""
def __init__(self, id: UUID, size: Size, price: Price, address: Address, description: Description) -> None:
self.id = id
self.size = size
self.price = price
self.address = address
self.description = description
def __eq__(self, that) -> bool:
return all((isinstance(that, type(self)), self.id == that.id))
def __hash__(self) -> int:
return hash((type(self), self.id))
@classmethod
def make(cls, id: UUID, size: Size, price: Price, address: Address, description: Description) -> Room:
return cls(id, size, price, address, description)
Is there some channel where this architectural decisions can be discussed?
All the best, David.
If I understand it well, the
Roomdomain model is what Domain-Driven Design (DDD) call Entity / Aggregate root entity, I think it would be better to compare rooms by id only because e.g. the price can change but the room is the same. At this moment the room is represented as a value object (DDD). I would model it like this:Is there some channel where this architectural decisions can be discussed?
All the best, David.