RE: Making osCommerce more patch-friendly.

bobvin <[email protected]>
Newsgroups gmane.comp.web.oscommerce.devel
Message-ID <b6cf0bb8cf39799693f2f76e68cd55bc@osCommerce-Forums>
This message was sent from: Development
http://forums.oscommerce.com/viewtopic.php?p=152727#152727
----------------------------------------------------------------

[quote="Wayne Luke"]It is almost impossible to write PHP code to a 60 column right margin and have it be efficient and fast.[/quote]

Sorry, but I don't buy that lame excuse.

You can insert newlines almost anywhere in a PHP statement with no measurable effect on its efficiency.

For a concrete example, please take a look at this line of code from default.php and try to tell me, with a straight face, that it could not have been broken into two or more lines:

[code]
$category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $current_category_id . "' and cd.categories_id = '" . $current_category_id . "' and cd.language_id = '" . $languages_id . "'");
[/code]

I believe the following equivalent code would run with no measurable effect on performance:

[code]
$category_query = tep_db_query(
  "select cd.categories_name, c.categories_image from " .
  TABLE_CATEGORIES . " c, " .
  TABLE_CATEGORIES_DESCRIPTION . 
  " cd where c.categories_id = '" . 
  $current_category_id . 
  "' and cd.categories_id = '" . 
  $current_category_id . 
  "' and cd.language_id = '" . 
  $languages_id . "'");
[/code]

Sure, the character count for the expression increases from 308 characters to 333 characters, but now it's far easier to patch.

If the PHP engine spends 50% of its time parsing statements and the other 50% of its time executing them, the above change would result in less than a 5% decrease in performance.

Why is that so unacceptable?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.