Java and Pattern Learning notes (i) UML Introduction to the Unified Modeling Language (2

Source: Internet
Author: User

Third, class diagram

Class diagrams are graphs that display classes, interfaces, and their static structures and relationships. The basic element of a class diagram is a class or interface.

The box of the class can be divided into several layers

    • Class name
    • Property List
    • Method checklist
    • List of properties

If a class has an internal member class, then its class diagram has 5 layers. In a class diagram, other layers can be omitted in UML except that the class name layer cannot omit the must display.

The first layer is the class name, if the class name is Roman, which indicates that the class is concrete (concrete, which can be instantiated), and if the variable name is italic, the class is abstract.

The second layer is the property layer. If there is a + number on the left, it indicates that it is public; if there is one on the left, it indicates that it is private, and if there is a # number, it indicates that it is protected.

The third layer is the method layer. The meaning of the +-# is consistent with the attribute layer.

Method below if there is an underscore, it indicates that it is a static method.

The fourth layer is the nature layer, which is composed of an attribute, an internal variable, an assignment function and a value function. For example:

Public String class1{

Private String JobTitle;

Public String Getjobtitle () {

return jobtitle;

}

public string Setjobtitle (string jobtitle) {

This.jobtitle=jobtitle;

}

}

In a UML diagram, the upper-left corner of a class typically writes out the parent class of the class and the implemented interface in two lines.

1, describing the interface of the class diagram

The class diagram of the interface is almost the same as the class diagram of the class, and the only difference is that the name of the interface has a "interface" word.

An interface is not of a nature and can have the declaration of methods, public, and final static internal member classes.

<

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.