Classes, methods and attributes can be accessed at various levels of scope. What determines this access is the visibility modifier that will be implemented, which will indicate where certain level element can be accessed. For example, a variable X can only be accessed within the scope of the class; on the other hand, the variable Y can be accessed from the instantiated object. Thanks to this feature is that the concept of encapsulation of object-oriented programming can be applied.

Within the UML notation it is possible to enter through specific characters, which the visibility of each of the elements that make up a class. By default, most languages use three reserved words to determine the visibility of elements:

  • public: indicating that the element can be accessed from the instantiated object;
  • private: indicates that the element can only be accessed in the local scope;
  • protected: Indicates the protected element that can only be accessed within the scope or derived classes;
  • default: indicates that the element uses the default property of language.

In the UML notation format, the visibility of the elements is displayed as follows:

 

Representation UML

+
#
~

 

  • “+” : public;
  • “-” : private;
  • “#” : protected;
  • ~“: default.

Upon receiving the notation that is the left side of the names of the element, the programmer will know exactly how to program the element within the applied modeling. Following is presented a practical example of using the displayed notation:

CustomerDatabase

+ name: String

~ ID: String

# age: int

– balanceAccount: double

~ CustomerDatabase (name: String, ID: String)

+ getBalanceAccount () :double

+ getBalanceAccount(balanceAccount: double) :void

#setAge (age: int) :void

In the example, the attributes, shown in the first diagram block after the class name, have their visibility indicated by the standard notation. The following methods are also presented along with the modifier.

Once the programmer gets this diagram, he just needs to use the corresponding syntax to the modifier within the programming language used for development.

Finally, the following code is the final result of the example diagram:

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.