<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ugly Code! &#187; php</title>
	<atom:link href="http://uglycode.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://uglycode.com</link>
	<description>c0ding is seriose busines!!!!1</description>
	<lastBuildDate>Thu, 15 Jul 2010 20:03:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>As much as I love WordPress&#8230;</title>
		<link>http://uglycode.com/2009/01/as-much-as-i-love-wordpress/</link>
		<comments>http://uglycode.com/2009/01/as-much-as-i-love-wordpress/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 12:44:13 +0000</pubDate>
		<dc:creator>analytik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[refuctoring]]></category>
		<category><![CDATA[ugly names]]></category>

		<guid isPermaLink="false">http://uglycode.com/?p=29</guid>
		<description><![CDATA[Seems that some WP developers are fans of refuctoring.

if &#40; &#40;$fQ=strpos&#40;$Fid,'&#34;'&#41;&#41;!==false &#41;
    $Fname = sanitize_title_with_dashes&#40;substr&#40; $Fid, $fQ+1, strpos&#40;$Fid,'&#34;',$fQ+1&#41;-$fQ-1 &#41;&#41;;


### wrapped in &#60;p&#62; ?
   $p_offset = &#40;$p_close &#60; $p_open&#41; ? $a-&#40;strlen&#40;$part_content&#41;-$p_open&#41; : $a;

Argh. Guys, seriously, how about some objects? How about some readable variables? How about instead of nesting function calls [...]]]></description>
			<content:encoded><![CDATA[<p>Seems that some WP developers are fans of refuctoring.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$fQ</span><span style="color: #339933;">=</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$Fid</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!==</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$Fname</span> <span style="color: #339933;">=</span> sanitize_title_with_dashes<span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$Fid</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fQ</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$Fid</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">,</span><span style="color: #000088;">$fQ</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #000088;">$fQ</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">### wrapped in &lt;p&gt; ?
</span>   <span style="color: #000088;">$p_offset</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$p_close</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$p_open</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$a</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$part_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #000088;">$p_open</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span></pre></div></div>

<p>Argh. Guys, seriously, how about some objects? How about some readable variables? How about instead of nesting function calls and using ugly ternary operators&#8230; ugh. Nevermind.</p>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://uglycode.com/2009/01/as-much-as-i-love-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>transactions</title>
		<link>http://uglycode.com/2008/12/transactions/</link>
		<comments>http://uglycode.com/2008/12/transactions/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 21:21:53 +0000</pubDate>
		<dc:creator>analytik</dc:creator>
				<category><![CDATA[ugly code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[transaction]]></category>

		<guid isPermaLink="false">http://uglycode.com/?p=22</guid>
		<description><![CDATA[
function run&#40;&#41; &#123;
  ...
  //DONT TOUCH !!! -&#38;gt; THIS DB TRANS STARTS, BECAUSE XYZ MODUL CONSIST OF DB::Commit() clausule
  DB::Trans&#40;&#41;;
  return $returnVal;
&#125;

Hey guys, let&#8217;s start a transaction here and expect that no one will ever change the code in any of the other 2000 files. And if they do, I&#8217;m sure [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #339933;">...</span>
  <span style="color: #666666; font-style: italic;">//DONT TOUCH !!! -&amp;gt; THIS DB TRANS STARTS, BECAUSE XYZ MODUL CONSIST OF DB::Commit() clausule</span>
  DB<span style="color: #339933;">::</span><span style="color: #004000;">Trans</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$returnVal</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Hey guys, let&#8217;s start a transaction here and expect that no one will ever change the code in any of the other 2000 files. And if they do, I&#8217;m sure that while they&#8217;ll be editing &#8220;modul&#8221; XYZ, I&#8217;m sure they will know that transaction starts here.</p>
]]></content:encoded>
			<wfw:commentRss>http://uglycode.com/2008/12/transactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hardcoding FTW</title>
		<link>http://uglycode.com/2008/11/hardcoding-ftw/</link>
		<comments>http://uglycode.com/2008/11/hardcoding-ftw/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 18:19:19 +0000</pubDate>
		<dc:creator>analytik</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hardcoding]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://uglycode.com/?p=18</guid>
		<description><![CDATA[
function _getCRServices&#40;$data&#41;
  &#123;
    if &#40;is_array&#40;$data&#41;&#41; &#123;
      //this is ehmmmm, d*ment requirement from client
      $not_cr = array&#40;3006, 2416, 1026, 5604, 3501&#41;;
      ...
    &#125;
  &#125;

Makes one wonder if there was a demented requirement, or [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> _getCRServices<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">//this is ehmmmm, d*ment requirement from client</span>
      <span style="color: #000088;">$not_cr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3006</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2416</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1026</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5604</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3501</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #339933;">...</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Makes one wonder if there was a demented requirement, or just a demented programming technique.</p>
]]></content:encoded>
			<wfw:commentRss>http://uglycode.com/2008/11/hardcoding-ftw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OCD code?</title>
		<link>http://uglycode.com/2008/10/ocd-code/</link>
		<comments>http://uglycode.com/2008/10/ocd-code/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 20:51:09 +0000</pubDate>
		<dc:creator>analytik</dc:creator>
				<category><![CDATA[optimization]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[queries]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://uglycode.com/?p=10</guid>
		<description><![CDATA[
if &#40;!empty&#40;fetchResult&#40;&#41;&#41; and isObject&#40;fetchResult&#40;&#41;&#41; and is_a&#40;fetchResult&#40;&#41;, &#34;objectType&#34;&#41;&#41; &#123;
  $result = fetchResult&#40;&#41;;
  doSomethingElse&#40;&#41;;
&#125;
elseif &#40;isObject&#40;fetchResult&#40;&#41;&#41; &#123;
  $result = fetchResult&#40;&#41;;
&#125;

I think the guy who wrote it was slightly OCD. And he definitely forgot that fetchResult() fetches results&#8230; from the database.
After optimizing aforementioned code and singleton-ifying the fetchResult(), number of queries made in one pageload went [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span>fetchResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> and isObject<span style="color: #009900;">&#40;</span>fetchResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> and <span style="color: #990000;">is_a</span><span style="color: #009900;">&#40;</span>fetchResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;objectType&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> fetchResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  doSomethingElse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>isObject<span style="color: #009900;">&#40;</span>fetchResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> fetchResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I think the guy who wrote it was slightly OCD. And he definitely forgot that fetchResult() fetches results&#8230; from the database.</p>
<p>After optimizing aforementioned code and singleton-ifying the fetchResult(), number of queries made in one pageload went down to 300 from 800. Our code is just <em>awesome</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://uglycode.com/2008/10/ocd-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
