PHP design pattern-UML class diagram

Source: Internet
Author: User
Preface I have been using PHP for more than two years. I have prepared and written some frequently-used design patterns based on my own practical experience. before using the design patterns, I must first understand the design patterns, therefore, we will first explain the UML class diagram. Through UML class diagrams, you can better communicate with everyone and easily express your own design ideas. umlunified Modeling Language (UML) is also known as the unified modeling language or standard modeling language, it was an OMG standard in 1997. It is a graphical language that supports modeling and software system development. It provides modeling and visualization support for all stages of software development, including requirement analysis to specifications, to construct and configure a class rectangular box represents a class, class chart is divided into three layers
    1. The first layer is the class name. If it is an abstract class, the class name is in italic, and the animal class in
    2. The second layer is the feature of the class (usually the member attribute of the class)
    3. The third layer is the class operation (usually the class member method)
Note: "+" indicates public, "-" indicates private, and "#" indicates that the protected animal class is an abstract class and cannot be instantiated, human interfaces can be instantiated in two ways: rectangular notation (Driving Interface) and lollipop notation (Driving interface in humans ).
    • Rectangular representation, with <interface> or <interface> at the top, the first action interface name, and the second action interface method.
    • Lollipop notation, with the interface name beside the circle. The interface method appears in the implementation class.
Generalization indicates the inheritance relationship between the class and the class, the inheritance relationship between the interface and the interface, or the Implementation relationship between the class and the interface. The general relationship is directed from the subclass to the parent class, which is opposite to the inherited or implemented method. Use a hollow triangle + solid line to represent inheritance. In the static structure diagram, drag and drop between the parent class and the Child class to link them. The arrow points to the parent class, and the other part points to the Child class. The interface is represented by a hollow triangle + dotted line. Dependency for two relatively independent objects, when an object is responsible for constructing an instance of another object or dependent on services of another object, the two objects are mainly dependent on each other. Dependencies are embodied in local variables, method parameters, and calls to static methods. For example, animals have several major features, such as metabolism, reproduction, and life. To make animals alive, they need oxygen, water, and food. That is to say, animals depend on oxygen and water. Code The aggregate relationship between local variables, method parameters, and call aggregation of static methods is the relationship between the whole and the part, and the part can exist independently from the whole. If a car and a tire are in the overall and partial relationship, the tire can still exist when it leaves the car. A solid line with a hollow diamond is used to indicate that the composition of member variables in the Code is the relationship between the whole and the part, but the part cannot be independent from the whole. For example, if the company and some are member variables in the composite link code, you can learn and record them!

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.