Wanted to thanks for providing good explanation and difference between Association, Aggregation and Composition.
It was good and helpful that you explained clearly with code constructs.
You are a .NET guru. I read your .NET interview books completely and it helped me a lot. This article is also very useful. Thank you. Keep up the good work.
hey in case of aggregation, how you initialize worker object in class scope. you have to initialize in somewhere method. because as by u did, this behavior matches to composition. if manager obj destroy so worker will also destroy bcoz worker behaves like manager data item. please if i am wrong. correct me through khayamabdulnasir@gmail.com
Above article is really a good at building concept using real life example. Also I've found another good article explaining difference between Composition and Aggregation;
Thanks for the article.
This is regarding the Composition section of your Article. In composition relationship, "Lifetime of Part depends on the Lifetime of Whole". In your example, "Project" and "Manager" is not developing a part-whole relation. Your are passing the the "Manager" object in "Project"'s constructor. You are creating the "Manager" object outside the "Project". So, your "Manager" can still survive even "Project" is destroyed.As far as my concept goes, I agree this is a case of "Aggregation" and also might result to a dependency but not a Composition. Please correct me if I am wrong.
Don't think Manager as Physical Entity..consider it as a logical entity..An Employee is Manager only when that Employee is assigned a Project(then employee becomes Manager),and when project is complete(destroyed) then employee's Role as a manager may be revoked.
I spent entire weekend reading all your articles. Gotta say, I loved them. It was time well spent. I spent all my Monday early morning voting, categorizing and bookmarking my favourite ones. Loved the content, became fan of presentation style.
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
Last Visit: 31-Dec-99 18:00 Last Update: 26-Sep-24 5:46