Packages and Namespaces - Packages and Visibility - Inner and Outer Names
13 important questions on Packages and Namespaces - Packages and Visibility - Inner and Outer Names
Consider Fig. 8.9. As shown in that figure, the direct Elements of P1, C1, and C2 can refer to each other by ....?![]()
In P1, if C1 needs to refer to an Attribute a1 in C2, it would use ..... ?
Likewise, if C2 needs to refer to an operation b() in C1, it would use ....?
C2.a1.
Likewise, if C2 needs to refer to an operation b() in C1, it would use C1.b().
Similarly, in Package P2, if C1 and C3 can use the ..... of the other member, C1 and C3.
If they wish to refer to the properties of each other, they can use .... or ....?![]()
If they wish to refer to the properties of each other, they can use C3.a1 or C1.b().
- Higher grades + faster learning
- Never study anything twice
- 100% sure, 100% understanding
The question then arises how can the Elements within P2 refer to the Elements directly in P1 or the Elements directly in P1 refer to the Elements in P2.
What technique can we use?
![]()
Let us assume that everything is marked visible (+).
To refer to the inner Elements from P1, we need to use the qualified name
The question then arises how can the Elements within P2 refer to the Elements directly in P1 or the Elements directly in P1 refer to the Elements in P2.
If we needed to refer to their features from P1, it would look like P2::C3.a1 or P2::C1.b().
The Package → Package and Package → Element uses ...... as the separator
The Element → attribute or Element → operation uses .... as the separator.
To refer to the outer Elements from P2, we can refer to C2 as .... , and we can refer to the properties of C2 as .....
However, we cannot directly refer to C1, because the name C1 is blocked by the existence of a C1 at the P2 level.
Using C1 as the reference would refer to the local C1.![]()
We have to use the ....?
However, we cannot directly refer to C1, because the name C1 is blocked by the existence of a C1 at the P2 level.
Using C1 as the reference would refer to the local C1.
We have to use the qualified name to get to P1’s C1, that is P1::C1. P2 can refer to C1’s properties as P1::C1.b().
We have to use the qualified name to get to P1’s C1, that is P1::C1. P2 can refer to C1’s properties as P1::C1.b().
Then, every Element in the diagram can refer to ....?
Then, every Element in the diagram can refer to C2 and C3 because these name Elements are defined once, and they are visible by the rules for public (+) Elements.
So the operation on C2 would still be C2.b() whether referred to by something in P1 or P2.
Similarly, the operation on C3 would still be C3.b() whether referred to by something in P2 or P1.
When will the reference be blocked?
If we wish to get the version of the blocked Element from a differ level, the reference has to use what? and why do we need it?
What can cause a blockage?
The question on the page originate from the summary of the following study material:
- A unique study and practice tool
- Never study anything twice again
- Get the grades you hope for
- 100% sure, 100% understanding
![Trustpilot Logo](/images/design_2020/lp/clp-trustpilot-en.png)