让我们假设我有以下对象模型(你可以自由地以你喜欢的方式改变它,我的兴趣只是有效地映射),
public class Product{
private String someAttribute;
//...
}
// A Seller who has a lot of products to sell, More than one Seller can sell the same Product
public class Seller{
private List<Product> products;
//...
}
public class Offer{
// who is offering
private Seller seller;
// multiple products can make an offer
private List<Product> products;
// pricing related
private Price price;
//...
}
Run Code Online (Sandbox Code Playgroud)
我想编写一个Web应用程序,它将对这些对象执行,读/写/搜索,并考虑入口点可以是其中任何一个.
以下是我的疑问, -
在存储Seller对象时,我是否应该存储Product对象的引用?还是只是钥匙?我的意思是我应该将Seller类转换为以下内容,
公共类别卖方{private List productKeys; }
如果我想编写一个可扩展且可维护的应用程序,我认为应该有一些很好的方法在分层架构中设计我的应用程序.是否有一些例子或一些已经使用过的模式?例如某种JSP - >服务 - > DAO …