[Phpmyadmin-devel] refactoring and superglobals

Piotr Przybylski piotr.prz at gmail.com
Fri May 11 09:05:32 CEST 2012


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




More information about the Developers mailing list