< Nine > object-oriented Analysis of UML core elements of design class, class, property, method, visibility

Source: Internet
Author: User

Design class



---> Design class is the abstraction of one or more objects in a system implementation.
---> Design classes have been mapped directly to the implementation code, so the design class relies on the implementation language. On the other hand, the design class originates from the early system analysis, in the unification process, the class is not the product fantasy like out. They can map to the results of previous system analysis. From this point of view, analysis of the importance of the class can be reflected. Analytic classes provide a very good abstraction for the design of interfaces, logic, and data that are needed in a class, and design classes can evolve easily and naturally from analytic classes.



Class
---The > class defines the object, and the object implements (or becomes implemented) the use case. The source of a class can be the need for a use case implementation of the object required by the system, which is defined to achieve business requirements. It can also be any previously developed object model, that is, existing system modules, software frameworks adopted, third-party products, etc. The class describes what the object is, and also determines what properties the object has and what method it has. In the typical object-oriented languages of Java and C + +, classes correspond to a class declaration.
---> class is the generalization and abstraction of the characteristics of one aspect of an object, and the object is the result of class instantiation.



Property
----> properties are characteristics of an object.
----> Properties also indicate the uniqueness of the object.

Method
----> In principle, the only way to access objects or properties or relationships that affect other objects is by means of methods, which are not advocated for accessing and modifying object properties directly.
----The method of the > object is defined by its class. In most cases, the methods defined by the class are executed by the instantiated object, that is, the methods are object methods. But sometimes it can be performed by a class, which is called a class method. For example, in Java, a class method is declared by the static keyword. A static method can be executed by a class without having to instantiate it as an object.
The role of the----> method is to access and change the properties of an object, sometimes the method simply encapsulates the algorithm, and executing the method does not alter the object's properties, and in object-oriented, the principle is that an object's properties should only be changed by its own method.


Visibility of
----the properties and methods of the > class have similar visibility definitions, and the processing of visibility by each programming language is not exactly the same. In UML, visibility can be summed up in the following four categories
----> Common: Properties and methods are also visible to other model elements except that the class itself is unexpected. Common visibility should be used sparingly, which means exposing the properties and methods of the class to the outside, which is contradictory to the object-oriented encapsulation principle. The more content exposed to the outside, the more vulnerable the object is, and the more likely it is to form a high degree of coupling.
---> Protection: Properties and methods are visible only to the class itself, its subclasses, or friends (depending on the specific language). Protection visibility is the default visibility. It protects properties and methods from being used by external classes, preventing the coupling and encapsulation of behavior from becoming loose.
----> Private: Properties and methods are visible only to the class itself and the Friends of the class (depending on the language). Private visibility can be used in situations where you do not want subclasses to inherit properties and methods. It provides a decoupling method from the superclass subclass. and reduces the need to remove or exclude unused inheritance operations
----> Implementation: Properties and methods are visible only within the class itself (depending on the language). Implementation visibility is most restrictive. This visibility is used when the operation is only available to the class itself. It is a variant of private visibility.

< Nine > object-oriented Analysis of UML core elements of design class, class, property, method, visibility

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.