'Association'에 해당되는 글 2건

  1. uml - association 2010/04/11
  2. Association Vs Aggregation Vs Composition 2008/03/17

uml - association

from lectures 2010/04/11 00:59
association은 단순하게 관계가 있다는 말이죵.. 관계에는 단방향과 양방향이 있겠죵.. ^^
그리고, association은 집합적인 개념으로 aggregation과 composition을 포함하고 있습니다..

1. 양방향
 - 아래의 그림처럼 실선으로 표현합니다.


 - 위 Diagram을 통해서 도출된 코드는 아래와 같습니다.. ^^
A.java
public class A {
    /** */
    public B Unnamed1;
}

B.java
public class B {
    /** */
    public A Unnamed1;
}


2. 단방향
 - 아래의 그림처럼 화살표와 실선으로 표현합니다.


 - 위 Diagram을 통해서 도출된 코드는 아래와 같습니다.. ^^
C.java
public class C {
    /** */
    public D Unnamed1;
}

D.java
public class D {
}


'lectures' 카테고리의 다른 글

uml - composition  (0) 2010/04/17
uml - denpendency  (0) 2010/04/11
uml - association  (0) 2010/04/11
delegation in java  (0) 2010/04/06
Framework vs Toolkit  (1) 2010/03/25
Tag // Association, UML
An Association is a channel between classes through which messages can be sent. As sending messages translates to calling methods in Java, Associations are typically (but not necessarily) implemented by references.

An Aggregation is an Association which denotes an "is part of" relationship. Unfortunately, the definition of this relationship is quite lax, so basically everyone is using his own interpretation. The only definitive (?) property is that in an instance graph, aggregations are not allowed to be circular - that is, an object can not be "a part of itself". (or) When building new classes from existing classes using aggregation, a composite object built from other constituent objects that are its parts.Java supports aggregation of objects by reference,since objects can't contain other objects explicitly.

A Composition adds a lifetime responsibility to Aggregation. In a garbage collected language like Java it basically means that the whole has the responsibility of preventing the garbage collector to prematurely collect the part - for example by holding a reference to it. (In a language like C++, where you need to explicitely destroy objects, Composition is a much more important concept.) Only one whole at a time can have a composition relationship to a part, but that relationship doesn't need to last for the whole lifetime of the objects - with other words, lifetime responsibility can be handed around.

Aggregation and Composition Guidelines :

Sometimes an object is made up of other objects. For example, an airplane is made up of a fuselage, wings, engines, landing gear, flaps, and so on. A delivery shipment contains one or more packages. A team consists of two or more employees. These are all examples of the concept of aggregation, which represents 밿s part of?relationships. An engine is part of a plane, a package is part of a shipment, and an employee is part of a team. Aggregation is a specialization of association, specifying a whole-part relationship between two objects. Composition is a stronger form of aggregation where the whole and parts have coincident lifetimes, and it is very common for the whole to manage the lifecycle of its parts. From a stylistic point of view, because aggregation and composition are both specializations of association the guidelines for associations apply.

출처는 http://faq.javaranch.com/java/AssociationVsAggregationVsComposition 입니다.

'ooad' 카테고리의 다른 글

LSP(Liskov Substitution Principle) ..  (0) 2008/06/03
Comparing Two High-Performance I/O Design Patterns  (0) 2008/05/27
MVC(Model-View-Controller) 패턴  (0) 2008/04/21
Association Vs Aggregation Vs Composition  (0) 2008/03/17
OOAD 란??  (0) 2008/02/19