Reputation: 409
If I am using UML diagrams to depict a C program, can I have composition and aggregation or is that reserved just for Object Oriented Languages?
For example if I have a struct or a Buffer in my source that is only used for that particular segment of the code I assume is aggregation, because the lifecycle of that particular piece of code is dependent of the user using that file right?
Should I be using Association and Direct Association?
Upvotes: 2
Views: 2189
Reputation: 4763
Yes, you can use UML to describe programs in any language.
When an object (structure, w/e ) has it's lifecycle tight coupled with another object is Composition , not Aggregation
What you described is neither Composition nor Aggregation. The lifecycle of a particular structure/buffer that's only valid through a certain code segment can be better represented through a Sequence diagram (get buffer , release buffer calls should be shown in the diagram)
You will have allot of Composition and Aggregation in C. Think about POD structs. Some of them reference other POD structs inside them. If the reference comes with memory ownership it's Composition (eg :pointer which needs to be released). If the reference doesn't come with memory ownership it's Aggregation (eg : pointer which you don't have to release when releasing the structure).
Upvotes: 4