This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am pretty new to this Composition, Association, Aggregation business myself, but after a lengthy study of "Head First OOA&D" and "The Object-Oriented Thought Process" and many internet articles, I have come the following conclusions regarding your questions:
if I am having a class1 that USE class2 without having instance variable pointing to class2, Is that Association?
Yes, while the classes are clearly associated, the instance of class2 is independent and may participate in relationships with other objects. This is true as long as class2 is instantiated elsewhere. It make no difference how class1 accesses class2.
if class1 is having a instance variable which reference class2, while class1 never instantiated class2, is this Aggregation?
No. This is still Association. Aggregation is not clearly defined beyond the UML symbol (white diamond). I (and notable others) believe you are best ignoring Aggregation, it doesn't really exist...
if the previous case but class1 instantiated class2, is this composition.
Yes. The key here is that class1 "owns" this instance of class2, the life span of these instances are the same. They are truly composed into a new whole.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com