[Phpmyadmin-devel] Refactoring: Displaying query results

Chanaka Dharmarathna pe.chanaka.ck at gmail.com
Tue May 22 19:07:47 CEST 2012


On Tue, May 22, 2012 at 6:02 PM, Rouslan Placella <rouslan at placella.com>wrote:

> 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
>
>
> ------------------------------------------------------------------------------
> 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 Rouslan,

Thanks for participating to this discussion and share your valuable
suggestions.

As I remember Michal has already suggested to not to use an object of this
case.
And use PMA_Display::someFunction where needed.
Thats why I focused on static fields and behaviors.

The constructor of the function only executed, if create an object of a
class. (I think your code trying to say create an object, new keyword is
missing there).
So I don't think to get the use of a constructor. That's why I'm using a
function for initialize instance variables.

I'm agreed to use more meaningful name. It is better if we can name it as
PMA_DisplayTable .

Regards !
-- 
____________________________________

Chanaka Indrajith
Bsc.Computer Engineering Undergraduate
Faculty of Engineering
University of Peradeniya
Sri Lanka
____________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20120522/4a70ca14/attachment.html>


More information about the Developers mailing list