2
我正在创建一个应用程序来尝试DDD。
该应用程序是为租看电影,我的类别是:域驱动设计服务
class Movie{
String title
String descrition
}
class Customer{
String username
}
class Rent{
Film film
User user
Period period
}
对于我所知道的DDD我也有RentService
创建Rent
对象。所以,我有:
class RentService{
Rent rentMovie(User user, Film film, Date from, Date to){
//validation check (like if the film is already rented)
return rentRepository.store(new Rent(user, film, from, to));
}
}
到底RentService
只需要创建一个新的Rent
对象,然后存储它使用一个仓库。这是对的吗?
然后,我想提供一个按钮到RentNow!在从今天起租期为3天的Web应用程序中,我应该在RentService
中添加一个方法rentNow
来计算日期,还是我可以重新使用旧方法并计算Controller类中的日期?