I'm reading about UML class diagrams and notation for visibility, and I can't tell if this book (Learning UML 2.0 by Russ Miles) has a typo or is just not explaining itself.
Consider these two diagrams:
Protected Member:
Private Member:
I fully understand the concept of visibility, as I am a seasoned Java developer.. but I'm curious about the notation here. Is there any significance to the fact that aMethod()
does not have a visibility modifier? Why is it in the first picture that it looks as if SpecializedClassInAnotherPackage
can access aMethod()
from BlogAccount
, but the same class cannot access it in the second diagram? The only difference between the two is that the showcased property is protected in the first, and private in the second.
Is this a typo, or am I not understanding something? I cannot readily see anything in the book that would indicate the meaning of having no visibility modifier.
Best Answer
Seems like there is a simple solution to that confusion: the arrows in these diagrams are not accurate as to their destination. They all point to different things when you look at it exactly. Some point to the property with the visibility modifier, some to the other operation, others to the class itself. However, the intention of the author seems to be that each of these is regarding access to the field with the interesting visibility modifier.
Or in short:
#creationDate
is accessible from the derived class, but-name
is not. Granted, the author may have taken more care here as to avoid this confusion.A little extension on the actual semantics of this. When you take a look at the UML superstructure specification at page 141 you will see the different visibility kinds and their specified semantics. Another post on SO shows you where to look at in the SSS to find out that the default visibility (if nothing is written in front of the operation) is public. (Yes, the SSS is a tough beast to read.. you should learn how to read that document before actually reading it).
Just for the reference, here are the concrete semantics as defined in the UML SSS: