[Phpmyadmin-devel] Refactoring: Displaying query results

Rouslan Placella rouslan at placella.com
Tue May 22 14:32:49 CEST 2012


On 22/05/12 12:57, Chanaka Dharmarathna wrote:
> On Tue, May 22, 2012 at 12:54 AM, Chanaka Dharmarathna<
> pe.chanaka.ck at gmail.com>  wrote:
>
>>
>>
>> On Mon, May 21, 2012 at 6:58 PM, Chanaka Dharmarathna<
>> pe.chanaka.ck at gmail.com>  wrote:
>>
>>>
>>>
>>> On Mon, May 21, 2012 at 6:31 PM, Michal Čihař<michal at cihar.com>  wrote:
>>>
>>>> Hi
>>>>
>>>> Dne Mon, 21 May 2012 12:28:42 +0530
>>>> Chanaka Dharmarathna<pe.chanaka.ck at gmail.com>  napsal(a):
>>>>
>>>>> Thanks for giving your feedback.
>>>>> Yes, I did more changes to the code.
>>>>> Pleas get me into the right track if I'm going wrong.
>>>>
>>>> I think you're heading in right direction - splitting the code to
>>>> smaller blocks which are easy to understand always helps.
>>>>
>>>> I'm currently commenting some things in your commits, so let's keep
>>>> this part on github.
>>>>
>>>> --
>>>>         Michal Čihař | http://cihar.com | http://blog.cihar.com
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Live Security Virtual Conference
>>>> Exclusive live event will cover all the ways today's security and
>>>> threat landscape has changed and how IT managers can respond. Discussions
>>>> will include endpoint security, mobile security and the latest in malware
>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>>> _______________________________________________
>>>> Phpmyadmin-devel mailing list
>>>> Phpmyadmin-devel at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
>>>>
>>>>
>>> Hi Michal,
>>>
>>> That's good to hear.
>>> I put a reply in github
>>>
>>>
>>> Regards !
>>> --
>>> ____________________________________
>>>
>>> Chanaka Indrajith
>>> Bsc.Computer Engineering Undergraduate
>>> Faculty of Engineering
>>> University of Peradeniya
>>> Sri Lanka
>>> ____________________________________
>>>
>>>
>> Hi Michal,
>>
>> I'm going to change my plans little bit.
>> At the moment I think the most prioritized task is to make the
>> display_tbl.lib.php file as a PHP class.
>> So, if there is no matter of that, I'll involve with this task in this
>> week (In my third week).
>>
>>
>> Regards !
>> --
>> ____________________________________
>>
>> Chanaka Indrajith
>> Bsc.Computer Engineering Undergraduate
>> Faculty of Engineering
>> University of Peradeniya
>> Sri Lanka
>> ____________________________________
>>
>>
> Hi Michal,
>
> I have a plan on introducing Display class instead of the set of global
> functions inside the display_tbl.lib.php file.
>
> Currently the only function which used by the outsiders is PMA_getTable().
> And the only outside file accessed this function is sql.php file.
>
> With the Display class,
> All fields and methods other that getTable() method are keep as private.
> To remove the use of global fields in every function, instance variables
> are used and they are initialized by a separate function which is inside
> the getTable() method. For initializing them Global variables are used.
>
> I have documented the rough plan about my design in my blog [0].
> The design for this should also be extend with the future plans of PMA.
> So I'm waiting to hear your comments and suggestions to create a solid
> design.
>
> [0] :
> http://chanakaindrajith.blogspot.com/2012/05/design-for-display-class-of-pma.html
>
> Regards !

Not sure why your methods are static and you have an initialisation 
method. To me it makes more sense to have non-static methods are the use 
of a constructor for the class. This way, the usage will be even more 
extensible. Also the class name is not very descriptive.

How about something like this?

$table = PMA_TableDisplay($GLOBALS['db'], $GLOBALS['table']);
echo $table->getDisplay();

class PMA_TableDisplay {
     private $_db;
     private $_table;
     public function __contruct($db, $table) {
         $this->_db = $db;
         $this->_table = $table;
     }
     public function getDisplay() {
         // ...
     }
     private static function getTableHeaders() {
         // ...
         $msg = getMessage($this->_db, $this->_table);
         // ...
     }
     // ...
}

BTW, what about extending our existing PMA_Table class? I'm not sure how 
good of an idea it is, so I'm just throwing it out there...

Bye,
Rouslan




More information about the Developers mailing list