The OOP & refactor project weekly report 1

After a whole week of work, I have almost finished the job of first phase — calculate dependencies. Firstly I used automated tools like doxygen and phpstorm to determine where the functions is called. Then I can decide how to refactor it.

Files covered in this week

  • tbl_chart.lib.php
  • tbl_indexes.lib.php
  • tbl_relation.lib.php
  • tbl_printview.lib.php
  • tbl_gis_visualization.lib.php
  • tbl_columns_definition_form.lib.php
  • Table.class.php

But the works on tbl_relation.lib.php and Table.class.php are not finished yet. Also the TableSearch.class.php will be covered in less than 2 days.

Outcomes in this week

libraries/tbl_chart.lib.php

PMA_getHtmlForTableChartDisplay:31
Function to get html for displaying table chart
Callers:
tbl_chart.php:136

libraries/tbl_indexes.lib.php

PMA_getNameAndTypeOfTheColumns:20
Function to get the name and type of the columns of a table
Callers:
tbl_indexes.php:50

PMA_handleCreateOrEditIndex:47
Function to handle the creation or edit of an index
Callers:
tbl_indexes.php:28

PMA_getSqlQueryForIndexCreateOrEdit:93
Function to get the sql query for index creation or edit
Callers:
tbl_indexes.php:51

PMA_prepareFormValues:185
Function to prepare the form values for index
Callers:
tbl_indexes.php:21

PMA_getNumberOfFieldsForForm:208
Function to get the number of fields for the form
Callers:
tbl_indexes.php:37

PMA_getFormParameters:236
Function to get form parameters
Callers:
tbl_indexes.php:39

PMA_getHtmlForIndexForm:264
Function to get html for displaying the index form
Callers:
tbl_indexes.php:53

libraries/tbl_columns_definition_form.lib.php

PMA_getFormsParameters:23
Get table related parameters from $_REQUEST object
Callers:
*libraries/tbl_columns_definition_form.inc.php:54*

PMA_getHeaderCells:315
Get header cells for showing table
Callers:
PMA_getHtmlForCreateNewColumn
at
libraries/normalization.lib.php:81
libraries/tbl_columns_definition_form.inc.php:76

PMA_getMoveColumns:396
Function for moving, load all available column names
Callers:
libraries/tbl_columns_definition_form.inc.php:68

PMA_getRowDataForRegeneration:417
Get row data for regenerating previous when error occurred
Callers:
PMA_handleRegeneration
at
libraries/tbl_columns_definition_form.lib.php:532

PMA_getSubmitPropertiesForRegeneration:497
Get submit properties for regenerating previous when error occurred
Callers:
PMA_handleRegeneration
at
libraries/tbl_columns_definition_form.lib.php:537

PMA_handleRegeneration:529
An error happened with previous inputs, so we will restore the data * to embed it once again in this form
Callers:
libraries/tbl_columns_definition_form.inc.php:105

PMA_getFormParamsForOldColumn:1400
Get form parameters for old column
Callers:
libraries/tbl_columns_definition_form.inc.php:165

libraries/tbl_gis_visualization.lib.php

PMA_GIS_modifyQuery
Returns a modified query iwht only the label column and spatical columns
Callers:
tbl_gis_visualization.php:70

PMA_GIS_visualizationResults
Formats a visualization for the GIS query results
Callers:
gis_data_editor.php:92
gis_data_editor.php:95
tbl_gis_visualization.php:109

PMA_GIS_saveToFile
Generate visualization for GIS query results and save it to a file
Callers:
tbl_gis_visualization.php:82

Notes on Table.class.php

I suggest that PMA_Table should be created by PMA_DatabaseInterface::getTable($db, $table) and the PMA_DatabaseInterface objecct should be injected as a parameter in constructor. And there will be some changes for the class:
These functions are used to handle errors or messages in an array, but we can use a throw statement for that

  • getLastError
  • getLastMessage

These functions are not used, so we can remove them:

  • set
  • get

These functions are static methods, and we needs to make them a member function

  • isView
  • isUpdatableView
  • analyzeStructure
  • isMerge
  • getStatusInfo
  • countRecords

These functions are not table related actions. They are UI related actions, therefore I’d like to move them into other classes (maybe PMA\Template?)

  • getUiProp
  • setUiProp
  • removeUiProp

The public $cache property should be moved into PMA_DatabaseInterface.

That’s all for this week! I will fix issues mentioned by my mentor in the PR 1642 as soon as possible.

Advertisements
The OOP & refactor project weekly report 1

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