Reputation: 4585
I am beginner in UML. The following is a UML object-model diagram that shows a single object called Timer, which has attributes minutes and seconds of type integer, as well as public operations tick() and reset().
The correspondig C Structure is:
struct Timer_t {
int mins; /*## attribute mins */
int secs; /*## attribute secs */
};
/* Operations */
/*## operation reset() */
void Timer_reset();
/*## operation tick() */
void Timer_tick();
With respect to this diagram I would like to understand the physical interpretation of the following:
1- 1
at the top left (Is it no. of instances that will be instantiated during the lifetime of the application?)
2- <<Singleton>>
(If it is stereotype to highlight that the object is an instance of a singleton class, then why do we also mention 1 at the top left?)
source : UML for C Programmers
Upvotes: 0
Views: 197
Reputation: 36333
First, the above is not an object(/instance) but a class. An object does not show attributes/methods in compartments and the name would be underlined.
Second, the <<Singleton>>
stereotype is placed wrongly. It needs to appear under the name of the class.
Third, the 1
top left signaling multiplicity needs to be enclosed in brackets like {1}
. Not sure about the position, I just know right below the class name.
Now regarding your question. The multiplicity tells that there must be only one instance of this class in a system. The stereotype <<Singleton>>
doesn't tell anything else (it's a tautology). However, the name Singleton is well known and you can find implementation patterns for any language via Google - which will fail for the key word 1
;-)
Upvotes: 2