Tuesday, May 22, 2012

GSoC 2012 - 2nd Week Progress

       This is my second week of GSoC 2012 project since I have started my coding before the official day. I have started to refactoring the file display_tbl.lib.php in PMA. Last week I remove the HTML rendering inside the functions it selves in this file. Some readability improvements also done.

         In this week, I mainly focused on improving the readability of the code inside display_tbl.lib.php file. There were several function which having more than 200 code lines in this file. I broke those functions into sub functions in a way that each sub function do a specific portion for the bigger function. As well the sub functions were not having very large code blocks and those functions were placed just after the referring function.  The names of these sub functions were little longer sometimes, because of they express valuable details for the developer at the first time.

                 In some places there were used similar code segments again and again even in the same functions. Those similar code segments were moved into new sub functions with the help of some additional parameters to separate out the small differences. (PMA_getOperationLinksForVerticleTable, PMA_getColumnParams etc.)

I have mentioned those larger functions which were broken into sub functions with there names below.

  • PMA_getTableNavigation
    • PMA_getMoveBackwardButtonsForTableNavigation
    • PMA_getShowAllButtonForTableNavigation
    • PMA_getMoveFarwardButtonsForTableNavigation
    • PMA_getAdditionalFieldsForTableNavigation
  • PMA_getTableHeaders
    • PMA_getSortByKeyDropDown
    • PMA_getDataForResettingColumnOrder
    • PMA_getOptionsBlock
    • PMA_getFullOrPartialTextButtonOrLink
    • PMA_getFormForMultiRowOperations
    • PMA_getCommentForRow
    • PMA_isInSorted
    • PMA_getSortingUrlParams
    • PMA_getSortOrderLink
    • PMA_getDraggableClassForSortableColumns
    • PMA_getDraggableClassForNonSortableColumns
  • PMA_getTableBody
    • PMA_getUrlSqlQuery
    • PMA_getColumnParams
    • PMA_getVerticalDisplaySupportSegments
    • PMA_getModifiedLinks
    • PMA_getDeleteAndKillLinks
    • PMA_getPlacedLinks
    • PMA_getResettedClassForInlineEdit
    • PMA_getClassForDateTimeRelatedFields
    • PMA_getDataCellForNumericFeilds
    • PMA_getDataCellForBlobField
    • PMA_getDataCellForGeometryFields
    • PMA_getDataCellForNonNumericAndNonBlobFields
  • PMA_getVerticalTable
    • PMA_getOperationLinksForVerticleTable
    • PMA_getCheckBoxesForMultipleRowOperations
  • PMA_getTable
    • PMA_getOffsets
    • PMA_getSortParams
    • PMA_getSortedColumnMessage
    • PMA_setMessageInformation
    • PMA_getMultiRowOperationLinks

         Apart from this I used some coding conventions for improve the readability. If the function is not too small one, an empty space were kept both after starting bracket of the scope and before ending bracket of the scope. Not only for that, wherever I saw the codes are seems packed and hard to read, I put empty lines between code segments. As well I followed the conventions suggested in my proposal.

                     At next week, I'm going to change my plans by giving the place to most prioritized task at the moment. I am going to make the display_tbl.lib.php file as a PHP class. As well I'm going to reduce the usage of global variables which are used in most of the functions. The strings used inside the functions for comparisons, will be replaced with constants. The design for the class will be discussed with the community on next week.

No comments:

Post a Comment