Is the class of a class (Main class) an association, aggregation, or composition?

I am wondering what is the relationship of the main class (controlling all other classes in a non-GUI program) with other classes?

for example, a class that is instantiated in a class that contains the main method and the classes that the main method interacts with, such as getting a return value.

EDIT: Should it be included in the UML? because my professor includes (I didn't even know it was called a driver class), and the book he read apparently does not include, no, this is not homework.

It can be an association because it interacts with it. It can also be an aggregate because it consists of several classes. And the class has no meaning without it (in the program implementation), so I consider its composition, because composition is an aggregation, and aggregation, in turn, is a type of association. Although several answers have already been posted, it looks like my answer is wrong.

+3


source to share


4 answers


Nothing out of this. The main method is static. Therefore, it does not belong to any object. Thus, you have no association. The main method uses instances of other classes, that's all.



+4


source


The main class does not have to be created, so it does not have to be anywhere in the UML diagram, but it can be created and has any relationship with the rest of the program. Both the book and your teacher may be right in their respective cases.



BTW not to confuse associations between classes with what a static

method refers to main

. The method itself is main

definitely outside the UML paradigm.

+3


source


It's just a kickstarter class, you can modify it to take any of them, but it's better to keep it just for the starter and class build paradigm.

+2


source


And about including it in the UML - why not include it. Explore different design patterns - you learn about relationships and are used there

this discussion can help you

+1


source







All Articles