Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about UML Notation for Design Patterns #396

Open
FredericChow00 opened this issue Apr 19, 2023 · 2 comments
Open

Question about UML Notation for Design Patterns #396

FredericChow00 opened this issue Apr 19, 2023 · 2 comments

Comments

@FredericChow00
Copy link

Question regarding Singletons:

  1. Where does the <<role/purpose>> come in for the Singletons? Is it in the naming of the singleton?
  2. I realize that Singletons have <<Singleton>> UML Notation above the class name, I just wanted to clarify that according to the textbook it is optional. And also Facade Classes would not require such an UML Notation?

image

@hingen
Copy link

hingen commented Apr 20, 2023

Where does the <<role/purpose>> come in for the Singletons? Is it in the naming of the singleton?

image

It's just a way to specify that the class is a singleton. There isn't a specific programming language construct for it like in the case for <<interface>> or {abstract}.

Suppose <<Singleton>> is removed, now it becomes a bit unclear whether the class is a singleton or not. In practice, singleton classes often have a lot more methods and variables than what is shown in the example. The specific names theOne and getInstance() (from my understanding) aren't conventions either and different developers may name them differently or even implement Singletons differently (e.g. using a Singleton<T> generic class). Hence, determining whether something is a singleton purely base on the methods and variables is not as straightforward as it may look. Thus the <<Singleton>> notation is good for being explicit and clear.

I realize that Singletons have <> UML Notation above the class name, I just wanted to clarify that according to the textbook it is optional.

Seems like the textbook does imply that it is optional. From what I gather, most things in UML class diagrams are optional. The bare minimum seems to just be class names (for representing classes) and a solid line (for representing associations). But then again, you can omit specific classes and associations (as many have done in the TP) if they are not necessary for what you're trying to convey. Not sure what the convention is for our final exam though.

core-uml-class

And also Facade Classes would not require such an UML Notation?

Pretty sure you can specify it if you feel it is necessary. I remember one of the tutorials had a UML class diagram where <<Facade>> was specified. I have no screenshots of it though :(

@FredericChow00
Copy link
Author

Got it thanks so much for the help! @hingen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants