Php design mode-UML class diagram _ PHP Tutorial

Source: Internet
Author: User
Php design pattern-UML class diagram. 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. of course, I should first understand the design patterns before using the design patterns.
I have been using php for more than two years. I have prepared to write frequently-used design patterns based on my own practical experience. of course, 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, we can better communicate with you and express our design ideas easily.


UML
Unified Modeling Language (UML), also known as the Unified Modeling Language or standard Modeling Language, was an OMG standard in 1997. it is a graphical Language that supports Modeling and software system development, provides modeling and visualization support for all stages of software development, from Requirement Analysis to specification, to construction and configuration


Class
Rectangular boxes represent a class. class diagrams are divided into three layers.
The first layer is the class name. if it is an abstract class, the class name is in italic, and the animal class in
The second layer is the feature of the class (usually the member attribute of the class)
The third layer is the class operation (usually the class member method)
Note: "+" indicates public, "-" indicates private, and "#" indicates protected.



Animal class is an abstract class, which cannot be instantiated, while humans can be instantiated.


Interface
Interfaces can be expressed in two ways: Rectangular Notation (the driving interface) and lollipop notation (the driving interface in humans ).
Rectangular representation, with < <接口> > Or < >, First action interface name, second action interface method
Lollipop notation, with the interface name beside the circle. the interface method appears in the implementation class.



Generalization)
Represents the inheritance relationship between classes, the inheritance relationship between interfaces, or the implementation relationship between classes on interfaces. 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 one object is responsible for constructing an instance of another object or dependent on the service 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 performance
Parameters of local variables, methods, and static methods



Aggregation)
The aggregation relationship 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. Expressed by solid line with hollow diamond


Code performance
Member variables



Composition)
Is the relationship between the whole and the part, but the part cannot leave the whole but exists separately. For example, the company and the part are in a composite relationship.


Code performance
Member variables



Postscript
There are some more to be added. learn and remember!

I have been using php for more than two years. I have prepared to write common design patterns based on my own practical experience. of course, before using the design patterns, I must first understand the design patterns, so...

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.