Clarification
I tried to explain, very generally, what is the difference between association, composition, and aggregation, but I have sinned the same as criticizing the post I read. I have not been sufficiently clear, well I have been asked to explain a bit more .. je.
I must emphasize that each model designed not prescriptive or intended to be all there are other ways to design it, or at least to me I have other besides these.
pricipalmente But I think, certainly comes across the Composition and Aggregation. Of note,'s membership, comes as the Aggregation refinement at the pursuit of good practices implementation program to make most classes "coercive" is to assign responsibility. Explanation of Model
Represented
Association: is the relationship between the class Person and class picture, ie that there is an instance variable (or attribute) in the class Person Photo type. Only one Obeto, which Sets from setFoto method () as instance variable to which it creates a setter. This can be instantiated (new Photo ()) in any other part of the code.
Aggregation: is the relationship between class and class Person Place Through The attribute "lugaresFrecuentes" which is a collection (array, colection, vector, etc) Place objects. And also, the Person class has a method "agregarLugaresFrecuentes (Place place)" By which you add a single object type Place to the playlist "lugaresFrecuentes." These objects, which are passed as parameters to this method are instantiated outside the class Person. Not to be confused with the method setLugaresFrecuentes (Location [] lugaresFrecuentes), which has only to be a property.
Composition: is the relationship between class and class Person Profile travez property to "profile" which is a collection of profile type. In addition, if a structural relationship is merely semantic, since it aims to give the idea of \u200b\u200bthe responsibility of the Person class on the life cycle of the object of the class Profile. That is why also in the example a dependence graph (graph is not usually enough to composition. But UML is used to communicate.)
is identical to the aggregation but with the difference that the class Person responsible for the creation of the object profile. This means that the instance (new Profile ()) is created within the agregarPerfil method (), and after that, this object is stored in the collection "Profiles." The model is telling us that in any other part of the code should write a new Profile (). Since colloquially, the profile (whether it is psychological, personal, etc) there is only one person from the person deceased person's profile does not help, and only from the existence of it you can create a , so this method of creation must be an instance method.
It's all a question what the person who wrote the model (and bearing in mind that it knows how to use UML, we chose to pass), if in doubt, we must ask what he meant by that plotted.
I hope I have cleared some doubts
Greetings
Ariel Diaz Molina.
0 comments:
Post a Comment