PHP and UML class diagram phpandumlclassdiagrams_php tutorial

Source: Internet
Author: User
This essay is good, the use of PHP to explain the UML (or conversely) can be said to be an innovation, through this article, I also found a good station: www.phppatterns.com. The translation of the UML terms comes from the Unified Modeling Language User Guide, which I am looking at. UML (Unified Modeling Language, Unified Modeling Language) is a mechanism for representing software by means of graphs. Essentially it allows us to design our programs by drawing, and if we have the tools, we can even generate the code directly from the graph. In this article, we will look at how the PHP code is represented by the use of the UML class diagram (the class diagram). We will start directly, assuming that you have the knowledge of UML and enumerate some PHP code and their corresponding UML representations as examples-but this is not a complete analysis of the class diagram. If you have not yet contacted UML, you can add some knowledge before you start reading, and we have collected some resources at the end of this article. [Inheritance inheritance relationship] The PHP keyword extends allows one class (subclass) to inherit from another class (the parent Class). The UML approach is expressed as follows: Note that the triangle is on the parent class side. The [Associations Association Relationship] Association Relationship (associations) occurs between two classes that do not exist but may need to be accessed from each other, such as model (models) and view (view), and view requires model to provide data for display. There are several different types of associations: *aggregation* aggregation Aggregation (Aggregation) is the second Class (DAO) that might have been externally instantiated ($dao) when one class (the following example is model) accesses another class (the following is DAO). If the first object ($model) is "hung", the second object ($dao) will still remain alive. This is common when it comes to data access objects, which may be passed to many objects, which are still "alive" even if the data access object is "hung". This approach normally explains part of the first Class (Model) to control the second class (Dao). As an example: dao=& $dao; } function DoSomething () {$this->dao->getsomething ();}} $dao =new DAO; $model =new model ($DAO); $model->dosomething ();?> is represented in UML as: The Hollow diamond is on this side of the control class. The *composition* combination (composition) occurs when a class (in the case of view) instantiates another class (in the example, Linkwidget) so that the current (view) "Hangs" when the latter () also follows the "Finish" case. In other words, the first class controls all of the second class. Here is an example of PHP: Linkwidget=new Linkwidget; } function Renderpage () {$this->page= $this->linkwidget->display ()}}?> is represented in UML: a solid diamond is on the control class side. The [Messages message] Message (Messages) occurs when a class (in the example, view) "communicates" with other classes (htmlutils in the example) without controlling an instance of it (htmlutils). The relationship between these classes is also associated with the Relationship (association). In PHP, it usually happens in the operator:: When used. For example: I think this approach is similar to the case where the member function unhtmlentities () in the Htmlutils class in C + + is static, so that you do not have to instantiate htmlutils directly through the "class name:: member function name" method ( Htmlutils::unhtmlentities ()) to invoke. This is expressed as: The message is sent from view to Htmlutils. (One-way send) Similarly, messages can also be sent in both directions. ERRORMSG); }} class SomeClass {var $errorMsg =this is an error message, function someFunction () {if (debug = = 1) {debug::d Ispla Y (); }}} define (debug,1); $someClass = &new SomeClass; $someClass->somefunction ();?> [Output information: "This is an error message"] Here SomeClass sends a message to Debug,debug visited SomeClass $e The Rrormsg property. [Resources Resource] Introduction to UML from the Object Management Group posideon uml-a tool for drawing UML diagrams and generating Java (s Adly no PHP), the Community edition being free. Based on Argo UML, an open source project. Object Mentor on UML A UML Reference Card

http://www.bkjia.com/PHPjc/531980.html www.bkjia.com true http://www.bkjia.com/PHPjc/531980.html techarticle This essay is good, the use of PHP to explain the UML (or conversely) can be said to be an innovation, through this article, I also found a good station: www.phppatterns.com. Each UML technique ...

  • 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.