3

I have two classes.

Employee (Model)

EmployeeInfo (Another Class)
//Employee GetEmployeeInfo(int empCode) (MethodName)

EmployeeInfo class returns a Employee type.

Now, what is the relationship between Employee and EmployeeInfo ? (Aggregation, Composition or Association ?)

My guess is that, a new instance of Employee is created within the EmployeeInfo. So, when EmployeeInfo class object dies, so does Employee . This signifies a death relationship. So, the relationship is Composition ?

Sorry if this is a naive question, but cant get it right.

3 Answers3

1

If a particular EmployeeInfo is created with and dies with a specific Employee then it's Composition.

If a particular EmployeeInfo can have a specific Employee, but can exist without it then it's Aggregation.

Both Composition and Aggregation are types of Associations, they are just specialized associations.

Yes I would say the relationship you are describing would be composition.

Mick
  • 6,527
  • 4
  • 52
  • 67
0

It could be either Composition if EmployeeInfo owns (creates/disposes) the Employee, or Association (if Employee may exist outside EmployeeInfo).

So more information on how you use them (source code) is needed to answer your question.

MiN
  • 175
  • 1
  • 12
-2

Strange, these two classes is designed by you? If not , it's hard to know the relationship between the two.

wshcdr
  • 935
  • 2
  • 12
  • 27