PHP and UML class diagram PHPandUMLClassDiagrams_PHP tutorial

Source: Internet
Author: User
PHP and UML class diagrams PHPandUMLClassDiagrams. This short article is well written. it can be said that using PHP to explain UML (or conversely) is an innovation. through this article, I also found a good site: www.phppatterns.com. This short article on various UML techniques is well written. using PHP to explain UML (or conversely) can be said to be an innovation. through this article, I also found a good site: www.phppatterns.com. The translation of various UML terms comes from The book "The Unified Modeling Language User Guide" I am reading. UML (Unified Modeling Language) is a mechanism for expressing software through graphs. Essentially, it allows us to design our program through drawing, and if there is a corresponding tool, we can even directly generate code from the graph. In this article, we will look at how PHP code is presented by using the UML class diagram. We will start directly, assuming that you have the knowledge of UML, and list some PHP code and their corresponding UML representation as an example -- but this is not a complete analysis of the class diagram. If you have not been familiar with UML, you can add some knowledge before you start reading it. we have collected some resources listed at the end of this article. [Inheritance relationship] the PHP keyword extends allows one class (subclass) to inherit from another class (parent class ). The UML method is as follows: note that the triangle is on the parent class side. [Associations Association] Associations occur between two classes that do not have a relationship but may need to access each other, such as Model and View ), view requires the Model to provide data for display. There are several different types of association: * Aggregation is when a class (Model in the following example) accesses another class (Dao in the following example, the second type (Dao) may have been instantiated externally ($ dao. If the first object ($ model) is "down", the second object ($ dao) will continue to "live ". This is common when it comes to data access objects, which may be passed to many objects. even if these objects are "hung", the data access objects are still "healthy ". This method normally explains part of the first class (Model) controlling the second class (Dao. For example: Dao = & $ dao;} function doSomething () {$ this-> dao-> getSomething () ;}$ dao = new Dao; $ model = new Model ($ dao); $ model-> doSomething ();?> In UML, the hollow diamond is on the control class side. * Composition occurs when one class (View in this example) instantiates another class (LinkWidget in this example), so that when the former (View) when "Hung Up", the latter () also followed the situation of "playing. In other words, the first class controls all of the second class. The following is an example in PHP: LinkWidget = new LinkWidget;} function renderPage () {$ this-> page = $ this-> linkWidget-> display () }?> In UML, the solid diamond is on the control class side. [Messages message] a message occurs when a class (View in this example) "communicates" with other classes (HtmlUtils in this example) and does not control its (HtmlUtils) instance. The relationships between these classes are also association ). In PHP, the operator: used. For example:: I think this method is similar to the case where the member function unHtmlEntities () in the HtmlUtils class in C ++ is static, so that you can directly use "class name :: the member function name (HtmlUtils: unHtmlEntities () is called. This indicates that the message is sent from the View to HtmlUtils. (one-way transmission), and the message can also be sent in two directions. ErrorMsg) ;}} class SomeClass {var $ errorMsg = This is an error message; function someFunction () {if (DEBUG = 1) {Debug :: display () ;}} define (DEBUG, 1); $ someClass = & new SomeClass; $ someClass-> someFunction ();?> [Output information: "This is an error message"] SomeClass sends a message to Debug. Debug accesses the $ errorMsg attribute of SomeClass. [Resources] Introduction to UML from the Object Management Group Posideon UML-a tool for drawing UML diagrams and generating Java (sadly no PHP), the community edition being free to use. based on Argo UML, an open source project. object Mentor on uml a uml Reference Card

Parse (or vice versa) is an innovation. through this article, I also found a good site: www.phppatterns.com. Various UML techniques...

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.