[Phpmyadmin-devel] refactoring and superglobals

Thilina Buddika Abeyrathna thilinaabeyrathna at gmail.com
Fri May 11 13:50:17 CEST 2012


On Fri, May 11, 2012 at 12:35 PM, Piotr Przybylski <piotr.prz at gmail.com>wrote:

> 2012/5/11 Thilina Buddika Abeyrathna <thilinaabeyrathna at gmail.com>:
> >
> >
> > On Mon, May 7, 2012 at 7:14 PM, Thilina Buddika Abeyrathna
> > <thilinaabeyrathna at gmail.com> wrote:
> >>
> >>
> >>
> >> On Mon, May 7, 2012 at 5:34 PM, Marc Delisle <marc at infomarc.info>
> wrote:
> >>>
> >>> Hi,
> >>>
> >>> We previously had a script called grab_globals.lib.php, which created
> >>> global variables from a few superglobals arrays.
> >>>
> >>> When this script was removed a few weeks ago, we added at the beginning
> >>> of other scripts some code, for example in tbl_change.php:
> >>>
> >>> if (isset($_REQUEST['where_clause'])) {
> >>>    $where_clause = $_REQUEST['where_clause'];
> >>> }
> >>>
> >>> In the upcoming refactoring efforts, we should avoid this, because,
> >>> looking at the code further in the script, it's difficult to see the
> >>> origin of $where_clause. So, we should only refer to
> >>> $_REQUEST['where_clause'] (except in the situations where the global is
> >>> modified afterwards).
> >>>
> >>> Another benefit is that this variable would not need to be passed as a
> >>> parameter to functions.
> >>
> >>
> >> Hi Marc,
> >> Thank you very much for pointing out.
> >>
> > Hi Marc,
> > when I write functions for columns(function column, null column, value
> > column, ...) in insert form (line 408 in tbl_change.php) I have to pass
> lot
> > of parameters. But it is not a good practice for refactoring. And use
> > global variables also not a good solution. So is it ok to use a parameter
> > array. I need to pass around 10 parameters. I like to see
> your suggestions.
> >
>
> 10 is not nice but I think it's more readable, if you have to pass
> these 10 arguments two or three times it shouldn't be too troublesome.
> If you don't like it, maybe create a special object type that you will
> pass around? But not a stdObject, a custom one so that parameters will
> be properly documented and you will get code assist in some smart
> editors (just a suggestion).
>
> --
> Regards,
> Piotr Przybylski
>

Hi Piotr,
Thank you for your suggestion.
-- 
Regards.

Thilina Buddika Abeyrathna,
Department of Computer Engineering,
Faculty Of Engineering,
University of Peradeniya,
Sri Lanka.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20120511/aaa49bb1/attachment.html>


More information about the Developers mailing list