The OOP & refactor project weekly report 5

In this week I started the second phase of my work — OOPing table related scripts. I’d like to create a basic MVC structure for table related scripts. Before diving into the MVC structure, in this week I was decomposing tbl_*.lib.php for the convenience of the future work.

Files Covered In This Week

  • gis_data_editor.php
  • tbl_gis_visualization.php
  • GIS_Visualization.class.php
  • tbl_columns_definitions_form.lib.php
  • central_columns.lib.php
  • normalization.lib.php
  • Table.class.php
  • tbl_indexes.lib.php

Outcomes In This Week

The new GIS_Visualization class
First I found that the effect of the GIS_Visualization class is to convert raw data into diagrams and images. So I used Factory Pattern on it, and replace the constructor with a new private constructor. When we need to use this class, we can just use it in this way:

require_once 'libraries/gis/GIS_Visualization.class.php';
PMA_GIS_Visualization::get($sql_query, $options, $row, $pos, $data = null);

Notice: The $sql_query is the SQL using to fetch raw data from database, and the $row and $pos is the same as function PMA_GIS_modifyQuery($sql_query, $visualizationSettings, $rows = null, $pos = null) before. When we specify $data field in the constructor, other parameters except $options make no effect.

Some tbl_*.lib.php scripts decomposed
I am going to create a TableController to handle logic just I mentioned before, so I decomposed them and move these logics into corresponding tbl_*.php for convenience. Logic processing codes can be easily extracted from tbl_*.php when I started to create the TableController class with these logics represented as methods.

Somethings about the tbl_columns_definition_form.lib.php
Now there is only one functions PMA_getHtmlForColumnAttributes left in the tbl_columns_definition_form.lib.php. After I figure out ways to elimate it, I will create a new PR.

What Will I Do Next

Now I have almost finished decomposing tbl_*.lib.php scripts. In next few days I will create a TableController class for handling logic processing and communicate with the Table class to fetch data. The TableController class should available at June.18th.

The OOP & refactor project weekly report 5

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s