[Phpmyadmin-devel] Refactoring: Insert/edit, Privileges, Operations, Structure

Dieter Adriaenssens dieter.adriaenssens at gmail.com
Fri Mar 30 18:01:01 CEST 2012


On 30/03/2012 13:06, Shameeha Pp wrote:
> 
> 
> 
> 
>     Sir,
> 
>          I have gone through the project "Refactoring:Insert/edit,
>     Privileges,
>     Operation,Structure".
> 
>         I think that refactoring means technique for restructuring an
>     existing body of code, altering its internal structure without
>     changing its external behavior.
> 
>        I worked out for some portion of the application tbl_structure.php.
> 
>     <table id="tablestructure" class="data">
>     <thead>
>     <tr>
>         <th id="th<?php echo ++$i; ?>"></th>
>         <th id="th<?php echo ++$i; ?>">#</th>
>         <th id="th<?php echo ++$i; ?>" class="column"><?php echo
>     __('Column'); ?></th>
>         <th id="th<?php echo ++$i; ?>" class="type"><?php echo
>     __('Type'); ?></th>
>         <th id="th<?php echo ++$i; ?>" class="length"><?php echo
>     __('Length(bytes)'); ?></th>
>         <th id="th<?php echo ++$i; ?>" class="precision"><?php echo
>     __('Precesion'); ?></th>
>         <th id="th<?php echo ++$i; ?>" class="Scale"><?php echo
>     __('Scale'); ?></th>
>         <th id="th<?php echo ++$i; ?>" class="null"><?php echo
>     __('Null'); ?></th>
>         <th id="th<?php echo ++$i; ?>" class="default"><?php echo
>     __('Default'); ?></th>
>         <th id="th<?php echo ++$i; ?>" class="extra"><?php echo
>     __('Extra'); ?></th>
>     <?php if ($db_is_information_schema || $tbl_is_view) { ?>
>         <th id="th<?php echo ++$i; ?>" class="view"><?php echo
>     __('View'); ?></th>
>     <?php }
>     I transform the above code into the following code.
> 

Hi,

I can't find the code you mention here in tbl_structure, beside, the
names of the columns are not the same between the version before and
after refactoring. I think you are refering to a previous mail by Marc
Delisle where he set a small challenge for refactoring lines 199-209 in
tbl_structure.php, but this part of the code has since been update,
please check the latest version of master in our git repository.

>     <?php
>     $field=array("Name","Type","Collation","Attributes","Null","Default","Extra","View");
>     reset($field);
>     foreach ($field as $key => $value)
>     {
>         echo "__('$value')\t";
>     }
>     ?>

A few remarks :
- reset($field) is not necessary, because the foreach loop will go
through each element in the array
- best to use the gettext function : __() on the elements in the array,
and not in the foreach loop, because otherwise the script generating the
translation files will not pick these strings up.
- the original code had html tags (<th>) surrounding each element, they
don't appear in your example, actually all html tags seem to be missing
from your code
- in the original code, the 'View' element is displayed conditionally,
in your refactoring it is always displayed.

I hope this helps you.

-- 
Kind regards,

Dieter Adriaenssens

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20120330/f84f0471/attachment.sig>


More information about the Developers mailing list