<?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>wide thoughts &#187; Thoughts</title>
	<atom:link href="http://kozak.si/widethoughts/category/thoughts/feed/" rel="self" type="application/rss+xml" />
	<link>http://kozak.si/widethoughts</link>
	<description>a blog of one of those ... software developer creatures</description>
	<lastBuildDate>Sat, 31 Jul 2010 12:30:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>deleting window properties</title>
		<link>http://kozak.si/widethoughts/2009/11/08/deleting-window-and-document-properties/</link>
		<comments>http://kozak.si/widethoughts/2009/11/08/deleting-window-and-document-properties/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 14:58:48 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=533</guid>
		<description><![CDATA[Seems like there&#8217;s really something special about window and document objects in IE. Just as with iterating over window properties, there seems to be some weirdness about deleting the properties in window DOM object.

In IE, deleting a custom window property doesn&#8217;t work. The following code is fully ECMAScript compliant.



window.p = &#39;VAL&#39;;


delete window.p;



But it throws an [...]]]></description>
			<content:encoded><![CDATA[<p>Seems like there&#8217;s really something special about window and document objects in IE. Just as with <a href="http://kozak.si/widethoughts/2009/09/06/iterating-over-properties-in-window-object/">iterating over window properties</a>, there seems to be some weirdness about deleting the properties in <em>window</em> DOM object.<br />
<span id="more-533"></span><br />
In IE, deleting a custom window property doesn&#8217;t work. The following code is fully ECMAScript compliant.</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1">window.<span class="me1">p</span> = <span class="st0">&#39;VAL&#39;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">delete</span> window.<span class="me1">p</span>;</div>
</li>
</ol>
</div>
<p>But it throws an exception in IE: Object doesn&#8217;t support this action. The same action works on custom objects:</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">var</span> o = <span class="br0">&#123;</span><span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1">o.<span class="me1">p</span> = <span class="st0">&#39;VAL&#39;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">delete</span> o.<span class="me1">p</span>;</div>
</li>
</ol>
</div>
<p>Just like with iterating over properties, it seems as if IE treats <em>window</em> like a special object, and it&#8217;s custom properties as something out of reach for certain actions. So I&#8217;ve come up with a solution to delete properties that works on all tested browsers:</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">try</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">delete</span> obj.<span class="me1">prop</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">catch</span> <span class="br0">&#40;</span>e<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; obj.<span class="me1">prop</span> = undefined;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>You can test this <a href="http://kozak.si/widethoughts/wp-content/uploads/2009/11/prop_del.html">here</a>. This issue is present even in IE8, which is supposed to be much better with standards, but this example clearly shows that some very basic behavior is still missing from their Javascript engine.</p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/11/08/deleting-window-and-document-properties/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Pushing PDO</title>
		<link>http://kozak.si/widethoughts/2009/10/25/pushing-pdo/</link>
		<comments>http://kozak.si/widethoughts/2009/10/25/pushing-pdo/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 19:59:39 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[PDO]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=541</guid>
		<description><![CDATA[I&#8217;m really glad to see Lukas planning to push PDO a step higher. I think it&#8217;s already a decent extension, and has a bright future &#8212; since I first used the extension I&#8217;ve never ever used anything else for any database. It&#8217;s object-oriented, has a lean interface, it&#8217;s fast, and supports a major feature: prepared [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really glad to see <a href="http://pooteeweet.org/blog/1565/p/1">Lukas planning to push PDO a step higher</a>. I think it&#8217;s already a decent extension, and has a bright future &#8212; since I first used the extension I&#8217;ve never ever used anything else for any database. It&#8217;s object-oriented, has a lean interface, it&#8217;s fast, and supports a major feature: prepared statements. I&#8217;ve completely forgotten about having to escape, because I always insert/update through these. Seeing mysql_real_escape_string() anywhere in code makes me sad, and seeing $db = mysql_connect() and then passing the resource around makes me sick <img src='http://kozak.si/widethoughts/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Yes, you can use a class to wrap this up, but why would you? PDO is just that and more.</p>
<p>The only thing I miss is some sort of prepared statement inspection. You prepare it, and you pass the parameters, but you can&#8217;t find out what the query actually looks like. This would come in handy for logging, but it may be impossible to implement in the extension, because as I understand prepared statements are assembled by the database itself, unless they&#8217;re emulated by the extension.</p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/10/25/pushing-pdo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LiveNetLive privacy fail *updated*</title>
		<link>http://kozak.si/widethoughts/2009/10/24/livenetlive-privacy-fail/</link>
		<comments>http://kozak.si/widethoughts/2009/10/24/livenetlive-privacy-fail/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 13:18:27 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[LiveNetLive]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=538</guid>
		<description><![CDATA[I&#8217;ve encountered LiveNetLive a few times, it&#8217;s a service that runs on top of your website and creates a live community chat. Never had any problems with it, until yesterday, when I tried posting a comment on some blog.
Seems like LNL steals focus upon loading, which may happen a few seconds after you&#8217;ve already started [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve encountered LiveNetLive a few times, it&#8217;s a service that runs on top of your website and creates a live community chat. Never had any problems with it, until yesterday, when I tried posting a comment on some blog.</p>
<p>Seems like LNL steals focus upon loading, which may happen <em>a few seconds after</em> you&#8217;ve already started writing a form. Needless to say that this is annoying at least.</p>
<p>But today, I&#8217;ve seen the problem in all of its glory. I&#8217;ve tried logging in to <a href="http://videolectures.net/">VideoLectures.net</a>, I focused the username input, entered my username, tabbed to password input, entered password, pressed Enter, and only then realised that it stole the focus just before I typed the first letter of the password. My full password then went public to at least 8 people that were reportedly visiting the same page. What good is strong password hashing, XSS and session protection and whatnot, when you have a feature like this?</p>
<p>Needless to say I&#8217;ve changed my password immediately.</p>
<p><strong>Update</strong>: I&#8217;ve contacted them and they replied promptly that this problematic auto-focus will be fixed soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/10/24/livenetlive-privacy-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php&#124;architect&#8217;s rundown of frameworks fail</title>
		<link>http://kozak.si/widethoughts/2009/07/10/phparchitects-rundown-of-frameworks-fail/</link>
		<comments>http://kozak.si/widethoughts/2009/07/10/phparchitects-rundown-of-frameworks-fail/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 20:56:39 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php|architect]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=443</guid>
		<description><![CDATA[For some reason php&#124;architect&#8217;s June issue failed to list Symfony among 6 frameworks that are supposedly worth mentioning. I&#8217;m not going to speculate on why, but I will say that it&#8217;s wrong from at least one perspective.
If a serious magazine tries to present itself as a valuable source of PHP information, and half of the [...]]]></description>
			<content:encoded><![CDATA[<p>For some reason <a href="http://www.phparch.com/magazine/index/99">php|architect&#8217;s June issue</a> failed to list Symfony among 6 frameworks that are supposedly worth mentioning. I&#8217;m not going to speculate on <em>why</em>, but I <em>will</em> say that it&#8217;s wrong from at least one perspective.</p>
<p>If a serious magazine tries to present itself as a valuable source of PHP information, and half of the issue is dedicated to frameworks, <em>and</em> they put a big caption saying &#8220;PHP HAS BEEN FRAMED &#8211; A rundown of popular frameworks&#8221; on the front cover, but then at least two of the frameworks listed are far from maturity (and userbase, and documentation) of the big players, and you fail to list at least one of the most popular frameworks, then it&#8217;s a fail. Whether it be because they couldn&#8217;t find anybody that would write an article, or they didn&#8217;t try hard enough to find anybody, or they just didn&#8217;t think about it, it&#8217;s still a fail. They <em>should&#8217;ve</em>. And the same could be said for a few other PHP frameworks.</p>
<p>I wonder what were the criteria for the framework selection. Popularity couldn&#8217;t be the only one, because that would mean at least three frameworks replaced by others.</p>
<p>Even though, it&#8217;s an interesting issue, framework articles included.</p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/07/10/phparchitects-rundown-of-frameworks-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>serializing objects with different class definitions</title>
		<link>http://kozak.si/widethoughts/2009/06/25/serializing-objects-with-different-class-definition/</link>
		<comments>http://kozak.si/widethoughts/2009/06/25/serializing-objects-with-different-class-definition/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 13:42:44 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[persistent]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[serialization]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=409</guid>
		<description><![CDATA[When it comes to (un)serializing objects in PHP, some things may surprise you. In this post I show what I&#8217;ve found out last week, when I was testing serialization with different class definitions. This is generally a bad practice, and shows one of the biggest drawbacks of using serialization for persistent object storage: the serialized [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to (un)serializing objects in PHP, some things may surprise you. In this post I show what I&#8217;ve found out last week, when I was testing serialization with different class definitions. This is generally a bad practice, and shows one of the biggest drawbacks of using serialization for persistent object storage: the serialized data holds a frozen version of an object. As project evolves, and classes change, the serialized information doesn&#8217;t change with them. When objects are unserialized with the new class definition, it can result in unexpected behavior. You should take care when using serialization for persistent or temporary storage (ie caching objects in memcache), because every change in the class definition may affect the unserialized objects, causing numerous bugs and crashes.<br />
<span id="more-409"></span><br />
Every example is following the same procedure; file <em>write.php</em> declares a <em>class X</em>, creates an instance of it, and then writes it to a file serialized with obj_write(). The second file, <em>read.php</em>, declares a <em>different class X</em>, reads the file and unserializes the object with obj_read(), which results in creating an instance of the object. Then it executes some code, such as print_r of the object, or echoes some properties.</p>
<p>Helper functions:</p>
<pre code="PHP">
function write_obj($obj)
{
  file_put_contents('obj.data', serialize($obj));
}

function read_obj()
{
  return unserialize(file_get_contents('obj.data'));
}
</pre>
<p><strong>Example 1</strong><br />
Serializing an object with a public property.</p>
<pre code="PHP">
class X
{
  public $a = 'A';
}
obj_write(new X());
</pre>
<p>read.php declares a blank class.</p>
<pre code="PHP">
class X
{
}
$x = obj_read();
print_r($x);
echo $x->a
</pre>
<p>As you might expect, the public property is restored correctly:</p>
<pre>
X Object
(
    [a] => A
)
A
</pre>
<p><strong>Example 2</strong><br />
Adding some protected properties.</p>
<pre code="PHP">
class X
{
  public $a = 'A';
  protected $b = 'B';
  protected $c = 'C';
}
obj_write(new X());
</pre>
<p>read.php declares only one protected variable $c.</p>
<pre code="PHP">
class X
{
  protected $c;
}
$x = obj_read();
print_r($x);
echo $x->a;
echo $x->b;
echo $x->c;
</pre>
<p>An this is the result:</p>
<pre>
X Object
(
    [c:protected] => C
    [a] => A
    [b:protected] => B
)
A
Notice: Undefined property: X::$b in /home/gasper/phpser/test1-read.php on line 12
Fatal error: Cannot access protected property X::$c in /home/gasper/phpser/test1-read.php on line 13
</pre>
<p>As you see, print_r correctly prints out the object. Properties $b and $c are both protected. What differs is that when printing out $x->b, PHP reports that $b is undefined property, and it correctly throws a Fatal when accessing $c. The question is, why doesn&#8217;t the fatal error already occur when accessing $b? As you can see from print_r output, property $b is present in the $x, and it&#8217;s correctly marked as protected, just as is $c. The only difference here is that $b isn&#8217;t declared in the class definition, so I guess PHP checks the class definition when accessing properties, rather than actual object information.</p>
<p><strong>Example 3</strong><br />
Now let&#8217;s twist up things some more by modifying X definition in read.php:</p>
<pre code="PHP">
class X
{
  public $c;
  function getB()
  {
    return $this->b;
  }
  function getC()
  {
    return $this->c;
  }
}
print_r($x);
echo "a: " . $x->a;
echo "b: " . $x->b;
echo "c: " . $x->c;
echo "getB: " . $x->getB();
echo "getC: " . $x->getC();
</pre>
<p>As you can see, I&#8217;ve changed $c visibility to public, and I&#8217;ve written two getters. The former is a test whether I can shift visibility of $c upon unserializing, while the second will hopefully allow me to read the variables $b and $c, which are protected in the original definition, and not declared in this one.</p>
<p>Here&#8217;s the output:</p>
<pre>
X Object
(
    [c] =>
    [a] => A
    [b:protected] => B
    [c:protected] => C
)
a: A
Notice: Undefined property: X::$b in /home/gasper/phpser/test1-read.php on line 20
b: c:
Notice: Undefined property: X::$b in /home/gasper/phpser/test1-read.php on line 9
getB:
getC:
</pre>
<p>The first strange thing is that there are two $c properties declared; one protected and one public. While this might be expected (the serialized information specifically tells PHP to unserialize a <em>protected variable $c</em>), it&#8217;s still strange that I now have <em>two</em> variables named $c. I don&#8217;t think this is possible to achieve without serialization. If you subclass a class and shift visibility of a variable from private/protected to protected/public, you still only have one single variable, so this behavior may come as unexpected. Still, the $x->c and getC() both return an empty value, because no value for <em>public $c</em> was present in the serialized object.</p>
<p>The other thing is that I still can&#8217;t access $b, even through a getter. The property is obviously present in the object (as print_r shows), but even when accessing it through a getter, which <em>has</em> access to instance&#8217;s protected variables, PHP reports that it&#8217;s undefined. I can&#8217;t think of a reasonable explanation for that, but this again shows that care should be taken when serializing objects.</p>
<p><strong>Conclusion</strong><br />
As stated before, serializing and unserializing objects with different versions of classes can be a cause for a lot of trouble. If your classes rarely change, or if you have some means of invalidating the serialized objects (ie flushing the cache, or rewriting the rows in the database), then you&#8217;re probably fine, although you should always be aware of possible consequences. Likewise, if you cache object with public properties only, these seem to work fine, whether they&#8217;re declared or not.</p>
<p>But if you have classes that change often or rely heavily on persistent storage of serialized objects, you should use another way of doing it. One way I can think of is reading the written object with the old version of the class, and passing them to another script/service, which writes them in the new format. This is possible to achieve, but is quite volatile. Other means include using XML to store persistent object data, perhaps even JSON. In these cases, you don&#8217;t store the object itself, just as with serialization, but a subset of its properties that are essential to restoring it correctly. Upon recreating the object, these properties are read one by one into a blank object of a proper class version.</p>
<p>So, that&#8217;s it. Take care with serialization! <img src='http://kozak.si/widethoughts/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/06/25/serializing-objects-with-different-class-definition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>the steep learning curve misunderstanding</title>
		<link>http://kozak.si/widethoughts/2009/06/15/the-steep-learning-curve-misunderstanding/</link>
		<comments>http://kozak.si/widethoughts/2009/06/15/the-steep-learning-curve-misunderstanding/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 21:34:16 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[learning curve]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[thinking]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=360</guid>
		<description><![CDATA[I keep bumping into articles or presentations where &#8220;steep learning curve&#8221; is improperly used, so I&#8217;ve decided to clear up the confusion. People often think that steep learning curve means something that requires a great deal of effort to learn. Well, it doesn&#8217;t.
Given the most common agreement about graphs of functions, we put effort (time, [...]]]></description>
			<content:encoded><![CDATA[<p>I keep bumping into articles or presentations where &#8220;steep learning curve&#8221; is improperly used, so I&#8217;ve decided to clear up the confusion. People often think that <em>steep learning curve</em> means something that requires a great deal of effort to learn. Well, it doesn&#8217;t.</p>
<p>Given the most common agreement about graphs of functions, we put <em>effort (time, number of trials)</em> on <em>x-axis</em>, and <em>knowledge (skill)</em> on <em>y-axis</em>. Knowledge is a function of effort; this means that f(x) will tell us the amount of knowledge a person has, given the amount of effort the person has put into something.</p>
<p>Let&#8217;s take a look at a shallow learning curve.<br />
<div id="attachment_362" class="wp-caption alignnone" style="width: 388px"><img src="http://kozak.si/widethoughts/wp-content/uploads/2009/06/shallow-learning-curve.png" alt="Gradual (shallow) learning curve" title="shallow-learning-curve" width="378" height="311" class="size-full wp-image-362" /><p class="wp-caption-text">Gradual (shallow) learning curve</p></div><br />
You can see that knowledge rises rather slowly as effort is put in learning. This means that something is <em>hard</em> to learn.</p>
<p>Now let&#8217;s take a look at a steep learning curve.<br />
<div id="attachment_376" class="wp-caption alignnone" style="width: 392px"><img src="http://kozak.si/widethoughts/wp-content/uploads/2009/06/steep-learning-curve.png" alt="Steep learning curve" title="steep-learning-curve" width="382" height="316" class="size-full wp-image-376" /><p class="wp-caption-text">Steep learning curve</p></div><br />
It&#8217;s obvious that knowledge is gained very fast. Even with a small amount of effort, skill gets high quite fast. This means that something is <em>easy</em> to learn.</p>
<p>So, remember that <strong>steep learning curve means easy to learn</strong>, and <strong>gradual learning curve means hard to learn</strong>, and stop misusing the term. <img src='http://kozak.si/widethoughts/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/06/15/the-steep-learning-curve-misunderstanding/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>the dark side of IE6Update</title>
		<link>http://kozak.si/widethoughts/2009/04/21/the-dark-side-of-ie6update/</link>
		<comments>http://kozak.si/widethoughts/2009/04/21/the-dark-side-of-ie6update/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 23:14:17 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=276</guid>
		<description><![CDATA[Most of you probably know about IE6 Update (implementation of which is, in fact, a fork of Activebar2), a movement that is supposed to help us developers force users to move away of the browser that is long past due. Well, while this project has a good intention, things shouldn&#8217;t be done that way.
Let&#8217;s categorize [...]]]></description>
			<content:encoded><![CDATA[<p>Most of you probably know about <a href="http://ie6update.com/">IE6 Update</a> (implementation of which is, in fact, a fork of <a href="http://westhoffswelt.de/blog/ie6update.html">Activebar2</a>), a movement that is supposed to help us developers force users to move away of <a href="http://en.wikipedia.org/wiki/IE6">the browser that is long past due</a>. Well, while this project has a good intention, things shouldn&#8217;t be done that way.</p>
<p>Let&#8217;s categorize people in three groups. The first group are the tech-savvy users that know their way around their computers. The second group are people that know how to use a computer and the internet, but still take advice from the first group on matters like what program for recording DVDs is the best, what graphics card to buy etc. The third group are the ones that use computers, but don&#8217;t know much. This is the group that installs the most viruses on their computers. If I had to estimate the number of all people that belong to this group, I&#8217;d say about 50%, and I&#8217;m probably being generous. These are also the folks that we, users from group 1 and 2, are always yelling to: <em>don&#8217;t install software from the web</em>! Be careful what you click! You can get your computer infected if you install things from websites! If the website you&#8217;re visiting offers you to buy/install something suspicious, close it!</p>
<p>Which of these still use IE6? The third group, obviously, unless somebody from the first or second group installed Firefox on their computer. And who else? The people that work in companies that have more or less strict software-upgrading policies. The upgrades in these companies are performed by system administrators (or their slaves), that in most cases know what they&#8217;re doing.</p>
<p>Now let&#8217;s throw these people on the web and add this IE6 information bar on the websites they visit. The first and second group won&#8217;t see them, because they&#8217;re already using a better browser. The only people that will see it are the ones that <em>don&#8217;t know what the hell the message is saying</em> and the ones that <em>can&#8217;t upgrade their browser by themselves</em>.</p>
<p>If the group 3 does what we&#8217;ve been telling them for years, they&#8217;re gonna get scared, leave the site, and surely won&#8217;t install anything. So, not only the IE6Update didn&#8217;t reach its most-targeted users, it actually did worse: it scared the users off of a site that&#8217;s most likely a perfectly legitimate company site, a blog, or whatnot. Keep in mind that users from group 3 don&#8217;t visit slashdot.org, and the information bar is most likely out of the context of the website they&#8217;re visiting.</p>
<p>And what will the people that can&#8217;t upgrade their own browsers do? Not much, because they can&#8217;t. Most of them won&#8217;t even suggest it to their system administrators, because they don&#8217;t get to talk to them, and even if they could, they wouldn&#8217;t, because system administrators bite. So, another target group missed. Is there anybody left? No. Well, yes, the system admins themselves. Well, this is actually the group that the project <em>should</em> be targeting, but not by making random websites show the message.</p>
<p>To recap this point; the majority of people that will see this notice, will either ignore it, be confused by it, or even be scared off of a website, but they won&#8217;t upgrade their browser.</p>
<p>The other thing that&#8217;s wrong with this approach is that it&#8217;s exploiting (yes, exploiting) the information bar UI. It&#8217;s not meant to relay custom messages to users, it&#8217;s purpose is to let users know something from the specific tool they&#8217;re using &#8212; the browser. It should <em>only</em> be used by the browser. By using the information bar to show custom messages, you cross the line between good and bad practices, and are no better than spammers and attackers, which try to disguise their messages to gain users&#8217; attention. Like a chatbox coming from the lower right corner, which is supposed to make you think you&#8217;re attractive, because a nice girl wants to talk to you. Or the Windows95 dialogue box that tells you you&#8217;ve won a car (probably the seventh car this year).</p>
<p>The Browser Information Bar is so useful <em>only</em> because through it the browser relays self-related important messages to the user. It has a distinctive UI, and lets users immediately know that their browser has something relevant to say. To push this thought further, it sends two messages to the user; the first message is that there is a state of the environment (the browser itself) that the user should be aware of &#8212; this is relayed immediately by the bar&#8217;s UI. The second message is the message itself. And while &#8220;having IE6&#8243; could be considered to be a &#8220;defective system state&#8221;, this just isn&#8217;t a browser-created message, and is not legitimate. Where would we end if we start using this bar for everything? For notifying people they have private messages, for news, for advertisements? Well, it wouldn&#8217;t be the end of the world, but the browser&#8217;s messages would get lost among these less important ones.</p>
<p>So, even though I strongly agree that IE6 should be burned, and its ashes should be eaten by zombies, which should then also be burned, I strongly disagree with this project. It&#8217;s for a <em>very</em> good cause, but that&#8217;s a wrong way to achieve it.</p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/04/21/the-dark-side-of-ie6update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linux isn&#8217;t safe enough?</title>
		<link>http://kozak.si/widethoughts/2009/03/28/linux-isnt-safe-enough/</link>
		<comments>http://kozak.si/widethoughts/2009/03/28/linux-isnt-safe-enough/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 12:45:23 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[open-source]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=263</guid>
		<description><![CDATA[Slovenian government decided that Linux and open-source aren&#8217;t appropriate for government usage. The reasons being (a recap from the source):

Using open-source browser instead of horrible MSIE is inappropriate because &#8220;MSIE is free anyway, and using other browsers can cause problems with existing applications&#8221;. The facts that MSIE is the least secure A-grade browser on the [...]]]></description>
			<content:encoded><![CDATA[<p>Slovenian government decided that Linux and open-source aren&#8217;t appropriate for government usage. The reasons being (a recap from the source):</p>
<ol>
<li>Using open-source browser instead of horrible MSIE is inappropriate because &#8220;MSIE is free anyway, and using other browsers can cause problems with existing applications&#8221;. The facts that MSIE is the least secure A-grade browser on the market, and that in Slovenia <a href="http://www.spreadfirefox.com/node/3275">Firefox has the biggest share</a> apparently aren&#8217;t important.</li>
<li>OpenOffice is a viable option (wow!)</li>
<li>&#8220;Linux isn&#8217;t appropriate for workstations because it&#8217;s code is <strong>too open</strong> and it can become too vulnerable in case of mass usage.&#8221; I&#8217;m speechless.</li>
<li>Linux is already used on most servers. Impressive.</li>
<li>&#8220;Security is an issue with OSS, because the source code is available to general public.&#8221; Just as for #3, I remain speechless.</li>
</ol>
<p>Source: <a href="http://slo-tech.com/forum/t351913/0">slo-tech.com</a> (in Slovene)</p>
<p>This is what you get if uninformed people make decisions. It&#8217;s utter non-sense with no solid arguments. Some of the points can in all fairness be called STUPID.</p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/03/28/linux-isnt-safe-enough/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Avoid micro-optimizations</title>
		<link>http://kozak.si/widethoughts/2009/03/10/avoid-micro-optimizations/</link>
		<comments>http://kozak.si/widethoughts/2009/03/10/avoid-micro-optimizations/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 22:25:27 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=241</guid>
		<description><![CDATA[I&#8217;ve read this post about micro-optimization today, and I think many of the listed hints are wrong. Not wrong in way of being false, but in a way that you shouldn&#8217;t use them. Sebastian already wrote something about it, but more can be said.
The difference between static and object method call isn&#8217;t about speed at [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve read <a href="http://www.alexatnet.com/node/196">this post</a> about micro-optimization today, and I think many of the listed hints are wrong. Not wrong in way of being false, but in a way that you shouldn&#8217;t use them. Sebastian already <a href="http://sebastian-bergmann.de/archives/854-Do-Not-Micro-Optimize.html">wrote something about it</a>, but more can be said.</p>
<p>The difference between static and object method call isn&#8217;t about speed at all, it&#8217;s about what you&#8217;re dealing with and what you&#8217;re trying to do. If you have an object, you call an object method. If you have a class with a static method, you call the static method. You shouldn&#8217;t choose between the two just for the sake of speed. You shouldn&#8217;t even have the option of choosing. They&#8217;re not interchangeable. And, in most cases you should be using objects, not classes, for testability&#8217;s sake.</p>
<p>A similar case can be made for &#8220;accessing a global variable is faster then an object property&#8221;. If I start developing with this hint in mind, and I start putting object properties in the global scope, what I am going to get? A mess, that&#8217;s what. You should never think about putting an object property in the global scope, for <em>any</em> reason, optimization included.</p>
<p>Another example would be &#8220;an array is a faster alternative to a class with several fields&#8221;. (Should be object, not class.) Again, this makes little sense. An array is a hash-like storage of data, an object is a black box that receives and sends messages, it&#8217;s encapsulated data with behavior attached. These two are two different things, and if I change the code to use arrays instead of objects, the change ripples throughout the rest of the code. Again, this leads to messy code. Not to mention that in the spirit of OOP you <em>should</em> be aiming to use objects, not arrays. Sure, there are cases where this hint would be suitable, but optimization like this should be the last thing you think about.</p>
<p>There are more hints like this, but I&#8217;m not going to list them all, because I&#8217;ve made my point: most of the hints are invalid, because they compare non-interchangeable things. If I push it a little, it&#8217;s almost like saying: not using echo is faster than using it. Yes, it&#8217;s completely true, but these two options <em>don&#8217;t do the same thing</em>.</p>
<p>I can&#8217;t help myself, so I&#8217;ll say a little something about the famous PHP quotes optimization: single quotes are faster than double quotes. First, these two aren&#8217;t the same, so changing one to another ripples out. Second, with quotes it&#8217;s only about readability and taste. Third, the speed gain is literally negligible. This is another hint you should forget as soon as possible. A second spent on quotes optimization is a second lost. I just lost a few minutes writing this, but some readers will hopefully gain them by not bothering about optimizing quotes.</p>
<p>A lot can be said about optimization, but most of these hints sure aren&#8217;t worth remembering. Even more; forget them as soon as possible. If you have a speed problem, find out where it is, and fix it. In the vast majority of the time it&#8217;s IO-related resources: the database and files, maybe network shares, or whatnot. I&#8217;ve <em>never</em> seen a real-life problem where <em>for</em> statement was causing problems and <em>foreach</em> solved them. This just doesn&#8217;t happen, except maybe if you&#8217;re computing Pi in php-cli.</p>
<p>The path to optimization should be:</p>
<ol>
<li>Write working code, no matter how slow it is. It&#8217;s a million times better than fast code with bugs.</li>
<li>If and only if you undoubtedly have performance issues, profile your code, locate and measure slow code.</li>
<li>Optimize the slowest thing. <em>Only</em> the slowest thing.</li>
<li>Loop.</li>
</ol>
<p>Also keep in your mind that by optimizing your code, you reduce readability, and consequently maintainability. This means that you&#8217;ll lose more time the next time you come back to update or fix the code.</p>
<p>There are also some good points that Alex makes, so I&#8217;ll repeat them here, because these <em>are</em> worth remembering:</p>
<ul>
<li>use prepared database statements,</li>
<li>avoid @ (error control operator),</li>
<li>avoid notices and warnings in your scripts.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/03/10/avoid-micro-optimizations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>array() == false</title>
		<link>http://kozak.si/widethoughts/2009/03/07/array-false/</link>
		<comments>http://kozak.si/widethoughts/2009/03/07/array-false/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 11:26:13 +0000</pubDate>
		<dc:creator>Gašper</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://kozak.si/widethoughts/?p=234</guid>
		<description><![CDATA[Yesterday I&#8217;ve noticed that too many queries are sent to the database server, even though the result should be cached in memcache. After digging into the source and testing, I&#8217;ve discovered something like this:



$results = $memcache-&#62;get&#40;&#39;key&#39;&#41;;


if &#40;!$results&#41;


&#123;


&#160; $results = $this-&#62;fetchFromDb&#40;&#41;;


&#160; $memcache-&#62;set&#40;&#39;key&#39;, $results&#41;;


&#125;


return $results;



The fetchFromDb() method returned an empty array, which was stored in memcache. But, [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I&#8217;ve noticed that too many queries are sent to the database server, even though the result should be cached in memcache. After digging into the source and testing, I&#8217;ve discovered something like this:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="re1">$results</span> <span class="sy0">=</span> <span class="re1">$memcache</span><span class="sy0">-&gt;</span><span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&#39;key&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="re1">$results</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$results</span> <span class="sy0">=</span> <span class="re1">$this</span><span class="sy0">-&gt;</span><span class="me1">fetchFromDb</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re1">$memcache</span><span class="sy0">-&gt;</span><span class="me1">set</span><span class="br0">&#40;</span><span class="st0">&#39;key&#39;</span><span class="sy0">,</span> <span class="re1">$results</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">return</span> <span class="re1">$results</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>The fetchFromDb() method returned an empty array, which was stored in memcache. But, as it turns out, the bug was in checking of $results. An empty array evaluates to false when checking for true/false. I knew that already, but I missed this one.</p>
<p>So, the script issued a query, even though it already had a result. Luckily, this only happened with empty result sets, so the query was fast, and didn&#8217;t overload the server.</p>
<p>The correct code would be:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="re1">$results</span> <span class="sy0">===</span> <span class="kw2">false</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">&#8230;</span></div>
</li>
</ol>
</div>
<p>I&#8217;ve lost quite some time over this, so I&#8217;m posting this as a reminder: if possible, use strict checking.</p>
]]></content:encoded>
			<wfw:commentRss>http://kozak.si/widethoughts/2009/03/07/array-false/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
