[Phpmyadmin-devel] GSOC 2012 - Refactoring: Insert/edit, Privileges, Operations, Structure
marc at infomarc.info
Sat Mar 24 16:26:00 CET 2012
Le 2012-03-24 09:43, prakul agarwal a écrit :
> Hello sir,
> Im new to PHP code refactoring. Going through this thread i worked out for
> tbl_structure.php (line 199-209):
> $b =
> echo " <th id=\"th$i\" class=\"$a[$i]\" > __('$b[$i]') </th>" ;
> This code has the same output as the already existing code, plus this
> removes redundancy and makes maintenance easier. Does this qualifies as
> good refactoring?
> thank you.
yes, this is good refactoring, but better refactoring would be:
- avoid generic names like $a, $b
- avoid using the constant 8, instead counting the elements in the array
Using a loop, like you did, is what I had in mind when I proposed this
challenge. Technically, after refactoring, the code had to produce the
same output, as I suspect your example does.
In this discussion, however, code improvement was gained not just by
refactoring, but by examining the reasons behing the code and
More information about the Developers