<?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>ihumanable &#187; php</title>
	<atom:link href="http://ihumanable.com/blog/category/code/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://ihumanable.com/blog</link>
	<description>usable in any place a human can be used</description>
	<lastBuildDate>Wed, 11 May 2011 15:10:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Auto-timestamps in Flourish</title>
		<link>http://ihumanable.com/blog/2010/10/29/auto-timestamps-in-flourish/</link>
		<comments>http://ihumanable.com/blog/2010/10/29/auto-timestamps-in-flourish/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 18:04:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[flourish]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=879</guid>
		<description><![CDATA[This will be a short post, I just wanted to share a protip for anyone using Flourish and in particular using the fActiveRecord ORM. fActiveRecord is pretty awesome, with it and fRecordSet I find myself very rarely having to drop down to raw SQL, although for some reports it can&#8217;t be avoided and then fORMDatabase::retrieve()->query() [...]]]></description>
			<content:encoded><![CDATA[<p>This will be a short post, I just wanted to share a protip for anyone using <a href="http://flourishlib.com/">Flourish</a> and in particular using the fActiveRecord ORM.  fActiveRecord is pretty awesome, with it and fRecordSet I find myself very rarely having to drop down to raw SQL, although for some reports it can&#8217;t be avoided and then fORMDatabase::retrieve()->query() is your friend.  Anyways one of the really cool features about fActiveRecord is that it has a plug in module based off of hooks and I wanted to pass along something that I&#8217;ve started doing as a convention that&#8217;s worked out really well for me.</p>
<p>I like all of my model classes to have a <tt>created_at</tt> and an <tt>updated_at</tt> timestamp that automatically do the correct thing to provide a very basic audit trail.  This does not let you off the hook for doing actual auditing, but it is a nice way to do sanity checks and get some instant information about records.  fActiveRecord makes this pretty easy to do, let&#8217;s dive into some code.</p>
<pre class="brush: php; title: ;">
class someModel extends fActiveRecord {
  /**
   * The fActiveRecord class provides the configure function to let you set-up Active Record hooks.  Let's do that now
   */
  protected function configure() {
    fORMDate::configureDateCreatedColumn($this, 'created_at');
    fORMDate::configureDateUpdatedColumn($this, 'updated_at');
  }
}
</pre>
<p>Easy as that you now have your <tt>created_at</tt>s and <tt>updated_at</tt>s working great for the someModel class.  Here&#8217;s the cool part though, because boilerplate code is stupid ugly code, if you want to use this across your project simply do the following.</p>
<pre class="brush: php; title: ;">
class ActiveRecord extends fActiveRecord {
  /**
   * For this project every model should record created_at and updated_at
   */
  protected function configure() {
    fORMDate::configureDateCreatedColumn($this, 'created_at');
    fORMDate::configureDateUpdatedColumn($this, 'updated_at');
  }
}
</pre>
<p>Now when you need to create a new model simply extend <tt>ActiveRecord</tt> instead of <tt>fActiveRecord</tt>  and auto timestamps are done.</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2010/10/29/auto-timestamps-in-flourish/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2 months</title>
		<link>http://ihumanable.com/blog/2010/08/31/2-months/</link>
		<comments>http://ihumanable.com/blog/2010/08/31/2-months/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 19:02:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[flourish]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=863</guid>
		<description><![CDATA[On June 3rd I typed the following into my Terminal. mkdir faveroo cd faveroo git init On August 15th I typed the following into my Terminal. cd ~/src/faveroo php deploy.php production Then I watched and held my breath as my carefully crafted deployment script worked its way through 2 months of code and pushed them [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_864" class="wp-caption aligncenter" style="width: 600px"><a href="http://ihumanable.com/blog/wp-content/uploads/2010/08/header.jpg"><img src="http://ihumanable.com/blog/wp-content/uploads/2010/08/header.jpg" alt="Faveroo Logo" title="that&#039;s a pretty sweet logo" width="590" height="96" class="size-full wp-image-864" /></a><p class="wp-caption-text">that's a pretty sweet logo</p></div>
<p>On June 3rd I typed the following into my Terminal.</p>
<pre>
mkdir faveroo
cd faveroo
git init
</pre>
<p>On August 15th I typed the following into my Terminal.</p>
<pre>
cd ~/src/faveroo
php deploy.php production
</pre>
<p>Then I watched and held my breath as my carefully crafted deployment script worked its way through 2 months of code and pushed them across the line.  Then I fired up my browser and went to <a href="http://faveroo.com">http://faveroo.com</a> and waited for the now familiar homepage to show up&#8230; I&#8217;m sure it took less than a second to load, but it seemed like an eternity, finally it was up.  I worked for the next few hours exercising the application through all its various operations, squishing little bugs here and there that popped up from being in a different environment.  Two months of development, and finally it was live, and it actually worked.  A few hours later we started hooking up people with sweet deals and putting money in the bank, mission accomplished.</p>
<p>Faveroo.com is my first project at my new job at 614 Media Group.  It was a skunkworks project up through the end of July, so I couldn&#8217;t come to this blog and talk about it.  I did all of the coding for Faveroo and my colleague Jeff Guciardo did all the design work to make it look so pretty (it&#8217;s probably the prettiest thing I&#8217;ve ever had the opportunity to create).  The basic premise of the website is that our team of dedicated sales people go and find great local deals, then we throw them up on Faveroo.com, and then we help people save some cash.  When you buy a Faveroo you save some money, the business makes money, we make money, and 3% of the sale automatically goes to charity, it&#8217;s win-win-win-win.  But I&#8217;m neither marketing nor sales, so I will stick with what I know and what I knows is tech, so let&#8217;s talk about that for a minute.</p>
<p>Faveroo is a PHP website that includes the public frontend, a private backend, and a series of maintenance scripts that make sure everything works like clockwork.  When I was starting up the Faveroo project I was given carte blanche as to how to build it.  All of our other web properties use the classic LAMP stack, so to keep operations fairly sane and because I deeply love PHP, I decided to build out Faveroo on a classic LAMP stack as well.  The code is Object Oriented, nearly MVC, PHP 5.2 code.  I looked around, had been for a long time, at various PHP Web Frameworks.  I had just come off of working with rails on a side project and so I knew the joy and frustration of work with a framework.</p>
<p>As you may be aware, I&#8217;m crazy in love with <a href="http://flourishlib.com">Flourish</a> and decided that I would use it as a major component.  I have been a fan of Flourish for a while now, probably over a year, but this was the first big application I was going to use it on, and really the first large scale from scratch application I have ever written.  Now don&#8217;t get me wrong, I&#8217;m no rookie to this slinging code stuff, I&#8217;ve maintained huge legacy applications, built middle-ware up from nothing, and even rewritten large applications to the point that almost all of the original code has been replaced.  But this would be the first time that if I didn&#8217;t like something in my code, it was because I was the stupid jack-ass that made such a boneheaded decision.  Well, not the first time, but the first time I couldn&#8217;t easily blame someone else <img src='http://ihumanable.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I want to say that the decision to go with Flourish is probably what made the rapid turn around time possible.  It&#8217;s a wonderful library that helps you do things right but doesn&#8217;t force you to do anything you don&#8217;t need.  The thing that amazed me as I used it is I started off only wanting to pull bits and pieces, maybe some fCryptography here and a little fMessaging there, but as I got familiar (and boy howdy did I get familiar) with the docs, I just found more and more amazing functionality and a beautifully coherent system.  Flourish was clearly written to be used, and by the end of the project I found I was using almost every class.  It&#8217;s clearly a tool written for real world use from real world experience.</p>
<p>Flourish and jQuery are really the 2 big external dependencies for Faveroo, the rest of the code was written by me.  I found this minimal system worked very well for me.  I wrote a router in about 100 lines of PHP code, it&#8217;s nothing earth shattering but I think it has a few novel ideas.   I&#8217;ve since built a new version of this router that is shorter and has less complex code paths.  At some point in the future I may try to make a more generic version of this router and release it open source.  All of the model classes are fairly straightforward using the excellent fActiveRecord as a base.</p>
<p>I spent about a week spinning up my minimalist framework, but it paid off big.  I knew how the system worked every step of the way, and more importantly, I could alter it in minor ways to achieve dramatic results.  All of this is possible with established frameworks, but here I got away without having to climb up a learning curve.  This gave me more time to understand the problem domain and to learn how to best use Flourish.</p>
<p>With this experience under my belt I&#8217;m looking forward to continuing to learn, and hopefully to contribute back to, Flourish and PHP development in general.  This project has shown me that in 2 months I can go from nothing to cash hitting the bank account.  I feel reinvigorated to make cool things that add value to people&#8217;s lives and reassured of my abilities as a programmer.  After a long period feeling burned out and wasted, I remember why I love programming, and why I love creating, and why this is the only thing I can ever see myself doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2010/08/31/2-months/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flourishing</title>
		<link>http://ihumanable.com/blog/2010/08/05/flourishing/</link>
		<comments>http://ihumanable.com/blog/2010/08/05/flourishing/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 15:18:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[flourish]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=856</guid>
		<description><![CDATA[Looks like my claim of writing fast and furious didn&#8217;t come to pass, oh well. For the last few weeks I&#8217;ve been working on a hush hush project for work. It&#8217;s not done yet but we are nearing the end of the road for the MVP to be released soon. I wanted to write a [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_859" class="wp-caption alignleft" style="width: 214px"><a href="http://flourishlib.com"><img src="http://ihumanable.com/blog/wp-content/uploads/2010/08/header_logo_beta.gif" alt="flourish logo" title="header_logo_beta" width="204" height="70" class="size-full wp-image-859" /></a><p class="wp-caption-text">Flourish's sweet logo</p></div>
<p>Looks like my claim of writing fast and furious didn&#8217;t come to pass, oh well.  For the last few weeks I&#8217;ve been working on a hush hush project for work.  It&#8217;s not done yet but we are nearing the end of the road for the MVP to be released soon.  I wanted to write a quick update to discuss what it&#8217;s been like getting back on my developer feet after burning out.</p>
<p>First off I&#8217;m engaged in my work again.  For months I had felt disconnected, on autopilot, just trying to get through the day and hit some milestones.  Secondly, I enjoyed playing cowboy for a while but have cone to realize that not all the habits I picked up in Corporate America were bad.  Thirdly, I&#8217;m back to getting serious amounts of work done and am solving interesting problems.</p>
<p>Enough touchy feely hippie bullshit, let&#8217;s get down to some business.  I&#8217;ve been building a largish scale php application for the last couple of weeks and I wanted to reflect on the process.</p>
<p>I started off looking at various php frameworks a few weeks before starting this new project.  I had kept an ear to the ground in the php framework area since forever so I knew the big players.  I had also dabbled in some ruby on rails so I knew the bliss of when a framework gets it right, and the frustration of running up against something you would have done differently.</p>
<p>I looked into several frameworks <a href="http://cakephp.org/">CakePHP</a>, <a href="http://www.symfony-project.org/">Symfony</a>, <a href="http://framework.zend.com/">Zend Framework</a>, <a href="http://fatfree.sourceforge.net/">Fat Free PHP</a>, <a href="http://www.yiiframework.com/">Yii</a>, <a href="http://www.noloh.com/#/home/">Noloh</a>, and <a href="http://www.recessframework.org/">Recess!</a> to name a few.  They were all quite interesting but they all felt oddly foreign.  Imagine if ruby on rails came out and it was a port of .Net web forms for ruby, blech.  All the frameworks I looked at felt like they were trying to pave over PHP and make it into ruby lite or .Net lite.  Each one was well put together on the whole and with some effort I&#8217;m sure I could have become proficient in any of them.  Then I remembered an old friend I had played with before, Will Bond&#8217;s unframework <a href="http://flourishlib.com">Flourish</a>.</p>
<p>If you haven&#8217;t taken a look before I urge you to <a href="http://flourishlib.com">do so now</a>.  Flourish is exactly what PHP needs, a strong core of classes geared toward common web tasks, with an eye towards simplicity, security, and consistency.  After having used Flourish for a few weeks I can do nothing but sing its praises.  Let me say that working with the combination of Flourish + PHP is a completely different experience than just writing PHP.  Flourish gives you a sane construct around which you can build high quality applications.  Here&#8217;s a list of things Flourish provides:</p>
<ul>
<li>Cross Database support for DB2, MSSQL, MySQL, Oracle, PostgreSQL, and SQLite</li>
<li>An extremely good ActiveRecord implementation</li>
<li>Filesystem with psuedo-transactions</li>
<li>Safe consistent handling of Requests</li>
<li>Session handling with special resources for Authentication</li>
<li>Classes for creating HTML including a quality Templating mechanism</li>
<li>Great Utility classes (think ActiveRecord rails people)</li>
<li>Amazing Email support</li>
<li>Classes for handling Dates, Numbers, and Money</li>
<li>High quality Exceptions and Handling Facilities</li>
</ul>
<p>The thing that you will notice with <a href="http://flourishlib.com">Flourish</a> is that it&#8217;s a library that&#8217;s seen real world use.  It provides a high quality core but understands that it shouldn&#8217;t try to be everything to everyone.  The components interoperate nicely but you also function in isolation quite capably.  It truly hits all the high points you would want from a library, but there is even more.</p>
<p><strong>DOCUMENTATION:</strong> The Flourish documentation is some of the best I&#8217;ve ever seen.  There is full PHPDoc for every class, which is nice, but more importantly there is &#8220;Class Documentation&#8221; that explains how the class is intended to be used, with code examples to get you started.  The documentation is written very well and is incredibly in-depth.  You could sit down and read it like a book, it&#8217;s that good.</p>
<p><strong>COMMUNITY:</strong> The Flourish discussion boards are active and I have never seen a posting go unanswered.  Will Bond himself usually answers within a few hours of your posting, I know he has more than once helped me fix some tricky bug or better explained how something worked to me.  The ability to reach out and communicate with the author is amazing, it also makes you want to provide support for the project.</p>
<p><strong>CONSISTENCY:</strong> The Flourish API is amazingly consistent.  I keep finding myself saying, &#8220;That&#8217;s how I would have written it&#8221; while using it.  If you learn how fCookie works, you know how fSession works, and you even know how fRequest works.  Flourish simplifies things to the point that it&#8217;s worth it to go the extra mile to add a bit of security to your code, because it makes it dead simple.  Then you look back and realize that it also has helped you write self-documenting code, and jesus, did it just fucking cut my lawn too, what the hell?</p>
<p><strong>SECURITY:</strong> As I alluded to earlier, Flourish encourages writing secure code.  Flourish takes security seriously enough to have <a href="http://flourishlib.com/docs/Security">an entire compendium</a> on just that topic and how it relates to PHP.  My code is definitely more secure now that I use Flourish, from better security in parsing Request variables, to easily preventing Cross Site Request Forgeries, Flourish has you covered.</p>
<hr />
<p>Ok, so I didn&#8217;t really expect this to turn into a huge love fest about how much I love <a href="http://flourishlib.com/">Flourish</a> but that&#8217;s where we are at.  I want to over the course of a few blog posts really explore Flourish.  I haven&#8217;t fully figured out what format these are going to take, but if you are a PHP developer who wants to take their code to the next level, stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2010/08/05/flourishing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>unlicense&#8217;d</title>
		<link>http://ihumanable.com/blog/2010/01/21/unlicensed/</link>
		<comments>http://ihumanable.com/blog/2010/01/21/unlicensed/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 13:34:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[philosophy]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=605</guid>
		<description><![CDATA[I wrote yesterday about the importance of open source software. I got one comment saying that prosper would be awesome if it were in the public domain. Here is the comment from Arto Bendiken Prosper looks *sweet*. It’d be awesome if Prosper indeed were in the public domain. I think such a move would make [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_606" class="wp-caption alignright" style="width: 310px"><a href="http://ihumanable.com/blog/wp-content/uploads/2010/01/colbert-lockwood.jpg"><img src="http://ihumanable.com/blog/wp-content/uploads/2010/01/colbert-lockwood-300x225.jpg" alt="colbert portrait by lockwood" title="colbert-lockwood" width="300" height="225" class="size-medium wp-image-606" /></a><p class="wp-caption-text">Freedom has never kicked so much ass</p></div>
<p>I wrote yesterday about the importance of open source software.  I got one comment saying that <a href="http://prosper-lib.com">prosper</a> <strong>would</strong> be awesome <strong>if</strong> it were in the public domain.  Here is the comment from <a href="http://ar.to/">Arto Bendiken</a></p>
<blockquote><p>Prosper looks *sweet*. It’d be awesome if Prosper indeed were in the public domain. I think such a move would make for a decisive selling point over the numerous competing PHP libraries, setting Prosper clearly apart from the herd and allowing it to be easily embedded into any new emerging PHP web frameworks.</p>
<p>It’s worth mentioning that a key reason that SQLite, which is in the public domain, has prospered (no pun intended) has been the fact that it can be so easily (both technically and legally speaking) embedded into any other software. The end results of technical excellence combined with singularly liberal licensing speak for themselves: http://www.sqlite.org/famous.html</p>
<p>I think a lot of these same benefits could come into play also in such a potentially key higher-level web app infrastructure piece as Prosper. It certainly seems that you have the technical side of things well in hand, already, so here’s hoping for a bright and prosperous future.</p></blockquote>
<p>Well I completely agree with Arto and want to clear up any confusion about prosper and its license.  Prosper was original hosted on Google Code, which requires you to choose a license, at the time I selected the MIT/X11 license based off of my belief that it was the most free.  A little further down the road I saw the <a href="http://sam.zoy.org/wtfpl/">WTFPL &#8211; Do What The Fuck You Want To Public License </a> and thought about switching to that.  There is a bluntness to the ideal of that license that appealed to me.</p>
<p>The problem with the WTFPL is of course its name, I want prosper to power lots of things and that means taking into account a wider audience.  While hackers and rock star programmers can easily adopt something with WTFPL, I didn&#8217;t want to be responsible for some corporation turning their back on an otherwise useful library because they were squeamish about a word in the license.</p>
<div id="attachment_607" class="wp-caption alignright" style="width: 230px"><a href="http://ihumanable.com/blog/wp-content/uploads/2010/01/no-copyright.png"><img src="http://ihumanable.com/blog/wp-content/uploads/2010/01/no-copyright.png" alt="no copyright" title="no-copyright" width="220" height="220" class="size-full wp-image-607" /></a><p class="wp-caption-text">I always thought people just hated the letter C... then I found out this means no copyright</p></div>
<p>Then I found <a href="http://ar.to/2010/01/set-your-code-free">this post</a> on Hacker News (ironically by the same Arto Bendiken) and it lead me to the <a href="http://unlicense.org/">Unlicense</a>.  The Unlicense is exactly what I was looking for and simple to adopt.  If you go to the <a href="http://github.com/ihumanable/prosper-lib">GitHub repo</a> you will see that the project is now officially Unlicense&#8217;d.  The 0.8 release will be the first official Unlicense&#8217;d release, and so will every release going forward.  I believe in free and open source software and so <strong>I&#8217;m publicly declaring now that prosper will always be free, open source, and unencumbered</strong>.  The mechanism that I will use to ensure this going forward will be Unlicense.</p>
<p>What&#8217;s the big deal, plenty of things are open source, why is this any different?  The difference is that I&#8217;m giving this away fully, without any restrictions.  Want to build a cool new library that uses prosper as the low-level database abstraction layer, go for it.  Want to build a proprietary ORM that utilizes prosper, go for it.  Want to repackage prosper and try to sell it (as underhanded as that is), go for it.  Want to smother prosper with jam and eat it, if you can find a way to, go for it.  Want to&#8230;. enough already, you can do whatever you like.</p>
<p>It is easy to talk about things like freedom and support them in the abstract, it becomes more difficult when you have something concrete.  People could very well take prosper and take it in directions I don&#8217;t care to see it go, but that is life, that is creation, that is the essence of open source.  It is my goal to see prosper provide a solid foundation for building new and better tools and frameworks in php.  I want as many people as possible to use it, and so this was a logical choice.</p>
<p>The next time you have some useful chunk of code lying around and you want to give it to the public domain for the good of the public, think about using <a href="http://unlicense.org">Unlicense</a>.  I can&#8217;t say it any better than they can so I will just quote their section about why you should use Unlicense.  &#8220;Because you have more important things to do than enriching lawyers or imposing petty restrictions on users of your code.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2010/01/21/unlicensed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>codemash</title>
		<link>http://ihumanable.com/blog/2010/01/07/codemash/</link>
		<comments>http://ihumanable.com/blog/2010/01/07/codemash/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 14:19:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[prosper]]></category>
		<category><![CDATA[self-promotion]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=552</guid>
		<description><![CDATA[Disclaimer: This post is shameless, and I mean really, really shameless, self-promotion. If you have ever been on this site before you may recognize the name prosper. Prosper is my attempt at creating something of value for the PHP community. For anyone is following along at GitHub, you may have noticed that there hasn&#8217;t been [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_553" class="wp-caption alignright" style="width: 310px"><a href="http://ihumanable.com/blog/wp-content/uploads/2010/01/wink-puppy.png"><img src="http://ihumanable.com/blog/wp-content/uploads/2010/01/wink-puppy-300x210.png" alt="winking puppy" title="wink-puppy" width="300" height="210" class="size-medium wp-image-553" /></a><p class="wp-caption-text">I want you to come to Matt's CodeMash Session</p></div>
<p><strong>Disclaimer: This post is shameless, and I mean really, really shameless, self-promotion.</strong></p>
<p>If you have ever been on this site before you may recognize the name <a href="http://ihumanable.com/blog/prosper">prosper</a>.  Prosper is my attempt at creating something of value for the PHP community.  For anyone is following along at <a href="http://github.com/ihumanable/prosper-lib">GitHub</a>, you may have noticed that there hasn&#8217;t been much work done in the last few weeks, what&#8217;s the deal?!  Well, don&#8217;t fret, prosper is still under active development but it has been frozen for a few reasons.</p>
<ol>
<li>It was the holidays, and I was doing this weird thing where you interact with humans</li>
<li>I&#8217;ve been seeking, and receiving, feedback from some key users</li>
<li>I will be giving a live demo of Prosper and have been working on that demo more than the library as of late</li>
</ol>
<p>&#8220;A Live Demo?&#8221; you say bedeviled by the notion.  Don&#8217;t worry you don&#8217;t all need to cram into my apartment to see some technological wizardry, all you need to do is head on over to CodeMash, then at 3:00 on Thursday head to room E.  The awesome company that I work for, <a href="http://hmbnet.com">HMB</a> is sponsoring CodeMash and have selected me to give a presentation on this crazy open source project they&#8217;ve heard I wrote.</p>
<p>I&#8217;ve been working on a very minimal PowerPoint, because I know people can read so there is no point in me reading to them.  At the end of the presentation though will be a live demo building up a simple database backed PHP application for managing all the fond memories of CodeMash, a quote board.  In case you are unaware, building an application in front of people is incredibly nerve-wracking, which is why for the next 5 days I will be building this application over and over while talking to absolutely no one, to the confusion of my poor neighbors.</p>
<p>Live demos have a fantastic way of just going all wrong, as Bill will demonstrate</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/zFx62_Iadjg&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/zFx62_Iadjg&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><br />
<br />
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/RgriTO8UHvs&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/RgriTO8UHvs&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>I&#8217;m not trying to poke fun at Mr. Gates (for once), giving a presentation in front of people, with new software is never a fun experience, and bad things&copy; do happen.  I will be practicing and practicing and practicing, and after that I will probably be practicing, for this presentation to make it the best it can be.</p>
<p>In other prosper news, I have set up <a href="http://prosper-lib.com">http://prosper-lib.com</a> to be the new home of prosper (currently just a forward to <a href="http://ihumanable.com/blog/prosper">here</a>, although the update is still working its way through GoDaddy&#8217;s intertubes so you may get a parking page for a while).  I am working with my good friend <a href="http://ashleykruso.com">Ashley Kruso</a> to get a new logo for prosper.  Once I have the new logo I will begin building a new web home for prosper that will be all kinds of pretty.  This is all in the run-up to Prosper 1.0, which is a goal for this year, but I haven&#8217;t quite nailed down when.</p>
<p>It&#8217;s all steam ahead on Prosper, thanks to the contributions and support of many people.  When I started this project a few months ago I would not have been able to guess what it would turn into, so thanks to everyone that has helped or is going to help.   By month&#8217;s end there should be a 0.8 release that will have all kinds of new fun stuff including deferred result sets and lots of bug fixes from my friend who was kind enough to evaluate Prosper, Ian.</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2010/01/07/codemash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>early present</title>
		<link>http://ihumanable.com/blog/2009/12/22/early-present/</link>
		<comments>http://ihumanable.com/blog/2009/12/22/early-present/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 16:50:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[prosper]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=466</guid>
		<description><![CDATA[There is an early Christmas present for anyone using prosper, a new release, Version 0.7! You can get it hot off the GitHub or download here. Version 0.7 has a lot of exciting new features, the biggest 2 were spurred on by Ian Potter and Jeremiah Peschka. The phpDoc has been updated (if you are [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_468" class="wp-caption alignright" style="width: 310px"><img src="http://ihumanable.com/blog/wp-content/uploads/2009/12/pink-present.jpg" alt="pink present" title="pink-present" width="300" height="300" class="size-full wp-image-468" /><p class="wp-caption-text">open source software, the gift for everyone!</p></div>
<p>There is an early Christmas present for anyone using <a href="http://ihumanable.com/blog/prosper">prosper</a>, a new release, <a href="http://github.com/ihumanable/prosper-lib/downloads">Version 0.7</a>!  You can get it hot off the GitHub or <a href="http://ihumanable.com/prosper/releases/prosper-lib-0.7.zip">download here</a>.</p>
<p>Version 0.7 has a lot of exciting new features, the biggest 2 were spurred on by <a href="http://twitter.com/pian0/status/6431820026">Ian Potter</a> and <a href="http://facility9.com">Jeremiah Peschka</a>.  The <a href="http://ihumanable.com/prosper/doc/current/index.html">phpDoc</a> has been updated (if you are still using version 0.6 you can find the old documentation <a href="http://ihumanable.com/prosper/doc/version-0.6/index.html">here</a>).  The big news is that <a href="http://ihumanable.com/blog/prosper">prosper</a> uses Prepared Statements by default now, gracefully and transparently falling back to string interpolation where Prepared Statements are not available.  The second new feature is the introduction of Explicit Transaction Management.</p>
<pre class="brush: php; title: ;">
try {
  Prosper\Query::begin();

  //Do a bunch of stuff

  Prosper\Query::commit();
} catch (Exception $e) {
  Prosper\Query::rollback();
}
</pre>
<p>Only some of the adapters support this, the ones that do not simply ignore the call to begin(), commit(), and rollback().   You can use the has_transactions() functions to check if the current adapter supports transactions.</p>
<table>
<tr>
<th>Database</th>
<th>Supported by Prosper</th>
<th>Prepared Statements</th>
<th>Transaction Support</th>
</tr>
<tr>
<td>dBase</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>DB++</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>FrontBase</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>filePro</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>Firebird / Interbase</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Informix</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>IBM DB2</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Ingres</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>MaxDB</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Mongo</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>mSQL</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>MS-SQL</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>MySQL</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>OCI8 (Oracle)</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Ovrimos</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Paradox</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>PostgreSQL</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>SQLite</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>Sybase</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>Tokyo Tyrant</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
</table>
<p>Happy Holidays, and Happy Coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2009/12/22/early-present/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>impedance</title>
		<link>http://ihumanable.com/blog/2009/12/21/impedance/</link>
		<comments>http://ihumanable.com/blog/2009/12/21/impedance/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 18:32:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[philosophy]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web dev]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=454</guid>
		<description><![CDATA[There is a threat to good software, one that threatens the most promising of software projects. This threat is impedance mismatch. I use impedence mismatch in the sense that Object-relational impedance mismatch uses the term, but make no mistake, I&#8217;m not talking about the difficulties of writing an ORM. What I wish to discuss is [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_456" class="wp-caption alignleft" style="width: 310px"><a href="http://ihumanable.com/blog/wp-content/uploads/2009/12/impedance-mismatch.jpg"><img src="http://ihumanable.com/blog/wp-content/uploads/2009/12/impedance-mismatch-300x264.jpg" alt="you can find really cool images searching for impedance mismatch, this one has lazers (with a z)" title="impedance-mismatch" width="300" height="264" class="size-medium wp-image-456" /></a><p class="wp-caption-text">you can find really cool images searching for impedance mismatch, this one has lazers (with a z)</p></div>
<p>There is a threat to good software, one that threatens the most promising of software projects.  This threat is impedance mismatch.  I use impedence mismatch in the sense that <a href="http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch">Object-relational impedance mismatch</a> uses the term, but make no mistake, I&#8217;m not talking about the difficulties of writing an ORM.  What I wish to discuss is far more insidious, it is death by a thousand paper cuts, it can spell ruin for any project.  Impedance mismatch is born out of the confusing first steps of a project, it can also arise from multiple developers working over time on a large project or from internal disagreements over the optimal solution.</p>
<p>The major problem is that when we go about designing some new piece of software, some whiz-bang solution, we do not fully understand the problem domain.  Any good development team will spend days filling up whiteboards with the solution that models the problem domain, but anyone with experience will tell you that once you get into the guts of a problem you realize that things need to be changed.  This is fine, in fact this is a sign that you are solving the actual problem and not the ideal one you began with, don&#8217;t worry about changing your solution to meet the realities of the domain.  The problem though is making these changes first class citizens and not some weird third class monster thrown into the mix.</p>
<p>Have you ever been on a project and heard a conversation like this?</p>
<blockquote><p>
New Developer: What is X?<br />
Grizzled Veteran: X is what we refer to internally as Y<br />
New Developer: Why do we call it Y internally but X on the UI<br />
Grizzled Veteran: Time constraints&#8230; budgets&#8230;. other misc. bullshit<br />
New Developer: *mental note: X is called Y sometimes*
</p></blockquote>
<p>BAMMO!  There&#8217;s some nasty impedance mismatch there.  The problem is not so much in what we display to the user, or what our object properties are called, or what the database columns are named, the issue is that we have made our mental model convoluted.  At the heart of all these systems we build as software developers is some sort of mental model, at runtime this is expressed in system as an object graph, for persistence it is expressed as a collection of tables and relationships, but all of these things are just a <strong>representation</strong> of some mental model.</p>
<div id="attachment_455" class="wp-caption alignright" style="width: 310px"><a href="http://ihumanable.com/blog/wp-content/uploads/2009/12/unicorn-rainbow.jpg"><img src="http://ihumanable.com/blog/wp-content/uploads/2009/12/unicorn-rainbow-300x225.jpg" alt="artist depiction: working with an elegant mental model" title="unicorn-rainbow" width="300" height="225" class="size-medium wp-image-455" /></a><p class="wp-caption-text">artist depiction: working with an elegant mental model</p></div>
<p>When our mental model is internally consistent and simple and elegant, it makes life easy and happy and unicorns shoot out of our monitors and everything is sunshine and puppies.  When your mental model gets convoluted it can be an awful and bewildering experience.  The problem comes from an increased overhead, instead of the mapping from one representation to the next being clear-cut, the developer has to carry around a hashmap in their skull mapping various representations of their mental model.  The difficulty of carrying out even trivial tasks is increased as the mapping from X -> Y -> Z -> Q -> P takes place.</p>
<div id="attachment_459" class="wp-caption alignleft" style="width: 210px"><a href="http://ihumanable.com/blog/wp-content/uploads/2009/12/american-gladiators.jpg"><img src="http://ihumanable.com/blog/wp-content/uploads/2009/12/american-gladiators.jpg" alt="impedance mismatch vs. coupling: battle to the death" title="american-gladiators" width="200" height="194" class="size-full wp-image-459" /></a><p class="wp-caption-text">impedance mismatch vs. coupling: battle to the death</p></div>
<p>So let&#8217;s just name everything the same and go home, problem solved.  Oh, if it could only be so easy, the problem is that on the other end from impedance mismatch is a devilish little troll named coupling.  Coupling is the amount that two pieces of software are intertwined, they could be tightly-coupled wherein changing one requires changing the other, or they can be loosely-coupled all the way to the point of being considered decoupled or orthogonal.  Orthogonal pieces are nice to work with because you can change one and know that you won&#8217;t have side-effects on other pieces.  Orthogonality goes by some other names: encapsulation, modularity, and decoupled, it is generally considered a Good Thing&copy; and I make no argument against it.</p>
<p>We now have these two seemingly opposing forces, we want to decrease impedance mismatch without introducing coupling, what should we do?  There are many ways to deal with this issue, let&#8217;s look at a few.</p>
<p><strong>Adapters</strong> are nice little pieces of code (also called wrappers), that allow two different things to look the same.  Let&#8217;s assume we want to write some code to manage users, users have a name, an address, and an age.  The developer of the class decides that this object can be pretty simple.</p>
<pre class="brush: php; title: ;">
class User {
  public $name;
  public $address;
  public $age;
}
</pre>
<p>The database developer decides that he loves structured data and that this should be broken out into all kinds of columns and tables.</p>
<pre class="brush: sql; title: ;">
table user (
  user_id int autoincrement primary key,
  first_name varchar,
  last_name varchar,
  addr_street varchar,
  addr_number int,
  addr_city int foreign key,
  addr_zipcode int,
  age int
)

table city (
  city_id int autoincrement primary key,
  city_name varchar,
  state_id int foreign key,
)

table state (
  state_id int autoincrement primary key,
  state_name varchar,
  state_abbrev varchar
)
</pre>
<p>We could create an adapter class that bridges the difference, for brevity&#8217;s sake I won&#8217;t include the code for it, but it would basically translate strings into database fields, as the application developer I get to imagine the database as mirroring my object, even though it doesn&#8217;t.</p>
<p><strong>ORM</strong> &#8211; ORM&#8217;s are like automatic adapters.  They are not without their faults and some implementations are better than others, but they mask the complexity of marshaling data and reduce the impedance mismatch.</p>
<p><strong>Convention over Configuration</strong> &#8211; This was made famous by Ruby on Rails.  There is some strong convention that you follow that allows for a consistent mapping between domains, an example would be that tables are always named the pluralized version of the class name.</p>
<p>There is no silver bullet to solving the problem of impedance mismatch, but a combination of the above can help limit it.  The best thing you can do is be aware of the problem, don&#8217;t introduce impedance where it is unnecessary, and never be afraid to ruthlessly refactor out impedance mismatch when you find it.  Keeping impedance mismatch low increases developer productivity, lowers the bar for bringing on new people, and makes unicorns leap out of your monitor farting rainbows.</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2009/12/21/impedance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>murdering your baby</title>
		<link>http://ihumanable.com/blog/2009/12/08/murdering-your-baby/</link>
		<comments>http://ihumanable.com/blog/2009/12/08/murdering-your-baby/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 18:52:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[philosophy]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[side project]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=355</guid>
		<description><![CDATA[Yesterday my friend Ian sent me a tweet about prosper @ihumanable I&#8217;d be more interested in using Prosper if it provided support for true prepared statements instead of concatenating strings. 6:29 AM Dec 7th &#8211; pian0 With that my baby was born, the baby was a version of prosper that utilized prepared statements where appropriate. [...]]]></description>
			<content:encoded><![CDATA[<div style="padding-left: 55px">
<div id="attachment_356" class="wp-caption alignnone" style="width: 380px"><img src="http://ihumanable.com/blog/wp-content/uploads/2009/12/baby.jpg" alt="don&#039;t worry, no babies were harmed" title="baby" width="370" height="301" class="size-full wp-image-356" /><p class="wp-caption-text">don't worry, no babies were harmed</p></div>
</div>
<p>Yesterday my friend Ian sent me a tweet about <a href="http://ihumanable.com/blog/prosper">prosper</a></p>
<blockquote><p>
<a href="http://twitter.com/ihumanable">@ihumanable</a> I&#8217;d be more interested in using Prosper if it provided support for true prepared statements instead of concatenating strings.<br />
<a href="http://twitter.com/pian0/status/6431820026">6:29 AM Dec 7th</a> &#8211; <a href="http://twitter.com/pian0">pian0</a>
</p></blockquote>
<p>With that my baby was born, the baby was a version of prosper that utilized prepared statements where appropriate.  Prosper&#8217;s main functionality has been coded for a while and the bulk of the work I&#8217;ve been doing as of late has been testing, improving backend support, and adding new functionality.  The nice thing about this kind of work is that you don&#8217;t have to go mucking around in working code, you are just fixing broken stuff and adding new functionality.  The idea of adding prepared statements made me a little queasy, I had briefly looked at it when I was starting prosper but decided that they were so varied that for the first attempt I would just avoid the headache.  What&#8217;s the problem you ask, let&#8217;s take a look at this feature table real quick.</p>
<table>
<tr>
<th>Database</th>
<th>Supported by Prosper</th>
<th>Can Support Prepared Statements</th>
</tr>
<tr>
<td>dBase</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>DB++</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>FrontBase</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>filePro</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>Firebird / Interbase</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Informix</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>IBM DB2</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Ingres</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>MaxDB</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Mongo</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>mSQL</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>MS-SQL</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>MySQL</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>OCI8 (Oracle)</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Ovrimos</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>Paradox</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>PostgreSQL</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #00FF88; color: #00773F">YES</td>
</tr>
<tr>
<td>SQLite</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>Sybase</td>
<td style="background: #00FF88; color: #00773F">YES</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
<tr>
<td>Tokyo Tyrant</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
<td style="background: #FF85B6; color: #FF0000">NO</td>
</tr>
</table>
<p>As you can see the support for prepared statements varies in the <a href="http://us2.php.net/manual/en/refs.database.vendors.php">Vendor Specific Database Extensions</a> of php.  There is also the fact that prepared statement support is poorly implemented in several extensions, they can be coded around but it adds a good deal of complexity.  Despite all the reasons not to implement prepared statements, safety, speed, and correctness dictate that I should at least give it a go.</p>
<p>Yesterday and today were my go, and I met with some success.  Prepared statements are not all that difficult to implement for a given backend, throw in some question marks, call the correct bind function, and you&#8217;re off and running.  The real difficulty is the cross-platform nature of prosper.  I wanted prepared statements to be a first class citizen, I didn&#8217;t want to decrease any existing functionality, I wanted to not overly complicate the way prosper works, and because there are 11 adapters that need to be upgraded, I wanted it to be simple to add this functionality to a given adapter.</p>
<p>I worked and toiled and toiled and worked, I tried hacking something up to make the MySQL adapter work, ran into the <tt>bind_results</tt> function and screamed at it for a while.  Then I got out some paper and drew out some diagrams, thought about sample code.  Then I went to sleep.  Then I woke up and in the shower pondered the proper syntax for passing around typing information and the division of labor for transformation.  Then I hacked on it some more and wrote a quick test. Then <strong>and this is the most important part</strong> I realized I had done it absolutely backwards.</p>
<p>I had some clues that stuff wasn&#8217;t working out right, I hit a point where I would either need to embed an if statement in every function of an adapter or have a duplicate function.  I thought that with some clever coding I could shove this down into the base class, it wasn&#8217;t great but it was working.  Then I saw another red flag when I realized that the processing in the where clause was identical to the processing in the values clause, and I applied some refactoring.  This is when I realized that there was a single function that I <strong>could</strong> have modified and had the whole thing work much more elegantly.</p>
<p>That is when I had to come to the decision to murder my baby.  I had painstakingly worked out the kinks for two days, traveling far down this road, touching a bunch of code, and now I realize the best way forward is back.  The best thing I can do right now is to revert my changes to Monday morning and lose 2 days of work, and that is great!</p>
<p>It&#8217;s not the best outcome, in an ideal world I would have seen this solution before and applied it and not wasted 2 days.  The thing is that I&#8217;ve learned a great deal, I&#8217;ve come up with a much better implementation, and I&#8217;ve been reminded of an important lesson, never be afraid to throw away code.  The code I wrote is adequate, it works well enough, but it is far from optimal.  I could keep going, head down, plowing away making as many problems as I solve trying to build a house on an unsound foundation.  The point here is to pay attention to those red flags.</p>
<p>The other important point is that sometimes you have to actually try something to find the thing that <strong>will</strong> work.  You may lose some time, but even after sitting down with pencil and paper, thinking long and hard, the optimal path didn&#8217;t come to me until I walked down the wrong road.  That&#8217;s just life sometimes as a software developer, you have to learn to live with it.</p>
<p>I will continue working on prepared statements for prosper, and I hope that by 0.7 or 0.8 they will be implemented and in there.  I still question the syntax and think that I can clean it up, right now the plan is for prosper to support unnamed parameters (?), named parameters (:name), unnamed typed parameters (%i), and named typed parameters (:name%s), but all this seems like a little much.  Good thing prosper hasn&#8217;t had a 1.0 release yet <img src='http://ihumanable.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2009/12/08/murdering-your-baby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>php pain</title>
		<link>http://ihumanable.com/blog/2009/12/07/php-pain/</link>
		<comments>http://ihumanable.com/blog/2009/12/07/php-pain/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 16:47:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[philosophy]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=343</guid>
		<description><![CDATA[I am a fan of php, ever since my first software development job where I was thrown in the deep end and had to sink or swim. I swam in the sea of php and actually think it is a very nice language (begin receiving hate mail&#8230;. now!). You see, I never knew the non-OOP [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_353" class="wp-caption alignright" style="width: 220px"><img src="http://ihumanable.com/blog/wp-content/uploads/2009/12/php-elephant.png" alt="he never forgets, even the stupid decisions" title="php-elephant" width="210" height="158" class="size-full wp-image-353" /><p class="wp-caption-text">he never forgets, even the stupid decisions</p></div>
<p>I am a fan of php, ever since my first software development job where I was thrown in the deep end and had to sink or swim.  I swam in the sea of php and actually think it is a very nice language (begin receiving hate mail&#8230;. now!).  You see, I never knew the non-OOP php, I was brought into a well managed project with Classes and Interfaces, it was basically Java with dollar-<a href="http://en.wikipedia.org/wiki/Sigil_%28computer_programming%29">sigils</a> thrown in.  I never suffered through the spaghetti nightmare that so much php is, so I&#8217;m admittedly wearing some rose-colored glasses.</p>
<p>There is one feature that I love about php, it is the height of elegance, the associative array.  The associative array can do anything, need a stack just use array_push and array_pop, need to do some functional programming array_map, array_filter, and array_walk are your friends.  The beauty of the associative array in php is that it is ubiquitous, its a hash map, array, stack, object, all rolled into one.</p>
<p>The problem with the associative array though is that its create syntax is ugly.  Here is how you create an array in php</p>
<pre class="brush: php; title: ;">
$example = array(1, 2, 3);
</pre>
<p>That doesn&#8217;t seem so bad, what am I complaining about, well the problem comes when you have nested arrays (which is somewhat common).</p>
<pre class="brush: php; title: ;">
$configuration =
array(
  'name' =&amp;gt; 'My Configuration',
  'server' =&amp;gt; array (
    'name' =&amp;gt; 'localhost',
    'port' =&amp;gt; '8080',
    'users' =&amp;gt; array (
      array (
        'username' =&amp;gt; 'example',
        'password' =&amp;gt; 'example'
      ),
      array (
        'username' =&amp;gt; 'user01',
        'password' =&amp;gt; 'pass01'
      )
    ),
    'overrides' =&amp;gt; array (
      'https' =&amp;gt; false )
  )
);
</pre>
<p>The biggest problem is not that I have to keep writing the word array its that arrays don&#8217;t <em>look</em> like arrays.  They look like function calls, with other nested function calls, of course the newlines and tabs help out, but they don&#8217;t solve the problem.  Let&#8217;s look at how this would appear in JavaScript using super-awesome <a href="http://json.org/">JSON</a>.</p>
<pre class="brush: jscript; title: ;">
var configuration = {
  name: 'My Configuration',
  server: {
    name: 'localhost',
    port: '8080',
    users: [ {username: 'example', password: 'example'},
             {username: 'user01', password: 'pass01'} ],
    overrides: {https: false}
  }
};
</pre>
<p>That&#8217;s much nicer and the more important part is that hashes <em>look</em> like hashes and arrays <em>look</em> like arrays.  There was a <a href="http://markmail.org/message/rsi4welftwou24p3">proposed php syntax change</a> that was discussed to death and an <a href="http://debuggable.com/posts/better-array-syntax-for-php:484d6517-a700-4af3-a62f-64544834cda3">analysis here</a> which would have made the following legal php</p>
<pre class="brush: php; title: ;">
$configuration = [
  'name' =&amp;gt; 'My Configuration',
  'server' =&amp;gt; [
    'name' =&amp;gt; 'localhost',
    'port' =&amp;gt; '8080',
    'users' =&amp;gt; [ ['username' =&amp;gt; 'example', 'password' =&amp;gt; 'example'],
               ['username' =&amp;gt; 'user01', 'password' =&amp;gt; 'pass01'] ],
    'overrides' =&amp;gt; ['https' =&amp;gt; false]
  ]
];
</pre>
<p>But this is not the case, and more importantly, may <strong><em>never</em></strong> be the case.  The issue has been brought up and rejected several times, with the following reasoning</p>
<blockquote><p>
I see no advantages here, only another way to do already possible thing and yet another way to confuse people. </p>
<p>- <a href="http://markmail.org/message/rsi4welftwou24p3#query:+page:1+mid:5htzyp6u7r4y2ljt+state:results">Anthony Dovgal</a>
</p></blockquote>
<blockquote><p>
For the record: I&#8217;m -1. array() is enough. Ridiculous idea to begin with.</p>
<p>- <a href="http://markmail.org/message/rsi4welftwou24p3#query:+page:1+mid:k43xtutctkcf2eyw+state:results">Jani Taskinen</a>
</p></blockquote>
<blockquote><p>
There is no reason to add another syntax for *exactly* the same thing, especially because it&#8217;s ungoogable</p>
<p>- <a href="http://markmail.org/message/rsi4welftwou24p3#query:+page:1+mid:42dtd42ump6hbolo+state:results">Derick Rethans</a>
</p></blockquote>
<p>Then there is this</p>
<blockquote><p>
I&#8217;m ok with it as well. Like I said over a year ago (*), it is a syntax very familiar to web developers and it feels natural to most people.</p>
<p>(*) http://marc.info/?l=php-internals&#038;m=117060700805108&#038;w=2<br />
- <a href="http://markmail.org/message/rsi4welftwou24p3#query:+page:1+mid:ykz7xiiknbxjixf3+state:results">Rasmus Lerdorf</a> (the guy who <a href="http://en.wikipedia.org/wiki/Rasmus_Lerdorf">created PHP</a>)
</p></blockquote>
<p>The problem I see here is that the vote finally breaks down to 1 / 3 contributors in favor and 17 / 20 users in favor, it was then rejected.  There is no recourse and as long as the people maintaining php see this as a useless feature, as a <a href="http://markmail.org/message/rsi4welftwou24p3#query:+page:1+mid:d4d3pz5xk3eq34yb+state:results">&#8220;backward incompatible syntax that duplicates already existing one, but 5 characters shorter&#8221;</a> change request, it will never move forward.</p>
<p>This is a shame and it is myopic and dishonest.  To trivialize this change supported by the vast majority of the php users voting as some sort of luxury people want so that they can avoid typing 5 characters is intellectually dishonest.  The major point is that square brackets mean arrays in php, unless you are creating one, then it looks like a function.</p>
<pre class="brush: php; title: ;">
$array = array(0, 1, 2, 3, 4, 5, 6); //Create the array
$element = $array[5]; //Get the element at index 5
$array[3] = &amp;quot;hello&amp;quot;; //Set the element at index 3
$array[]  = &amp;quot;example&amp;quot;; //Push an element onto the array
</pre>
<p>The dishonest part about the argument against the change is that it would be some sort of crazy zany backwards incompatible change and we would never break backwards compatibility.  First off, if you are going to classify any addition to the language as backwards incompatible, then stop having a core development team, you are done, close up shop you can&#8217;t add anything to the language anymore.  Secondly, php has a history of removing and adding things that break older code, anyone remember the first stab at classes, or ever written $stringvar{4} to access a character, that is going away and you should write $stringvar[4] from now on.  It&#8217;s deprecated as of php 5.3.0 and will most likely be removed as of php 6.</p>
<p>But we are left as a community without recourse, the array function to create an array exists and by that fact alone it will remain forever.  The most disheartening thing about the whole misadventure is that because this has been brought up and rejected so many times any time it is brought up now it is automatically rejected as being rejected before.  Discussion has attached to this idea a Scarlett Letter, most undeservedly.</p>
<p>At the end of the day I won&#8217;t jump ship, but it&#8217;s one of those things that makes you stop and scratch your head.  Why be so against it?  I don&#8217;t buy the arguments against it, I don&#8217;t understand the fervor that the devs fight against it with, and I don&#8217;t see the harm.</p>
<p>As people push the boundaries of what the language can do and the concept of the DSL (pushed by those ruby people) becomes more and more prominent, language cruft will have to fall by the wayside.  Not improving array literal syntax is not the end of the world, but the attitudes and egos on display fighting a harmless change that the user base wants could be.</p>
<hr />
Edit: My arrays were using non-literal keys, which is incorrect as pointed out by Mewp in the comments, they have been corrected.  Sorry about that, thanks for the correction Mewp.</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2009/12/07/php-pain/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>prosper 0.6</title>
		<link>http://ihumanable.com/blog/2009/12/03/prosper-0-6/</link>
		<comments>http://ihumanable.com/blog/2009/12/03/prosper-0-6/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 14:46:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[prosper]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://ihumanable.com/blog/?p=309</guid>
		<description><![CDATA[I plan to have another real post later today, just wanted to announce a point release for the prosper library. Prosper development has been moving along and I am happy to announce that I just slapped the finishing touches on version 0.6. Here is the 10 cent tour of the new stuff Changed the configuration [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ihumanable.com/blog/prosper"><div id="attachment_248" class="wp-caption alignright" style="width: 138px"><img src="http://ihumanable.com/blog/wp-content/uploads/2009/11/prosper-128.png" alt="prosper" title="prosper-128" width="128" height="64" class="size-full wp-image-248" /><p class="wp-caption-text">prosper</p></div></a></p>
<p>I plan to have another real post later today, just wanted to announce a point release for the prosper library.  Prosper development has been moving along and I am happy to announce that I just slapped the finishing touches on <a href="http://github.com/ihumanable/prosper-lib">version 0.6</a>.</p>
<p>Here is the 10 cent tour of the new stuff</p>
<ul>
<li>Changed the configuration system to take constants instead of string literals</li>
<li>Added support for the older mysql library in addition to the mysqli library</li>
<li>Refactored adapters internally for more concise and logical class layout</li>
<li>Moved project to GitHub</li>
<li>Adapters are lazy loading now, this allows the configuration to be done with minimal overhead. This functionality also allows for unit testing</li>
<li>Added phpDoc Documentation to the project</li>
<li>Added GitHub frontpage documentation and project roadmap</li>
</ul>
<p>There is a <a href="http://github.com/ihumanable/prosper-lib/downloads">new download available on GitHub</a> that contains all the documentation and source code.  Since prosper is still in the 0.* stage it may be best to just clone or fork the source, a look at the 0.7 roadmap shows that there is still a bunch of work to be done.</p>
<p>If you want to help there are several ways that you can provide support</p>
<ul>
<li>Use prosper and <a href="http://github.com/ihumanable/prosper-lib/issues">submit issues</a></li>
<li>Join the project*</li>
<li>Give me some feedback*</li>
</ul>
<p>If you want to join up or give me feedback just send an email to ihumanable@gmail.com with <em>prosper</em> in the subject line</p>
]]></content:encoded>
			<wfw:commentRss>http://ihumanable.com/blog/2009/12/03/prosper-0-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

