域到DDD中的序列图代码中的存储库?

问题描述

对于学校作业,我们必须将序列图转换为代码。这是我们得到的以下序列图:

here

标记了reviewOfProduct方法,但这不是这样,所以您不能在“ Review”类中调用存储库吗? 这样,您将获得课程:

public class Review {
    private ProductId productId;
    <and other attributes>
    private ReviewRepository reviewRepository; // <— this isn't allowed right?

    public Review(<attributes>) {
        this.reviewRepository = new ReviewRepository; // <— this also isn't allowed right??
    }

    public List<Review> reviewsOfProduct(ProductId productId) { // this would be the reviewsOfProduct code
        this.reviewRepository.findReviewsOfProduct(productId);
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)