Blog description

Standard

Hi guys,

Thanks for coming my blog. Here is my home for GSOC2013: Refactoring Server View on PMA

Following is my proposal:

Name

xmujay

Chinese Name: Bin Zu(祖斌)

Location

  • Country : China
  • Time Zone : GMT + 8

Education

Undergraduate, Beijing University of Science and Technology

Email / IRC / Jabber

xmujay@gmail.com

Synopsis

While reading some server view source code of PMA, I found that the source code has some problems: not easy read, not easy reusable, full of long function, full of long file. Because PMA is a big project which is developed by a lot of Programmers from all over the world, we should enhance the maintainability to let more developers join in. From other side, in a project’s life cycle  sometimes we need to re-factor the code if the code starts smelling bad and it’s hard to maintain and even harder to add new features. By enhancing the readability and maintainability of code, re-factoring makes it easier for us to deal with the code. This idea aims to re-factor the code on “Server view” and make the code easy to understand and easy to reuse. It won’t involve changing the existing functionality of these scripts, nor would it introduce new functionality.

Benefits to the users

Because this project won’t involve changing the existing functionality of these scripts, nor would it introduces new functionality  the project would not benefit the common users directly, but it will be a big benefit to our developers. With these re-factoring, developers can use the existing codes by calling or extending the same functions and make the develop process more easily.

Project Details

 I will re-factor the code in the following aspects:

1.         Render the HTML element at once (using Response::AddHtml instead of echo)

2.         Fix HTML and PHP mixture

3.         Fix code indention

4.         Use better variable for readability

5.         Fix PHP tags and ugly code in the code base

6.         Make the source code better structured.

7.         Reduce Long lines & Long functions & Long files

8.         Comments: Making the code self-documenting by mitigating the need for many inline comments.

9.         Introduce OOP concept the PMA code, so that the code can be reused easily.

10.       The location of a particular function or code block is also important, so functions/code blocks will be moved to appropriate places/scripts if required.

11.       There are also many nested if-else blocks in the code. So, removal of any unnecessary

If time available, I will re-factor the following issues:

1.         Increase the corresponding Unit testing.

2.         Better performance, UI and user experience

The server view contains several files with prefix: server_. We should re-factor them one by one. They also include some library files.

  1. 1.    the display PHP files: starting with server_ prefix.

server_binlog.php      server_plugins.php         server_status_monitor.php

server_collations.php  server_privileges.php      server_status_queries.php

server_databases.php   server_replication.php     server_status_variables.php

server_engines.php     server_sql.php             server_variables.php

server_export.php      server_status.php

server_import.php      server_status_advisor.php

Take server_ privileges.php for example:

  • This file is a very large file and there are HTML and PHP mix tags in this file. So this file is not structured well. Therefore this code is not readable. We can separate these HTML tags and PHP tags. Then we can nicely split PHP snippet into several functions, then use this PHP functions in HTML tags. It will improve the readability of the code. The code will be very smart by using set of re-factoring method. Then we can write unit test for these functions to make sure that functions work properly.
  • And other issue is that the render code is using “echo”. We should render them at once, so before render, we should collect the HTML element. There is no need to echo in either function. Let both of them return a Html string, call those functions in the place you need them and echo  the result there. Or feed it to the addHtml() method from the Response class that is already defined in every file behind an accessible page.
  • See for more info on how to use this. http://wiki.phpmyadmin.net/pma/Generating_pages_and_ajax_responses_in_pma4

We should refactor it:

  • All the functions are re-factored one by one considering their functionality, coding conventions, and readability of the code and re usability of the code.
  • Library files will return the specific output or render HTML codes at once (at the end of the function) without rendering the HTML codes everywhere inside the function itself.
  1. 2.    Backend files.

server_common.inc.php  server_privileges.lib.php  server_variables_doc.php

  • These three PHP files also somewhat ugly, because of they contain lot of code with conditions, loops. It is better if we clean the code to make it more understandable and structured by reducing number of nesting levels of conditions, implementing several functions to do the same thing in a smart way without changing the behavior of the application.

 Take server_privileges.lib.php for example:

  • This file contains huge ‘if’ conditions like thousands of lines. It should re-factor to reduce the complexity by implementing several functions. And we can improve the readability of the source code.

Deliverables

After this project, reusable, re-factored, easy readability code will deliver to PMA, so that the development process will be easier and effective.Because this project won’t involve changing the existing functionality of these scripts, nor would it introduces new functionality  the project would not benefit the common users directly, but it will be a big benefit to our developers. With these re-factoring, developers can use the existing codes by calling or extending the same functions and make the develop process more easily.

One thought on “Blog description

  1. Pingback: Bin Zu: Blog description | PHP World

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s