This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hello SCEAs and SCEAs to-be! concerning the domain and class model I would like to hear your opinion. 1. I think if two classes have a 1-1 relationship you can make a single class out of them by combining their attributes (e.g. Customer and Address -> you can put the attribute "street" or "city" in the Customer class). Do you think this is ok? 2. I think classes can only be singular?! Is it possible to name a class e.g. "Articles"??? 3. Assume you have only 4 classes in your model: Customer, Order, OrderPosition and Article. The relationships are as follows: Customer-Order (1,0..*), Order-OrderPosition (1,1..*), OrderPosition-Article (1,1..*). I wonder in which scenario a (1,1..*)for the OrderPosition-Article-Relationship would be applicable? What do you think? Roger
Hi Roger, Here is what I feel for the points you mentioned 1. Always think in terms of real life objects. Assign only those responsibilites, which are relevant to that particular class. Its always said that when one is not clear with adding an attribute to a class or create a new seperate class. Always go with having a new class. 2. You can offcourse have a clas to hold a collection of similar class. but I am not very clear on this. May be some one might put some clear guideline. 3. This depends on the scenario you are talking about. OrderPosition is meant to hold a specific Article detail, but it can also hold details for collection of Article object. Thanks.
Hi Roger, i would like to add - 1. Having 1:1 relationship between classes doesn't imply u should merge them. Keep them separate as they can be altered later,aggregated by some other class or simply associated with some other class too. 2. Acceptable convention is to have singular name entities as classes. However, there r authors who have used plurals. So it depends. 3. I think, in all likelihood u will have scenarios like 1 orderposition has at least 1 article contained in it; otherwise the order itself in a broader sense would become void. Correct me if i didn't get u.