Through google, there are found many slightly different solutions to this, even though (to me) it feels like it should be much easier to answer. These are the words I’m worrying about right now, while trying to acquire decent UML’ing skills :D…
“public, protected, private, package”
Let me first try to get this complete for Java, because I feel pretty familiar with it (correct me please, if I did any evil nevertheless!):
- Public
- Members of the same instance can see/use this
- Members of another instance of the same class can see/use this
- Members of derivative classes in the same pkg can see/use this
- Members of derivative classes in another pkg can see/use this
- Members of another class in the same pkg can see/use this
- Members of another class in another pkg can see/use this
- Anything else can see/use this
- Protected
- Members of the same instance can see/use this
- Members of another instance of the same class can see/use this
- Members of derivative classes in the same pkg can see/use this
- Members of derivative classes in another pkg can see/use this
- Members of another class in the same pkg cannot see/use this
- Members of another class in another pkg cannot see/use this
- Anything else cannot see/use this
- Private
- Members of the same instance can see/use this
- Members of another instance of the same class can see/use this
- Members of derivative classes in the same pkg cannot see/use this
- Members of derivative classes in another pkg cannot see/use this
- Members of another class in the same pkg cannot see/use this
- Members of another class in another pkg cannot see/use this
- Anything else cannot see/use this
- Package
- Members of the same instance can see/use this
- Members of another instance of the same class can see/use this
- Members of derivative classes in the same pkg can see/use this
- Members of derivative classes in another pkg cannot see/use this
- Members of another class in the same pkg can see/use this
- Members of another class in another pkg cannot see/use this
- Anything else cannot see/use this
My questions now:
- How exactly does this differ from the UML standard?
- Where did I include errors in the upper list, if I did? I’m not god, so there might be one 😉
Best regards, and thanks in advance for any help!
From the UML standard. Visibility:
Namespace:
I think the UML definitions of private, protected, etc. are fairly similar to those of Java.