PHP with UML class diagram

zhaozj2021-02-08  256

PHP with UML class chart PHP and UML Class Diagrams PHP and UML Class Diagrams Phase: Harry Fuecks 26.11.2002 18:16 UML is an illustration of a software form structure. In principle, he allows us to design your own program in the drawing method, if Choosing the correct tool, you can also generate a code according to the graphics, we can see the PHP code in the form of UML in UML, we can use the UML class, and focus on the accurate code in UML. Performance form. This means that this content is not a complete class analysis. There are also some resources collected in the text. If you have not used UML, you can start from those resources. Inherited inheritancephp Keywords: Extends Allows you to inherit your class inheritance.

Class Senior {

}

Class Junior Extends Senior {

}

?>

In the UML category, the representation is as follows:

Inheritance Note Triangle is pointing to the parent class. The aggregated Associations joint occurs between the category does not have a relationship, but may need to access each other, like a model (Model) and a view (view), the view requires a model to provide data to display. There are two different combined type sharing aggregate aggregation shared polymerization, as follows: When a class (a) accesses other classes (b), the second class (b) may have been instantiated outside. If the first object "dead", the second object will continue "alive". This situation is very common in data access objects, some of them have passed multiple objects, which may have "dead" but the data access objects still exist. The first class (A) controls the first class (A) is described normally explained. Examples are as follows;

Class Dao {

Function getsomething () {

}

}

Class model {

Var $ DAO;

Function Model (& $ DAO) {

$ this-> DAO = & $ DAO;

}

Function DOSMETHING () {

$ this-> Dao-> getsomething ();

}

}

$ DAO = New DAO;

$ model = new model ($ DAO);

$ model-> DOSMETHING ();

?>

In UML, the performance is as follows:

Aggregation hollow diamond points to the controller class. Combined aggregation Composition combination aggregation occurs as follows: The first class (a) instantiates the second class (b), the first class (a) "dead", the second class (b) simultaneously " Death. In other words, the first class (a) controls all of the second class (b). AN EXAMPLE IN PHP; PHP example;

Class LinkWidget {

}

Class view {

Var $ linkwidget;

Var $ Page;

Function view () {

$ this-> linkwidget = new linkwidget;

}

Function renderpage () {

$ this-> Page = $ this-> linkwidget-> display ()

}

}

?>

UML is manifested;

ComPosition solid rhombus points to the controller class. Message Messages Messages The situation is as follows: A class "AC data" by controlling the instance of another class. The relationship between them is also aggregated. When using :: operating symbols in PHP. Such examples;

Function UnHtmlentities ($ STR) {

$ TRANS_TBL = GET_HTML_TRANSLATION_TABLE (HTML_ENTITIES);

$ TRANS_TBL = Array_flip ($ TRANS_TBL);

Return StRTR ($ STR, $ TRANS_TBL);

}

}

Class view {

Function renderpage {

$ text = htmlutils :: unHtmlentities ($ text);

}

}

?>

The performance is as follows;

One Way Message Message From View to HTMLUTILS, it is of course possible to send two different ways, as follows;

Class debug {

Function Display () {

Echo ($ this-> 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: "this is an error message"]

TWO WAY Messages Here SomeClass sends a message to Debug, Debug to access the $ ERRORMSG property of someClasss. Resources ResourcesIntroduction 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 Original: http://www.phpppatterns.com/index.php/Article/ArticleView/15/1/ The end contains some tools to discuss, you can take a look. Welcome to correct, exchange of Tiyi@163.com

转载请注明原文地址:https://www.9cbs.com/read-2879.html

New Post(0)