2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、Application of lightweight MVC-like structure in PHPGuanhua Wang School of Computer Science MVC; lightweight; OOP I. INTRODUCTIONObject-oriented programming (OOP) is a programming paradigm that uses “objects“ – data s

2、tructures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulatio

3、n, modularity, polymorphism, and inheritance. Many modern programming languages now support OOP. Since the proposed of the method that OOP models real- world objects with software counterparts, the outstanding advanta

4、ges of OOP in aspects like programming and software engineering cause the increasing numbers of organizations using it to implement their applications and applying it into the improvement of various types of programm

5、ing languages. However, as one of the most widely used web script syntax present, since the creation in 1994, PHP went through the transformation from the uncomplicated version as Personal Home Page Tools to the rece

6、nt unique grammar that mixed C, Java, Perl and PHP’s own innovative grammar. For the purpose of meeting the programming method’s progress, the later version since PHP 4.0 had added the features of OOP. But when compar

7、ed with its outstanding performance in small web sites, lightweight application, the front of large sites, the OOP feature seemed like to be inferior slightly. MVC, which was described in 1979, by Trygve Reenskaug, t

8、hen working on Smalltalk at Xerox PARC, is not a totally new concept. In the design of web applications, MVC is implemented by web template systems as a “View for web“ component. MVC is often seen in web applications

9、 where the view is the HTML or XHTML generated by the app. The controller receives GET or POST input and decides what to do with it, handing over to domain objects (i.e. the model) which contain the business rules and

10、 know how to carry out specific tasks such as processing a new subscription, and which hand control to (X)HTML- generating components such as templating engines, XML pipelines, Ajax callbacks, etc. In order to comply

11、 the OOP programming of PHP, the architecture of Model-View-Controller (MVC) is brought forward again. Although this idea improved PHP codes’ reuse and programming efficiency, this architecture had an obvious defect

12、---- reduction in operating efficiency. The OOP of PHP urgently needs a new form to address the balance of efficiency and reuse. II. TYPICAL PHP MODE AND MVC A. Introduction of Typical PHP Programming Mode Because of P

13、HP’s features that it is a scripting language that is embedded in HTML documents in the implementation of the server, the format of traditional programming of PHP is closely combined with HTML documents. This results

14、in the typical PHP programming mode of process-oriented. Embedding the PHP script according to the order of HTML document that already be designed has been the traditional format of PHP programming. It mixed the code

15、s in data layer like the statement of database query and the codes in presentation layer like HTML. A typical PHP program is like this, PHP Test ??___________________________________ 978-1-61284-109-0/11/$26.00 ©

16、2011 IEEE c. Involving in complicated backstage execution will to a certain degree reduce the efficiency of page running. It can be seen from the comparison that MVC is superior to traditional PHP format in the aspe

17、ct of software engineering. Using MVC, a PHP application can be arranged using OOP method, making it convenient for software developers to manage it as a project. However, this convenience is at the expense of cost e

18、fficiency. As to small- sized and even medium-sized applications which emphasize runtime efficiency, MVC pattern may not be suitable, for the reason that it will increase additional workload and make the application m

19、ore complicated. More specifically, MVC adds an engine on the server that pages will send requests to. Originally, PHP is a high-efficient solution, but because of the engine added by MVC, its speed is more or less i

20、nfluenced. Every time paper sent request to the server, the expense of launching engine is not small. IV. LIGHTWEIGHT MVC-LIKE FORMATIn order to take all of those things, readability, maintainability, reconfigurable an

21、d application execution efficiency, into account, we propose a lightweight class of MVC format. The lightweight MVC can also be defined as a MVC-like. Same as the traditional MVC, the lightweight MVC also emphasizes

22、the function division of Web systems, and it consists of three parts that are similar to the original MVC. On the other hand, the lightweight MVC is much different from the original one. In the lightweight MVC, M, V

23、and C are correspond to *.phtml, *.class (or *.class.php for the sake of security) and *.php files. The lightweight MVC takes example by the thought of software engineering and makes PHP code much more readable, main

24、tainable and reusable. Besides, it makes good use of Object-oriented design, which results in easier coding. In addition, since there is no need to add engine to server, the execution efficiency is much better than th

25、e original MVC pattern. Nevertheless, because of the use of class and encapsulation, it will generate redundant code. Because of that, the efficiency of lightweight MVC is in some degree lower than original PHP code.

26、 Fortunately, in contrast to the improvement of original MVC pattern, this influence is just inappreciable. To show how this lightweight MVC-like format optimizes the common used MVC structure, here the working struc

27、ture of MVC and lightweight MVC is compared. Figure 2 shows the structure of a common MVC framework. In this framework, the Controller class calls the Model classes and functions to fulfill a specific feature. Then

28、the Controller gets the return message. Next it will call a View file for return. The Controller uses the return message from Model to fill the View, and then sends a final page to the client. Besides this, some Model

29、 classes have their own functions which can call a View page. Figure 2. Structure of MVC ?*. php?*. pht ml ?*. cl ass. php? Cont rol l eVi ew? Model ?Figure 3. Lightweight MVC-like Structure As for the lightweight MVC-l

30、ike structure shown in Figure 3, the call function has been simplified. In this structure, the Controller function is not a packaged class object, but a *.php file which is written in the traditional form. This *.php

31、 file includes *.class.php files as Models and *.phtml files as Views. Because in lightweight applications, most *.php pages have different features that will seldom be used in other files, and these files have few re

32、lations with other files. In this lightweight MVC-like structure, each Controller with different features has its own *.php file. In this file, the *.class.php files and *.phtml files are joined together, the results

33、 of class functions from *.class.php files are put directly into the *.phtml files. In this way, during the period of development, the Controller, Model and View are developed and maintained separately. But in usage,

34、this structure removes packaged Controller classes; this can save the application from calling too many functions used in other Controller files. Also, this structure removes the function calls to View files. This fe

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論