Link to home
Start Free TrialLog in
Avatar of DamienL
DamienL

asked on

UML example

Hi there. Can you please give me a simple programming example of Generalization, Aggregation, Composition, Association (are there any more???)

for example I think (?) this is an example of composition:
====
composition:
Class1{
     private class2
}

- class1 is composed of class2
- denoted as a filled diamond and a solid line.
- Class1 <#>------ Class2
====

Thanks a million
Avatar of sasapopovic
sasapopovic
Flag of Serbia image

There are a lot of good articles about this. You can google your query and will get a lot of good matches.
Here are some:
http://www.codeproject.com/gen/design/idclass.asp
http://www.johndeacon.net/UML/UML_Appendix/Generated/UML_Appendix_structural.asp

I hope this is what you need.
Avatar of DamienL
DamienL

ASKER

yea i have actually visited loads of websites about this and they confuse me. It's difficult to get simple examples (in my opinion anyway)

For example just something simple like:
If Class1 has Class2 as a private member then this is composition (?)
If Class2 is passed into Class1 as a parameter then this is aggregation (?)

What about Association, etc?

and what is the difference between a broken line and a non-broken line as in:
http://www.dofactory.com/Patterns/PatternIterator.aspx

> If Class1 has Class2 as a private member then this is composition
I don't think that it has to be private.

> If Class2 is passed into Class1 as a parameter then this is aggregation
It's an example of aggregation, yea.

> and what is the difference between a broken line and a non-broken line
The dashed lines normally represent the life of the object.


> i have actually visited loads of websites about this and they confuse me
> ..
> What about Association, etc?

I found the online stuff pretty poor and hard going as well. So, I got myself down to my local library, and found a book on it, and gave it a quick read, and found it _much_ easier.

I really recommend you getting your hands on a _book_ rather than relying on this online stuff..


Good luck.
> The dashed lines normally represent the life of the object.
But when it has an arrow head, it depicts the return message.
Avatar of DamienL

ASKER

Hi InteractiveMind,

You say:
> If Class2 is passed into Class1 as a parameter then this is aggregation
It's an example of aggregation, yea.
- Can you give me another example please?

> and what is the difference between a broken line and a non-broken line
The dashed lines normally represent the life of the object.
- You mean the life of one class might depend on another, can you please explaine?

Thanks a lot
ASKER CERTIFIED SOLUTION
Avatar of InteractiveMind
InteractiveMind
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial