Click here to Skip to main content
15,920,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When I convert design to code ,can I ommit the multiplixity and role name .
If I cannot ,how can I write this .
Plese discuss about this .


Thanks you,
Posted
Comments
Richard MacCutchan 14-Jan-12 5:00am    
Your question is not clear, please try explaining your problem better.
OriginalGriff 14-Jan-12 5:02am    
Since you made the word "multiplixity" up yourself, you can omit it all you want.
If you meant "multiplicity", then that would depend on the relationships.
Not enough information there to discuss anything, really.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

If I understand you correctly, then the answer is no, you do not have to include them but you'd be making a big mistake if you omitted them.

Let us consider people. Specifically, relationships between people. There can be zero or one spouse, two parents and as many children as you like / can afford. Who would you code this? If the multiplicity can be greater than 1 it must be either an array or a collection of some sort. otherwise each role can be filled by a simple reference variable:

Java
public class Person {
    /** The spouse of this person */
    private Person spouse;
    /** The mother of this person */
    private Person mother;
    /** The father of this person */
    private Person father;
    /** The children of this person */
    private List<Person> children;
}

Note how the role leads into the member variable name. It doesn't have to, you could have hatstand instead of children; the variable would work just as well; but it isn't easy reading it to know what it does.
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 16-Jan-12 7:30am    
Fixed the generic List < > wise. Capitalized Person in generic List.
Manfred Rudolf Bihy 16-Jan-12 7:30am    
Good answer! 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900