Wednesday, October 27, 2010

Visibility: Private & Public


Following the laws of encapsulation, when designing a class, it is important to define the visibility of the states and behaviors contained within the class. This is known as visibility.

Notice in the class diagram below, each state has a minus preceding its name and each behavior has a plus preceding its name. A minus denotes that a state or behavior is private and cannot be directly accessed from external objects. A plus denotes that a state or behavior is public and may be accessed externally by other objects.

When an object state is private, no other object can read or change the value.



No comments:

Post a Comment