<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Simone 'Wiz' Tellini - Software Development</title>
    <link>http://www.tellini.info/blog/</link>
    <description>To strive, to seek, to find, and not to yield.</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.1 - http://www.s9y.org/</generator>
    <pubDate>Fri, 12 Jun 2009 17:37:02 GMT</pubDate>

    <image>
        <url>http://www.tellini.info/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Simone 'Wiz' Tellini - Software Development - To strive, to seek, to find, and not to yield.</title>
        <link>http://www.tellini.info/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>I do hate MySQL</title>
    <link>http://www.tellini.info/blog/archives/86-I-do-hate-MySQL.html</link>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/86-I-do-hate-MySQL.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=86</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=86</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    I can&#039;t stand it, really.&lt;br /&gt;
&lt;br /&gt;
I&#039;m using it at the moment only because I&#039;m forced to. I can&#039;t help considering it as a toy DB, especially comparing it to PostgreSQL or SQL Server or any other &lt;em&gt;serious&lt;/em&gt; RDBMS.&lt;br /&gt;
&lt;br /&gt;
The last thing that hit my nerve is &lt;a href=&quot;http://bugs.mysql.com/bug.php?id=7831&quot;&gt;this bug&lt;/a&gt;. Come on... can&#039;t it even handle foreign keys in a decent way?&lt;br /&gt;
&lt;br /&gt;
And I&#039;m trying not to think that it allows you to define a table with foreign keys and &lt;a href=&quot;http://bugs.mysql.com/bug.php?id=17943&quot;&gt;silently ignore them&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/rant&amp;gt; 
    </content:encoded>

    <pubDate>Fri, 12 Jun 2009 10:25:43 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/86-guid.html</guid>
    <category>mysql</category>
<category>rant</category>
<category>software development</category>

</item>
<item>
    <title>FeedbackReporter and Mantis integration</title>
    <link>http://www.tellini.info/blog/archives/81-FeedbackReporter-and-Mantis-integration.html</link>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/81-FeedbackReporter-and-Mantis-integration.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=81</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=81</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    I&#039;ve just written a small script to store reports generated by &lt;a href=&quot;http://vafer.org/projects/feedbackreporter/&quot; title=&quot;FeedbackReporter&quot;&gt;FeedbackReporter&lt;/a&gt; on a &lt;a href=&quot;http://www.mantisbt.org/&quot; title=&quot;Mantis Bug Tracker&quot;&gt;Mantis&lt;/a&gt; system.&lt;br /&gt;
&lt;br /&gt;
It should come handy to keep track of your application crashes (crash? uh? My apps never crash! &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;)&lt;br /&gt;
&lt;br /&gt;
You can download it &lt;a href=&quot;http://files.tellini.info/FRToMantis.zip&quot; title=&quot;FeedbackReporter to Mantis&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Simply extract it on your webserver and edit &lt;strong&gt;config.php&lt;/strong&gt; to adjust your settings.&lt;br /&gt;
&lt;br /&gt;
It can work in two ways: if you&#039;re installing it on the same server running mantis, set &lt;strong&gt;MANTIS_LOCAL&lt;/strong&gt; to true and &lt;strong&gt;MANTIS_PATH&lt;/strong&gt; to the root of your mantis installation.&lt;br /&gt;
&lt;br /&gt;
Otherwise, you can even install it on a different server and let it communicate with your mantis via SOAP. In order to do this, set &lt;strong&gt;MANTIS_LOCAL&lt;/strong&gt; to false and edit &lt;strong&gt;MANTIS_URL&lt;/strong&gt;. This setup needs the SOAP extension of PHP5, so make sure it&#039;s available.&lt;br /&gt;
&lt;br /&gt;
Feedback is welcome, of course. 
    </content:encoded>

    <pubDate>Sat, 02 May 2009 14:23:30 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/81-guid.html</guid>
    <category>mac os x</category>
<category>mantis</category>
<category>software development</category>

</item>
<item>
    <title>Connection without a listening socket?</title>
    <link>http://www.tellini.info/blog/archives/78-Connection-without-a-listening-socket.html</link>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/78-Connection-without-a-listening-socket.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=78</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=78</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    I&#039;ve encountered a network problem that left me a bit puzzled.&lt;br /&gt;
&lt;br /&gt;
Usually, when you want to setup a TCP connection between two sockets (let&#039;s called them S1 and S2), you need to perform these steps on the server:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
 &lt;li&gt; create S1&lt;/li&gt;&lt;br /&gt;
 &lt;li&gt; bind S1 to a port (or to a port/address, if you need to)&lt;/li&gt;&lt;br /&gt;
 &lt;li&gt; set S1 to listen for connections&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
on the client:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
 &lt;li&gt; create S2&lt;/li&gt;&lt;br /&gt;
 &lt;li&gt; tell S2 to connect to S1 &lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
and finally, the server receives the connection attempt and accepts it to remove it from the backlog of the listening socket.&lt;br /&gt;
&lt;br /&gt;
Well, apparently there&#039;s another way, which I suspect few know about.&lt;br /&gt;
&lt;br /&gt;
Check out this simple application:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Net&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Net.Sockets&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Threading&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;namespace&lt;/span&gt; SocketTest&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; Program&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;static&lt;/span&gt; IPEndPoint &amp;#160; &amp;#160; &amp;#160; a &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; IPEndPoint&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; IPAddress.&lt;span style=&quot;color: #0000FF;&quot;&gt;Loopback&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;18000&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;static&lt;/span&gt; IPEndPoint &amp;#160; &amp;#160; &amp;#160; b &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; IPEndPoint&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; IPAddress.&lt;span style=&quot;color: #0000FF;&quot;&gt;Loopback&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;18001&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Main&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; args&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Thread&amp;#160; threadA &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Thread&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; ThreadA &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Thread&amp;#160; threadB &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Thread&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; ThreadB &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; threadB.&lt;span style=&quot;color: #0000FF;&quot;&gt;Start&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; threadA.&lt;span style=&quot;color: #0000FF;&quot;&gt;Start&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; ThreadA&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Socket sock &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Socket&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; a.&lt;span style=&quot;color: #0000FF;&quot;&gt;AddressFamily&lt;/span&gt;, SocketType.&lt;span style=&quot;color: #0000FF;&quot;&gt;Stream&lt;/span&gt;, ProtocolType.&lt;span style=&quot;color: #0000FF;&quot;&gt;Tcp&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sock.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bind&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; b &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sock.&lt;span style=&quot;color: #0000FF;&quot;&gt;Connect&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; a &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Console.&lt;span style=&quot;color: #0000FF;&quot;&gt;WriteLine&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Connected from &amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; b &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot; to &amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; a &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Thread.&lt;span style=&quot;color: #0000FF;&quot;&gt;Sleep&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; Timeout.&lt;span style=&quot;color: #0000FF;&quot;&gt;Infinite&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; ThreadB&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Socket sock &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Socket&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; b.&lt;span style=&quot;color: #0000FF;&quot;&gt;AddressFamily&lt;/span&gt;, SocketType.&lt;span style=&quot;color: #0000FF;&quot;&gt;Stream&lt;/span&gt;, ProtocolType.&lt;span style=&quot;color: #0000FF;&quot;&gt;Tcp&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sock.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bind&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; a &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sock.&lt;span style=&quot;color: #0000FF;&quot;&gt;Connect&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; b &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Console.&lt;span style=&quot;color: #0000FF;&quot;&gt;WriteLine&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Connected from &amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; a &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot; to &amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; b &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Thread.&lt;span style=&quot;color: #0000FF;&quot;&gt;Sleep&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; Timeout.&lt;span style=&quot;color: #0000FF;&quot;&gt;Infinite&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see what happens compiling and running it:&lt;br /&gt;
&lt;br /&gt;
&lt;!-- s9ymdb:11 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;552&quot; height=&quot;68&quot; style=&quot;border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://www.tellini.info/blog/uploads/Screenshots/ConnectionWithoutListening.png&quot; alt=&quot;&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Yes, you get a connection between the two sockets. It&#039;s something I was never told about and I would have never expected to see. But it&#039;s correct as per &lt;a href=&quot;http://www.ibiblio.org/pub/docs/rfc/rfc793.txt&quot;&gt;RFC 793&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found out about it when a couple of clients on a test system started connecting between themselves, while they were supposed to connect to 2 different servers on localhost. Both clients were periodically trying to connect to their server, which was down. They were creating a new socket for every attempt, without binding it, thus Windows&#039; TCP/IP stack assigned a sequential port number to them. Eventually, the two processes reached the configuration required for the &quot;Simultaneous Connection Synchronization&quot; as described in the RFC.&lt;br /&gt;
&lt;br /&gt;
Interesting. I guess you live and you learn. 
    </content:encoded>

    <pubDate>Tue, 10 Feb 2009 12:25:00 -0800</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/78-guid.html</guid>
    
</item>
<item>
    <title>Quote of the Day</title>
    <link>http://www.tellini.info/blog/archives/71-Quote-of-the-Day.html</link>
            <category>Quotes</category>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/71-Quote-of-the-Day.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=71</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=71</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    &lt;blockquote&gt;[...] a good programmer cultivates the virtue of laziness. (But not just any laziness: you must be aggressively, proactively lazy!)&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;-- Chris Pine&lt;/em&gt;, dealing with the &lt;a href=&quot;http://blogs.msdn.com/steverowe/archive/2008/05/15/design-principle-don-t-repeat-yourself.aspx&quot;&gt;DRY rule&lt;/a&gt; 
    </content:encoded>

    <pubDate>Mon, 04 Aug 2008 22:53:09 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/71-guid.html</guid>
    <category>laziness</category>
<category>quotes</category>
<category>software development</category>

</item>
<item>
    <title>Quote of the Day</title>
    <link>http://www.tellini.info/blog/archives/68-Quote-of-the-Day.html</link>
            <category>Quotes</category>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/68-Quote-of-the-Day.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=68</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=68</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    &lt;blockquote&gt;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;-- Richard Cook, read on &lt;a href=&quot;http://www.freesoftwaremagazine.com/columns/dont_compare_gnu_linux_windows_or_macos_they_are_not_same_game&quot;&gt;FSM&lt;/a&gt;&lt;/em&gt; 
    </content:encoded>

    <pubDate>Sat, 12 Jul 2008 12:15:14 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/68-guid.html</guid>
    <category>idiots</category>
<category>quotes</category>
<category>software development</category>
<category>universe</category>

</item>
<item>
    <title>Quote of the Day</title>
    <link>http://www.tellini.info/blog/archives/67-Quote-of-the-Day.html</link>
            <category>Quotes</category>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/67-Quote-of-the-Day.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=67</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=67</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    &lt;blockquote&gt;[...] as we all know, premature optimization is the root of all evil.&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;-- from a &lt;a href=&quot;http://lists.apple.com/mailman/listinfo/cocoa-dev/&quot;&gt;cocoa-dev&lt;/a&gt; email&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
amen! 
    </content:encoded>

    <pubDate>Sun, 06 Jul 2008 21:21:04 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/67-guid.html</guid>
    <category>optimization</category>
<category>quotes</category>
<category>software development</category>

</item>
<item>
    <title>Single instance per session application with argument passing</title>
    <link>http://www.tellini.info/blog/archives/61-Single-instance-per-session-application-with-argument-passing.html</link>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/61-Single-instance-per-session-application-with-argument-passing.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=61</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=61</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    Suppose you want to create an application which you want to limit to a single running instance, like some image viewers do for example. Also, you need different users on a Terminal Server not to conflict with each other. Oh, and you&#039;re coding in C#.&lt;br /&gt;
&lt;br /&gt;
A possible solution to the problem is the one described in &lt;a href=&quot;http://www.flawlesscode.com/post/2008/02/Enforcing-single-instance-with-argument-passing.aspx&quot;&gt;this Flawless Code post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
What I didn&#039;t like is, it requires the 3.5 version of the framework, while I preferred to be able to run on machines with only 2.0 installed. So I&#039;ve replaced the NamedPipeClientStream/NamedPipeServerStream with a P/Invoke-based implementation based on &lt;a href=&quot;http://blog.paranoidferret.com/index.php/2007/07/25/interprocess-communication-using-named-pipes-in-csharp/&quot;&gt;this example&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Also, I create a different pipe per user session, since I haven&#039;t found a way to create a &quot;local&quot; pipe. An article at &lt;a href=&quot;http://www.drdobbs.com/windows/184416711&quot;&gt;Dr Dobb&#039;s&lt;/a&gt; suggests that  it&#039;s possible, while &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa365150(VS.85).aspx&quot;&gt;MSDN&lt;/a&gt; doesn&#039;t mention this possibility...&lt;br /&gt;
&lt;br /&gt;
I&#039;ve zipped up my &lt;a href=&quot;http://files.tellini.info/SingleInstanceApp.zip&quot;&gt;test solution&lt;/a&gt; in case someone else has the same needs. 
    </content:encoded>

    <pubDate>Wed, 04 Jun 2008 12:44:00 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/61-guid.html</guid>
    <category>.net</category>
<category>c#</category>
<category>ipc</category>
<category>software development</category>

</item>
<item>
    <title>How much would it cost to rewrite it?</title>
    <link>http://www.tellini.info/blog/archives/60-How-much-would-it-cost-to-rewrite-it.html</link>
            <category>Software</category>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/60-How-much-would-it-cost-to-rewrite-it.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=60</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=60</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    I&#039;ve just added &lt;a href=&quot;http://logminer.tellini.info/&quot;&gt;LogMiner&lt;/a&gt; to &lt;a href=&quot;http://www.ohloh.net/projects/logminer&quot;&gt;Ohloh&lt;/a&gt;, a site that offers an interesting feature: it can analyse a project source code and estimate how much it would cost to hire a development team to recreate the project from scratch.&lt;br /&gt;
&lt;br /&gt;
I think that it&#039;s a simple way to estimate the effort you put over the time in open source projects.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s the resulting figure for LogMiner:&lt;br /&gt;
&lt;div align=&quot;center&quot; style=&quot;border-style: none&quot;&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.ohloh.net/projects/14626/widgets/project_partner_badge&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt; 
    </content:encoded>

    <pubDate>Mon, 02 Jun 2008 17:13:44 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/60-guid.html</guid>
    <category>logminer</category>
<category>software</category>
<category>software development</category>

</item>
<item>
    <title>If at first you don't succeed... try, try again...</title>
    <link>http://www.tellini.info/blog/archives/58-If-at-first-you-dont-succeed...-try,-try-again....html</link>
            <category>Coding fun</category>
    
    <comments>http://www.tellini.info/blog/archives/58-If-at-first-you-dont-succeed...-try,-try-again....html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=58</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=58</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    Here&#039;s another &lt;em&gt;interesting&lt;/em&gt; piece of code I&#039;ve just digged up in a C# application I&#039;m reviewing.&lt;br /&gt;
&lt;br /&gt;
If you can come up with a bright idea about what those try/catch blocks are supposed to do, you&#039;ve got more imagination than me... &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; Foo&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; bar&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// ...snip...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; GetNewBar&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; ret &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;lock&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; bar&lt;span style=&quot;color: #008000;&quot;&gt;++;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; ret &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; bar&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; bar&lt;span style=&quot;color: #008000;&quot;&gt;++;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; ret &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; bar&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; ret&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// ...snip...&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt; 
    </content:encoded>

    <pubDate>Mon, 19 May 2008 16:57:02 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/58-guid.html</guid>
    <category>coding fun</category>
<category>fun</category>
<category>software development</category>

</item>
<item>
    <title>Don't code like this at home, kids</title>
    <link>http://www.tellini.info/blog/archives/57-Dont-code-like-this-at-home,-kids.html</link>
            <category>Coding fun</category>
    
    <comments>http://www.tellini.info/blog/archives/57-Dont-code-like-this-at-home,-kids.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=57</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=57</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    Sometimes when you&#039;re reviewing someone else&#039;s code, you find interesting pieces of &quot;&lt;em&gt;art&lt;/em&gt;&quot;. Like the following loop construct in a C# application:&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; anArray.&lt;span style=&quot;color: #0000FF;&quot;&gt;Length&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;i &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; break&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;... &amp;#160; &amp;#160;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000FF;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;--;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Doh.&lt;br /&gt;
&lt;br /&gt;
You might be tempted to rewrite it as:&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; anArray.&lt;span style=&quot;color: #0000FF;&quot;&gt;Length&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #008000;&quot;&gt;--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;... &amp;#160; &amp;#160;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
but it would be too simple, too boring, wouldn&#039;t it? 
    </content:encoded>

    <pubDate>Wed, 14 May 2008 10:25:13 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/57-guid.html</guid>
    <category>coding fun</category>
<category>fun</category>
<category>software development</category>

</item>
<item>
    <title>Quote of the Day</title>
    <link>http://www.tellini.info/blog/archives/54-Quote-of-the-Day.html</link>
            <category>Fun</category>
            <category>Quotes</category>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/54-Quote-of-the-Day.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=54</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=54</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    &lt;blockquote&gt;I always assumed the designers of the Objective-C language and Cocoa frameworks trust me to know what I&#039;m doing while I find very elegant ways to shoot myself in the foot.&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;-- from a mail sent to &lt;a href=&quot;http://lists.apple.com/mailman/listinfo/cocoa-dev/&quot;&gt;Cocoa-dev&lt;/a&gt;&lt;/em&gt; 
    </content:encoded>

    <pubDate>Fri, 18 Apr 2008 12:07:59 -0700</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/54-guid.html</guid>
    <category>cocoa</category>
<category>fun</category>
<category>objective-c</category>
<category>quotes</category>
<category>software development</category>

</item>
<item>
    <title>PHP templates</title>
    <link>http://www.tellini.info/blog/archives/47-PHP-templates.html</link>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/47-PHP-templates.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=47</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=47</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    When you design a complex application, it&#039;s always useful to separate the presentation layer from the business logic. Usually, when dealing with web apps, this involves handing templates which are &quot;filled&quot; with data by your controller.&lt;br /&gt;
&lt;br /&gt;
The common rationale is that the template should contain as little logic as possible and that it should be easily editable by non-programmers.&lt;br /&gt;
&lt;br /&gt;
There are &lt;a href=&quot;http://www.whenpenguinsattack.com/2006/07/19/php-template-engine-roundup/&quot;&gt;several PHP packages&lt;/a&gt; (Smarty, PHPTal, etc...) that aim at providing a flexible and neat template framework. They usually try to force you not to put code in the template by providing a limited set of directives that can be used, such as placeholders, foreach-style control blocks, conditional blocks... but in the end, every framework I&#039;ve seen also includes a directive that allows you to put arbitrary PHP code inside the template.&lt;br /&gt;
&lt;br /&gt;
Thus I&#039;ve always wondered: what&#039;s the point? Why don&#039;t you just use PHP as a templating engine instead of inventing a new language? &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
So, let me introduce my super-duper template class!&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;/*&lt;br /&gt;&amp;#160;* Copyright ©2007-2008 by Simone Tellini&lt;br /&gt;&amp;#160;* http://tellini.info/&lt;br /&gt;&amp;#160;*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; Template&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$commonVars&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$tpl&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$vars&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; __construct&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$template&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;tpl&lt;/span&gt; &amp;#160;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$template&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;vars&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$commonVars&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// you might set some variables before instantiating your templates when&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// you want to have some data available in all the templates you need to&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// build a complex page&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;a href=&quot;http://www.php.net/static&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;static&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; setCommon&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$key&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$commonVars&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$key&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; set&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$key&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;vars&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$key&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$value&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; execute&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$T&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;vars&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.php.net/ob_start&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;ob_start&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;include&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;tpl&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$html&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/ob_get_contents&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;ob_get_contents&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.php.net/ob_end_clean&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;ob_end_clean&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$html&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Ta-da!&lt;br /&gt;
&lt;br /&gt;
A sample template may look like:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&lt;br /&gt;Hello, &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$T&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;user&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;!&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The &lt;strong&gt;$T&lt;/strong&gt; array is the only variable visible to the template (except for $this, which points to the Template instance and the super-variables $_GET, $_POST, etc...), since it&#039;s the only variable defined in the scope where the template has been include()&#039;d&lt;br /&gt;
&lt;br /&gt;
The controller might look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;require_once&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;classes/template.php&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$tpl&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Template&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;templates/helloWorld.php&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$tpl&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;user&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;World&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;a href=&quot;http://www.php.net/print&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;print&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$tpl&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;execute&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
I&#039;ve been using a class like that for a couple of years now, without any regret. It&#039;s been used in sites whose content and graphics are now constantly edited by their owners: even though they aren&#039;t programmers, they never had any problem whatsoever in editing or creating their own templates. I truly like it beacuse:&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
  &lt;li&gt; it&#039;s simple &lt;/li&gt;&lt;br /&gt;
  &lt;li&gt; it surely isn&#039;t bloated &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; &lt;/li&gt;&lt;br /&gt;
  &lt;li&gt; it&#039;s faster than many (most?) of the other templating engines &lt;/li&gt;&lt;br /&gt;
  &lt;li&gt; it&#039;s as flexible as you need &lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Of course, the fact that you&#039;re using PHP to create your templates shouldn&#039;t tempt you to start placing business logic inside them! 
    </content:encoded>

    <pubDate>Thu, 24 Jan 2008 22:21:31 -0800</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/47-guid.html</guid>
    <category>php</category>
<category>software development</category>

</item>
<item>
    <title>Attributes, reflection and PHP</title>
    <link>http://www.tellini.info/blog/archives/46-Attributes,-reflection-and-PHP.html</link>
            <category>Software Development</category>
            <category>Tips'n'Tricks</category>
    
    <comments>http://www.tellini.info/blog/archives/46-Attributes,-reflection-and-PHP.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=46</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=46</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    After a long exposure to .NET, when I get back to PHP I sometimes find myself missing some cool functionality (and a good IDE too... none of those I&#039;ve tried so far can compete with the comfort of VisualStudio + ReSharper).&lt;br /&gt;
&lt;br /&gt;
Among these missing features, &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/xtwkdas5.aspx&quot; title=&quot;Attributes Overview&quot;&gt;attributes&lt;/a&gt; are what I needed in order to solve a certain problem in an elegant way.&lt;br /&gt;
&lt;br /&gt;
Looking at what the &lt;a href=&quot;http://www.php.net/oop5.reflection&quot;&gt;reflection API&lt;/a&gt; was offering, I came up with a simple way to decorate my properties/methods/classes with attributes: through the documentation comments!&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see an example:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;php geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; A&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;* @attr&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;* @attr2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;*/&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; protected &lt;span style=&quot;color: #000088;&quot;&gt;$foo&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; protected &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; GetPropAttrs&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$property&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$class&lt;/span&gt; &amp;#160; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ReflectionClass&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/get_class&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;get_class&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$prop&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$class&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;getProperty&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$property&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$doc&lt;/span&gt; &amp;#160; &amp;#160; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$prop&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;getDocComment&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$attrs&lt;/span&gt; &amp;#160; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$matches&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.php.net/preg_match_all&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;preg_match_all&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;/@([a-zA-Z_][a-zA-Z_0-9]*)\s/m&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$doc&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$matches&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; PREG_SET_ORDER &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;foreach&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$matches&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$m&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$attrs&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$m&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$attrs&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; test&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000088;&quot;&gt;$attrs&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;GetPropAttrs&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;foo&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.php.net/print_r&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;print_r&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$attrs&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; B&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;extends&lt;/span&gt; A&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009933; font-style: italic;&quot;&gt;/**&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;* @attr3 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;*/&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; protected &lt;span style=&quot;color: #000088;&quot;&gt;$foo&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$obj&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; A&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.php.net/print&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;print&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;Test A:&amp;lt;br&amp;gt;&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$obj&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;test&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$obj&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; B&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.php.net/print&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;print&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;&#039;&amp;lt;p&amp;gt;Test B:&amp;lt;br&amp;gt;&#039;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$obj&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;test&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Running the above script you&#039;ll see the following output, confirming that everything works as desired:&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
Test A:&lt;br /&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
    [0] =&gt; attr&lt;br /&gt;
    [1] =&gt; attr2&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
Test B:&lt;br /&gt;
Array ( [0] =&gt; attr3 ) &lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using the /** */ comments for real documentation, you might want to use another escape character rather than @, to avoid problems.&lt;br /&gt;
&lt;br /&gt;
Happy coding &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; 
    </content:encoded>

    <pubDate>Sun, 13 Jan 2008 12:16:00 -0800</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/46-guid.html</guid>
    <category>php</category>
<category>reflection</category>
<category>software development</category>
<category>tips'n'tricks</category>

</item>
<item>
    <title>Is MySQL bad for (open source) software quality?</title>
    <link>http://www.tellini.info/blog/archives/44-Is-MySQL-bad-for-open-source-software-quality.html</link>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/44-Is-MySQL-bad-for-open-source-software-quality.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=44</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=44</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    I think so.&lt;br /&gt;
&lt;br /&gt;
Why? Because it&#039;s basically a toy DBMS with too many non-standard behaviours.&lt;br /&gt;
&lt;br /&gt;
A lot of open source projects choose &lt;a href=&quot;http://www.mysql.com&quot;&gt;MySQL&lt;/a&gt; mainly because it&#039;s widely available among hosting providers, while better RDBMS like &lt;a href=&quot;http://www.postgresql.org/&quot; title=&quot;PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; are hard to find. The real problem is, a lot of open source developer know very little about SQL and databases: they make things up as they proceed in their project, almost often caring only that &quot;it works&quot; for them&lt;sup&gt;2&lt;/sup&gt;. The result is that they learn wrong habits and write poor DB-related code, a trait common to many projects, sadly.&lt;br /&gt;
&lt;br /&gt;
For instance, the inspiration for this rant comes from &lt;a href=&quot;http://bugs.flyspray.org/task/1338&quot;&gt;this bug report&lt;/a&gt; for &lt;a href=&quot;http://www.flyspray.org/&quot;&gt;Flyspray&lt;/a&gt;, a bug reporting system written in &lt;a href=&quot;http://www.php.net&quot;&gt;PHP&lt;/a&gt;. The report is about a pretty lame error in the SQL query used to fetch the task list, as detailed in the &lt;a href=&quot;http://bugs.flyspray.org/task/1338#comment3854&quot;&gt;9th comment&lt;/a&gt;. PostgreSQL is not &quot;incredibly annoying regarding GROUP BY&quot; as the Flyspray maintainer believes: PostgreSQL simply does the right thing to do in that case, just like every other serious&lt;sup&gt;3&lt;/sup&gt; RDBMS on the market. I was recently hired to port Flyspray to Oracle: needless to say that I had to fix this problem as well as several other queries.&lt;br /&gt;
&lt;br /&gt;
Other examples of DB abuse include &lt;a href=&quot;http://www.mantisbt.org&quot;&gt;Mantis&lt;/a&gt;, another PHP bugtracker. If you had a chance to use it, probably you&#039;ve seen the statistics at the bottom of the page, something like:&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
43 total queries executed.&lt;br /&gt;
30 unique queries executed.&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
I beg your pardon? 43 queries to display a 10 rows table? and why 13 of them have been performed twice? &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
So, please... kids don&#039;t use MySQL at home. &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
I&#039;m not saying that you should never use MySQL (there would be plenty of reasons to avoid it anyway &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;) or that projects based on it suck (I like mantis, for one). It&#039;s simply a bad choice for a beginner wishing to learn how to do things properly, IMHO.&lt;br /&gt;
&lt;br /&gt;
&lt;small&gt;&lt;br /&gt;
&lt;sup&gt;1&lt;/sup&gt; my favorite open source RDBMS. If it seems like I&#039;m doing some advocacy, well... maybe I am &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;sup&gt;2&lt;/sup&gt; I&#039;ve got nothing against this attitude when it comes to free software: if you want things to get done as &lt;em&gt;you&lt;/em&gt; wish, you should be prepared to do them yourself or pay for them, instead of &lt;em&gt;expecting&lt;/em&gt; other people to do the dirty work for free &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;sup&gt;3&lt;/sup&gt; yes, that excludes MySQL &lt;img src=&quot;http://www.tellini.info/blog/templates/default/img/emoticons/tongue.png&quot; alt=&quot;:-P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;/small&gt; 
    </content:encoded>

    <pubDate>Fri, 04 Jan 2008 15:54:00 -0800</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/44-guid.html</guid>
    <category>database</category>
<category>mysql</category>
<category>oracle</category>
<category>postgresql</category>
<category>rant</category>
<category>software development</category>

</item>
<item>
    <title>The meaning of const in C</title>
    <link>http://www.tellini.info/blog/archives/40-The-meaning-of-const-in-C.html</link>
            <category>Software Development</category>
    
    <comments>http://www.tellini.info/blog/archives/40-The-meaning-of-const-in-C.html#comments</comments>
    <wfw:comment>http://www.tellini.info/blog/wfwcomment.php?cid=40</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.tellini.info/blog/rss.php?version=2.0&amp;type=comments&amp;cid=40</wfw:commentRss>
    

    <author>nospam@example.com (Simone)</author>
    <content:encoded>
    John Engelhart posted to &lt;a href=&quot;http://lists.apple.com/mailman/listinfo/cocoa-dev&quot; &gt;Cocoa-dev&lt;/a&gt; a &lt;a href=&quot;http://lists.apple.com/archives/cocoa-dev/2007/Dec/msg00373.html&quot;  title=&quot;about the const keyword&quot;&gt;detailed explanation&lt;/a&gt; of what exactly &lt;strong&gt;const&lt;/strong&gt; means in C programs.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that he&#039;s talking about &lt;em&gt;C&lt;/em&gt;, not C++ (where &lt;strong&gt;const&lt;/strong&gt; has a stronger meaning and even a slightly different semantic when used to declare constant values).&lt;br /&gt;
&lt;br /&gt;
Still, it&#039;s worth reading. 
    </content:encoded>

    <pubDate>Sat, 08 Dec 2007 14:06:27 -0800</pubDate>
    <guid isPermaLink="false">http://www.tellini.info/blog/archives/40-guid.html</guid>
    <category>c</category>
<category>software development</category>

</item>

</channel>
</rss>