<?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>HTMList.com, A Web Development Blog by Synapse StudiosDevelopment   </title>
	<atom:link href="http://www.htmlist.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.htmlist.com</link>
	<description>A Web Development Blog by Synapse Studios</description>
	<lastBuildDate>Thu, 19 Jan 2012 09:30:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Fun in Source Code with Off And Away</title>
		<link>http://www.htmlist.com/development/fun-in-source-code-with-off-and-away/</link>
		<comments>http://www.htmlist.com/development/fun-in-source-code-with-off-and-away/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 01:50:24 +0000</pubDate>
		<dc:creator>Chris Cardinal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[off and away]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=641</guid>
		<description><![CDATA[A look at travel site Off and Away's source code reveals that everyone sneaks in fun lines in their source code from time to time.]]></description>
			<content:encoded><![CDATA[<p><a href="http://bit.ly/qQg5RO"><img class="aligncenter size-full wp-image-642" title="shizzle" src="http://www.htmlist.com/wordpress/wp-content/uploads/2011/07/shizzle.png" alt="" width="511" height="408" /></a></p>
<p><a href="http://bit.ly/qQg5RO">Off and Away</a> is a neat travel bidding site that lets you bid on travel deals for pennies. (The bids cost roughly a buck, though.) Curious at how their timer was put together, biz-partner Bob took a peek at their JavaScript. Somewhat surprised to find that they hadn&#8217;t <a href="http://en.wikipedia.org/wiki/Minification_(programming)">minified</a> it, he was even more amused by their credit card function, aptly named <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; white-space: pre;">$.fn.creditcard_shizzle.</span></p>
<p>When writing and testing code, it&#8217;s really tempting to put in junk data or in-jokes or other fun bits. As a development company, we&#8217;ve banned that outright, even in development environments, because we&#8217;ve discovered that somehow, some way, our little joke will end up live, released to clients or their customers, or even worse, appear in big bold letters in the middle of a demo. Nothing quite matches the sheer terror and stomach-pit feeling as having &#8220;stupid mcassface&#8221; show up during a demo.</p>
<p>Clearly, Off and Away&#8217;s devs/founders have a sense of humor and since this is source code and not customer-facing, this isn&#8217;t really a big deal. It&#8217;s not even vulgar. But it&#8217;s amusing to stumble across these sort of gems, as long as they&#8217;re not in the middle of a demo. For more fun, search swear words on <a href="http://www.google.com/codesearch">Google&#8217;s Code Search</a>. You&#8217;ll find some exasperated comments, angry rants, and outright bitterness, to be sure. (Hell, <a href="http://www.kuro5hin.org/story/2004/2/15/71552/7795">even Microsoft&#8217;s done it</a>.)</p>
<p><a href="http://bit.ly/qQg5RO">Off and Away</a></p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=641&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/development/fun-in-source-code-with-off-and-away/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon S3 Versioning, Multi-Factor Authentication Now Available</title>
		<link>http://www.htmlist.com/cool-stuff/amazon-s3-versioning-and-multi-factor-authentication-now-available/</link>
		<comments>http://www.htmlist.com/cool-stuff/amazon-s3-versioning-and-multi-factor-authentication-now-available/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 17:00:00 +0000</pubDate>
		<dc:creator>Chris Cardinal</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[amazon aws]]></category>
		<category><![CDATA[amazon s3]]></category>
		<category><![CDATA[deletions]]></category>
		<category><![CDATA[mfa]]></category>
		<category><![CDATA[versioning]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=579</guid>
		<description><![CDATA[Amazon reveals their newest addition to their S3 service: Versioning and multi-factor authentication.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-580" title="MFA Fob" src="http://www.htmlist.com/wordpress/wp-content/uploads/2010/02/mfa.jpg" alt="" width="160" height="120" />Continuing their trend of releasing substantial features and additional services in their web services portfolio on a regular basis, Amazon announced this week the availability of versioning and multi-factor authentication across their Simple Storage Service (S3) property.</p>
<p><strong>How S3 Versioning Works</strong><br />
Versioning is a critical feature many developers had requested as data stored on S3, while maintained in triplicate across the S3 file-system automatically, is still vulnerable to sweeping delete operations by developers, errant scripts, or other causes. Moreover, developers had to manually version changing files if they wanted to preserve the ability to roll-back to an earlier revision or undo a &#8220;delete&#8221;. In any event, a lot of custom code had to be created to replicate these behaviors, and most solutions weren&#8217;t particularly graceful.</p>
<p><span id="more-579"></span></p>
<p>Versioning is <a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/">easy to enable</a> and brilliant for Amazon: make a simple API call to enable versioning for an entire bucket and all changes to the files within that bucket will preserve versions. Moreover, deletions of files through the typical <code>DELETE</code> API call will simply create a delete marker, making the file unavailable for all intents and purposes, but preserving its presence and all of its versions in the S3 filesystem, until its permanent deletion is called for. It&#8217;s brilliant for Amazon because you pay the additional storage fees for each version and for each &#8220;deleted&#8221; file that hasn&#8217;t been permanently destroyed.</p>
<p>This means that versioning can be easily enabled on any existing S3 implementation with out breaking compatibility with existing code. Naturally, developers will need to rewrite their delete calls to make use of the version delete options, but for an application with little-to-no deletions, this is a feature implemented with a single API call.</p>
<p>Amazon also introduced Multi-Factor Authentication. MFA works with security code-generating key fobs that act as a physical token one must have in order to perform an action. In this case, if you enable MFA, you need the token to log in and manage your AWS account, and you can also optionally require the token to commit a permanent deletion of a file version. For the uninitiated, it&#8217;s considered multi-factor as you need two types of authentication to login or make deletes on your account. (Your AWS username and password for account management and your AWS public/private key for API calls each make up the other half of the multi-factor equation with the MFA code.)</p>
<p><strong>The S3 Trash Bin</strong><br />
Using MFA, it becomes possible to create a highly robust and secure safety net that prevents the wholesale deletion of an S3 account&#8217;s contents without first enforcing an additional review step. After enabling versioning and MFA-Delete mode for a bucket, a developer&#8217;s application will continue to function to the end-user as expected. This means very little rewriting of code needs to be performed to get these features up and running. A simple trash bin script could then be created which would identify all files whose current version is a delete marker, and present them to an admin. Since permanent deletions require the MFA code to be appended to the API call, only the individual with physical access to the code (which recycles every 30 seconds) would be able to commit the delete operations necessary. After reviewing the files queued for permanent deletion, they&#8217;d enter the code and the script would be sent off to the races.</p>
<p>Naturally, this still leaves some room for error: the script that commits the permanent deletes would need to be scrutinized to ensure that it itself is bulletproof, but beyond that, this should protect against nearly all accidental deletions, and establish a command and control hierarchy for an organization. It&#8217;s important to reduce the sheer number of individuals who have complete deletion privileges for myriad reasons, and this helps accomplish that. The MFA key fob is available for all of $13 and you&#8217;re off to the races. You simply input your serial number on the AWS site, and Amazon&#8217;s servers knows what the code it&#8217;s generated should be based on the time and a seed that&#8217;s private to them.</p>
<p><a href="http://aws.amazon.com/mfa/">More on Amazon AWS Multi-Factor Authentication</a><br />
<a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/Versioning.html">S3 Versioning</a> | Amazon Developer&#8217;s Guide</p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=579&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/cool-stuff/amazon-s3-versioning-and-multi-factor-authentication-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending PHP 5.3 Closures with Serialization and Reflection</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/</link>
		<comments>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 22:32:57 +0000</pubDate>
		<dc:creator>Jeremy Lindblom</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[magic methods]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[serialization]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=551</guid>
		<description><![CDATA[Our developer examines Closures in PHP 5.3]]></description>
			<content:encoded><![CDATA[<p>PHP 5.3 has brought with it some powerful and much-needed features like <a href="http://php.net/manual/en/language.oop5.late-static-bindings.php">late static bindings</a>, <a href="http://us3.php.net/manual/en/language.namespaces.rationale.php">namespaces</a>, and closures (also referred to as anonymous functions and lambda functions). Anyone who is experienced with JavaScript or who has worked with programming languages like Scheme or Lisp should realize the value that anonymous functions can bring to PHP. The <a title="PHP Closures (Anonymous Functions)" href="http://www.php.net/manual/en/functions.anonymous.php">PHP Manual explains closures</a> like this:</p>
<blockquote><p>Anonymous functions, also known as closures, allow the creation of functions which have no specified name. They are most useful as the value of callback parameters, but they have many other uses. Closures can also be used as the values of variables; PHP automatically converts such expressions into instances of the Closure internal class.</p></blockquote>
<p>PHP has very few <a title="PHP predefined classes" href="http://php.net/manual/en/reserved.classes.php">predefined classes</a> that are part of the core language, so naturally I was intrigued by the Closure class. The PHP Manual has this to say about the class:</p>
<blockquote><p>The predefined final class Closure was introduced in PHP 5.3.0. It is used for internal implementation of anonymous functions. The class has a constructor forbidding the manual creation of the object (issues <code>E_RECOVERABLE_ERROR</code>) and the <code>__invoke()</code> method with the calling magic.</p></blockquote>
<p>The <a href="http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.invoke">invoke magic method</a> is also a new feature in PHP 5.3. It is called when an object is used in the context of a function (e.g. <code>$object($parameter);</code>). Since Closure objects will be used like functions, this is a critical feature of the Closure object. The Closure class may be perfectly equipped to act like an anonymous function, but it does not provide any extra utility beyond that. A <code>var_dump()</code> of a closure will reveal the functions parameters, but there is no way to get any other information about the Closure (like the actual code of the function). Trying to serialize the Closure throws an Exception and <code>json_encode()</code> just returns an empty JSON string. To make matters worse, the Closure class is <a href="http://us.php.net/manual/en/language.oop5.final.php">final</a>, so there is no way to extend it.</p>
<p>That simply wasn&#8217;t going to cut it for me. I wanted to make my own Closure class that was at least able to do the following: <span id="more-551"></span></p>
<ol>
<li>Invoke the Closure (with <code>__invoke()</code>) just like the PHP Closure class</li>
<li>Retrieve the actual code of the Closure</li>
<li>Retrieve detailed data about the Closure&#8217;s parameters</li>
<li>Retrieve the names and values of any variables inherited from the Closure&#8217;s parent&#8217;s scope (with the <code>use</code> construct)</li>
<li>Serialize and unserialize the Closure</li>
</ol>
<p>I decided to play around with the <a href="http://php.net/manual/en/book.reflection.php">Reflection API</a> to see what kind of information I could get from the Closure. A Closure is a function, so using the <a href="http://us.php.net/manual/en/class.reflectionfunction.php">ReflectionFunction class</a> provides the same information about Closures as it does about any other functions. PHP 5.3 also added the <code>isClosure()</code> method to the ReflectionFunction (in case you weren&#8217;t convinced that reflection would be helpful). After some tinkering, it became apparent that I would be able to accomplish all of my desires. I will walk you through the construction of my &#8220;SuperClosure&#8221; class and explain how the creative use of Reflection allows us to find ways around the problems normally blocking the ability to have my desired features.</p>
<h2 id="toc-1-grant-the-ability-to-invoke-the-closure">1. Grant the ability to invoke the Closure</h2>
<p>The first goal was to create the basic SuperClosure class that both encapsulates and allows invocation of the Closure. To do this I wrote a simple class with a constructor and the magic <code>__invoke()</code> method. I also included an accessor method (getter) for the actual Closure. In the constructor I created an instance of the ReflectionFunction class and stored it as a class member that helped allow invocation of the closure with a variable number of arguments. It also helped me accomplish other things later. The following code shows the basic class upon which I will be building. The complete will be shown at the end of the article.</p>
<pre class="brush: php">class SuperClosure {

	protected $closure = NULL;
	protected $reflection = NULL;

	public function __construct($function)
	{
		if ( ! $function instanceOf Closure)
			throw new InvalidArgumentException();

		$this-&gt;closure = $function;
		$this-&gt;reflection = new ReflectionFunction($function);
	}

	public function __invoke()
	{
		$args = func_get_args();
		return $this-&gt;reflection-&gt;invokeArgs($args);
	}

	public function getClosure()
	{
		return $this-&gt;closure;
	}
}</pre>
<p>The <code>__invoke()</code> method allows the SuperClosure object to be used exactly as if it was a Closure object. I had to recreate this functionality for the SuperClosure class since I was not able to extend the Closure to begin with. In order to pass arguments through to the real Closure, I used a combination of the <a href="http://php.net/manual/en/function.func-get-args.php"><code>func_get_args()</code></a> function and the <code>invokeArgs()</code> method of ReflectionFunction to ensure that any variable number of arguments could be used. I could have also used <code>call_user_func_array()</code> function, but I prefer Reflection, and since I already had an instance of the ReflectionFunction, the <code>invokeArgs()</code> method seemed like a better choice.</p>
<h2 id="toc-2-retrieve-the-actual-code-of-the-function">2. Retrieve the actual code of the function</h2>
<p>Secondly, I added code that allowed the SuperClosure class to find and store the actual code defining the closure. This feature is actually the key to doing the serialization later and is the most complicated part of the program. To accomplish this portion of the program, I used the instance of ReflectionFunction from Step 1 and the <a href="http://php.net/manual/en/class.splfileobject.php">SplFileObject</a> class, an SPL class which provides a nice object-oriented interface for dealing with files. The <code>getFileName()</code>, <code>getStartLine()</code>, and <code>getEndLine()</code> methods of the ReflectionFunction class allowed me to retrieve all the information I needed to find the source code of the Closure function. Using the SplFileObject to open and read from the source file and in combination with some string manipulation, I was able to obtain the closure&#8217;s source code. The following code shows the protected <code>_fetchCode()</code> method used to parse the closure&#8217;s code out of its source file:</p>
<pre class="brush: php">protected function _fetchCode()
{
	// Open file and seek to the first line of the closure
	$file = new SplFileObject($this-&gt;reflection-&gt;getFileName());
	$file-&gt;seek($this-&gt;reflection-&gt;getStartLine()-1);

	// Retrieve all of the lines that contain code for the closure
	$code = &#039;&#039;;
	while ($file-&gt;key() &lt; $this-&gt;reflection-&gt;getEndLine())
	{
		$code .= $file-&gt;current();
		$file-&gt;next();
	}

	// Only keep the code defining that closure
	$begin = strpos($code, &#039;function&#039;);
	$end = strrpos($code, &#039;}&#039;);
	$code = substr($code, $begin, $end - $begin + 1);

	return $code;
}</pre>
<p>The only limitations with the current version of this function are that you cannot have multiple closures on a single line and you cannot use the word &#8220;function&#8221; anywhere besides the actual closure&#8217;s declaration.</p>
<h2 id="toc-3-retrieve-detailed-data-about-the-closures-parameters">3. Retrieve detailed data about the Closure&#8217;s parameters</h2>
<p>Retrieving information about the closure&#8217;s parameters was as simple as adding a method that simply returns the result of the <code>getParameters()</code> method the SuperClosure&#8217;s instance of ReflectionFunction. That&#8217;s all. The <code>getParameters()</code> method returns ReflectionParameter objects which have several methods for getting information about the parameters including their names, values, default values, and more.</p>
<h2 id="toc-4-retrieve-the-names-and-values-of-any-variables-inherited-from-the-closures-parents-scope">4. Retrieve the names and values of any variables inherited from the Closure&#8217;s parent&#8217;s scope</h2>
<p>One of the biggest problems I had was retrieving the names and values of the variables added to the Closure&#8217;s scope with the <code>use</code> construct. There isn&#8217;t a documented way of doing this as far as I know, but I was able to figure out a way to do it after playing around some more with the ReflectionFunction class (it is just so helpful). These variables are actually included in the results of the <code>getStaticVariables()</code> method. If the closure declares any variables with the <code>static</code> keyword, these will also be included in the results. To get around this I added the <code>_fetchUsedVariables()</code> method that uses a combination of the <code>getStaticVariables()</code> method and some string manipulation of the Closure&#8217;s code (from Step 2) to find only the variables that were inherited from the parent&#8217;s scope. The following code shows the <code>_fetchUsedVariables()</code> method:</p>
<pre class="brush: php">protected function _fetchUsedVariables()
{
	// Make sure the use construct is actually used
	$use_index = stripos($this-&gt;code, &#039;use&#039;);
	if ( ! $use_index)
		return array();

	// Get the names of the variables inside the use statement
	$begin = strpos($this-&gt;code, &#039;(&#039;, $use_index) + 1;
	$end = strpos($this-&gt;code, &#039;)&#039;, $begin);
	$vars = explode(&#039;,&#039;, substr($this-&gt;code, $begin, $end - $begin));

	// Get the static variables of the function via reflection
	$static_vars = $this-&gt;reflection-&gt;getStaticVariables();

	// Only keep the variables that appeared in both sets
	$used_vars = array();
	foreach ($vars as $var)
	{
		$var = trim($var, &#039; $&amp;amp;&#039;);
		$used_vars[$var] = $static_vars[$var];
	}

	return $used_vars;
}</pre>
<h2 id="toc-5-grant-the-ability-to-serialize-and-unserialize-the-closure">5. Grant the ability to serialize and unserialize the Closure</h2>
<p>Finally, I implemented the serialization capabilities. Since an actual closure object cannot be serialized (it gives a fatal error), I had to be creative to come up with a way to do my own serialization. The code I wrote for Step 2 and Step 4 made this possible. The <a href="http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep">sleep magic method</a> allows you to hook into the serialization process, so I used this method to prepare my SuperClosure class for serialization. In order for my class to be serialized, I needed to first stop the Closure object and the ReflectionFunction object representing the Closure from being serialized. The <code>__sleep()</code> method should return an array of the class members you are serializing, so I simply left those variables out of the list. Because I was serializing the Closure&#8217;s code and static variables, it made possible in the <code>__wakeup()</code> magic method to recreate the Closure object using the code. To do this I had to use the <code>extract()</code> function on my array of used variables to import them back into the scope. Then I performed an <code>eval()</code> operation on the Closure&#8217;s code in order to recreate the Closure. <code>eval()</code> is always a risky operation, but in this case it makes sense. If you are planning to use this code for any of your own projects, I urge you to take precautions.  The following code shows the complete SuperClosure class with the additions of the <code>__sleep(</code>) and <code>__wakeup()</code> methods.</p>
<pre class="brush: php">class SuperClosure {

	protected $closure = NULL;
	protected $reflection = NULL;
	protected $code = NULL;
	protected $used_variables = array();

	public function __construct($function)
	{
		if ( ! $function instanceOf Closure)
			throw new InvalidArgumentException();

		$this-&gt;closure = $function;
		$this-&gt;reflection = new ReflectionFunction($function);
		$this-&gt;code = $this-&gt;_fetchCode();
		$this-&gt;used_variables = $this-&gt;_fetchUsedVariables();
	}

	public function __invoke()
	{
		$args = func_get_args();
		return $this-&gt;reflection-&gt;invokeArgs($args);
	}

	public function getClosure()
	{
		return $this-&gt;closure;
	}

	protected function _fetchCode()
	{
		// Open file and seek to the first line of the closure
		$file = new SplFileObject($this-&gt;reflection-&gt;getFileName());
		$file-&gt;seek($this-&gt;reflection-&gt;getStartLine()-1);

		// Retrieve all of the lines that contain code for the closure
		$code = &#039;&#039;;
		while ($file-&gt;key() &lt; $this-&gt;reflection-&gt;getEndLine())
		{
			$code .= $file-&gt;current();
			$file-&gt;next();
		}

		// Only keep the code defining that closure
		$begin = strpos($code, &#039;function&#039;);
		$end = strrpos($code, &#039;}&#039;);
		$code = substr($code, $begin, $end - $begin + 1);

		return $code;
	}

	public function getCode()
	{
		return $this-&gt;code;
	}

	public function getParameters()
	{
		return $this-&gt;reflection-&gt;getParameters();
	}

	protected function _fetchUsedVariables()
	{
		// Make sure the use construct is actually used
		$use_index = stripos($this-&gt;code, &#039;use&#039;);
		if ( ! $use_index)
			return array();

		// Get the names of the variables inside the use statement
		$begin = strpos($this-&gt;code, &#039;(&#039;, $use_index) + 1;
		$end = strpos($this-&gt;code, &#039;)&#039;, $begin);
		$vars = explode(&#039;,&#039;, substr($this-&gt;code, $begin, $end - $begin));

		// Get the static variables of the function via reflection
		$static_vars = $this-&gt;reflection-&gt;getStaticVariables();

		// Only keep the variables that appeared in both sets
		$used_vars = array();
		foreach ($vars as $var)
		{
			$var = trim($var, &#039; $&amp;amp;&#039;);
			$used_vars[$var] = $static_vars[$var];
		}

		return $used_vars;
	}

	public function getUsedVariables()
	{
		return $this-&gt;used_variables;
	}

	public function __sleep()
	{
		return array(&#039;code&#039;, &#039;used_variables&#039;);
	}

	public function __wakeup()
	{
		extract($this-&gt;used_variables);

		eval(&#039;$_function = &#039;.$this-&gt;code.&#039;;&#039;);
		if (isset($_function) AND $_function instanceOf Closure)
		{
			$this-&gt;closure = $_function;
			$this-&gt;reflection = new ReflectionFunction($_function);
		}
		else
			throw new Exception();
	}
}</pre>
<h2 id="toc-conclusion">Conclusion</h2>
<p>With some cleverness and reflection, I was able to create the SuperClosure class and extend the Closure&#8217;s normal capabilities. Although my class does not enhance the typical use of a PHP Closure it does make it possible to serialize and transport a closure and provides an interface for examining the parameters and inherited variables. This means that we can do:</p>
<pre class="brush: php">$closure = new SuperClosure(
	function($num1, $num2) {return $num1 + $num2;}
);
$serialized_closure = serialize($closure);
$unserialized_closure = unserialize($serialized_closure);
echo $unserialized_closure(1, 5);
</pre>
<p>without worrying about errors. Also, it would technically be possible to send closures through a remote service.</p>
<p>From what I have read in the PHP Manual, this class may have to be changed in the future. The Manual states this regarding anonymous functions:</p>
<blockquote><p>Anonymous functions are currently implemented using the Closure class. This is an implementation detail and should not be relied upon.</p></blockquote>
<p>So according to this, future versions of PHP might implement closures differently, and my class would have to be rewritten.</p>
<p>If you would like a copy of the code from this article (and an example of its use) you can find it on <a href="http://github.com/jeremeamia/super_closure">my Github account</a>.</p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=551&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Google Speed Tracer Makes AJAX Optimization Easier</title>
		<link>http://www.htmlist.com/tech-news/google-speed-tracer-makes-ajax-optimization-easier/</link>
		<comments>http://www.htmlist.com/tech-news/google-speed-tracer-makes-ajax-optimization-easier/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 06:54:29 +0000</pubDate>
		<dc:creator>Chris Cardinal</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Tech News]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[google web toolkit]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[speed tracer]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=493</guid>
		<description><![CDATA[Google announced their Speed Tracer profiling tool to allow developers to better analyze performance problems in their web applications.]]></description>
			<content:encoded><![CDATA[<p><img class="size-medium wp-image-495 alignright" title="SpeedTracer-SluggishnessDetail" src="http://www.htmlist.com/wordpress/wp-content/uploads/2009/12/SpeedTracer-SluggishnessDetail-300x297.png" alt="SpeedTracer-SluggishnessDetail" width="180" height="178" />Google today announced <a title="Google Speed Tracer" href="http://code.google.com/webtoolkit/speedtracer/">Speed Tracer</a> as part of their <a href="http://code.google.com/webtoolkit/overview.html">Google Web Toolkit</a> offerings. While most of the GWT focuses on enabling developers to create web applications in Java (which compiles down to optimized JavaScript), Speed Tracer is a useful profiling tool for any developer wrestling with XMLHttpRequest.</p>
<p><strong>What makes Speed Tracer different?</strong></p>
<p>Developers have long used Firebug to identify what AJAX requests were causing bottlenecks and to analyze responses to those requests. Firebug is an extremely powerful tool and does a serviceable job with this approach, but Speed Tracer takes things one step further, analyzing the &#8220;sluggishness&#8221; of your application by examining how busy or blocked the UI is in your browser. This can help developers analyze why their application feels slow, instead of simply focusing on network-based bottlenecks.</p>
<p>Speed Tracer makes use of specific, unique APIs built into Webkit for this very purpose, which gives it a unique advantage compared to other profiling tools. Instead of simply guessing and checking, developers will now have full visibility into what&#8217;s causing their applications to appear slow:<br />
<blockquote>Using Speed Tracer you are able to get a better picture of where time is being spent in your application. This includes problems caused by JavaScript parsing and execution, layout, CSS style recalculation and selector matching, DOM event handling, network resource loading, timer fires, XMLHttpRequest callbacks, painting, and more.</p></blockquote>
<p>Very cool stuff. What&#8217;s more, it&#8217;s free, open source, and <a title="Speed Tracer getting started" href="http://code.google.com/webtoolkit/speedtracer/get-started.html">available for users of Google Chrome right now</a>. Check out their tutorial below:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.youtube.com/v/Sn_3rJaexKc&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/Sn_3rJaexKc&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a title="Google Speed Tracer" href="http://code.google.com/webtoolkit/speedtracer/">Google Speed Tracer</a></p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=493&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/tech-news/google-speed-tracer-makes-ajax-optimization-easier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Better Memory Management Tools for Web Apps Coming Soon</title>
		<link>http://www.htmlist.com/cool-stuff/better-memory-management-tools-for-web-apps-coming-soon/</link>
		<comments>http://www.htmlist.com/cool-stuff/better-memory-management-tools-for-web-apps-coming-soon/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 22:25:47 +0000</pubDate>
		<dc:creator>Chris Cardinal</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[memory usage]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[Mozilla Foundation]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=469</guid>
		<description><![CDATA[Developing a &#8220;web 2.0&#8243; application brings with it a host of new challenges previously unfelt or easily ignored with older, single-page-load-per-action apps. The browser has evolved from a simple page renderer to an application platform that busily executes JavaScript and receives, parses, and displays loads of new data without ever leaving the page. Developers are [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-470" title="mem_usage" src="http://www.htmlist.com/wordpress/wp-content/uploads/2009/03/mem_usage.gif" alt="mem_usage" width="456" height="156" /></p>
<p>Developing a &#8220;web 2.0&#8243; application brings with it a host of new challenges previously unfelt or easily ignored with older, single-page-load-per-action apps. The browser has evolved from a simple page renderer to an application platform that busily executes JavaScript and receives, parses, and displays loads of new data without ever leaving the page. Developers are now struck with the challenge of ensuring their applications manage memory properly and efficiently—your JavaScript can leak memory, killing the user experience on your site, but also impacting the user&#8217;s complete experience with their system across the board.</p>
<p>To date, it&#8217;s been a bit of a struggle to manage memory, since developers are essentially forced to rely on their operating system&#8217;s memory managers to even <em>monitor</em> the memory usage of their browser. Even then, testing can be frustrating, as Firefox, for instance, stores all tabs in the same process. Google Chrome is multi-threaded; each tab is its own process. Chrome also features its own built in task manager, so you can identify which page is using exactly how much memory, CPU, and bandwidth. Even at its most detailed, the stats available only show aggregate memory and virtual memory usage—these abstract figures make troubleshooting individual pieces of your code difficult to say the least.</p>
<p>The folks over at Mozilla&#8217;s Developer Tools Lab are looking to change that by building a memory analysis tool that helps devs understand exactly how their application is using memory, and the behavior of the cycle (garbage) collector:</p>
<blockquote><p>We plan on the initial implementation of this tool to be simple. For memory usage, we want to introduce the ability to visualize the current set of non-collectible JavaScript objects at any point in time (i.e., the <a href="http://en.wikipedia.org/wiki/Heap_%28data_structure%29">heap</a>) and give you the ability to understand why those objects aren’t collectible (i.e., trace any object to a GC root). For the cycle collector, we want to give you a way to understand when a collection starts and when it finishes and thus understand how long it took.</p></blockquote>
<p>Ben Galbraith and the team are soliciting help and feedback, so if this is an issue you&#8217;ve had to deal with in the past, make sure you comment.</p>
<p><a href="http://benzilla.galbraiths.org/2009/03/23/memory-tools-and-you/">A New Memory Tool for the Web</a> | Ben Galbraith&#8217;s Blog via <a href="http://ajaxian.com/">Ajaxian</a></p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/fe6ef69e-aa85-4fab-8fbf-98997c8a0049/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=fe6ef69e-aa85-4fab-8fbf-98997c8a0049" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=469&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/cool-stuff/better-memory-management-tools-for-web-apps-coming-soon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lunascape Multi-Rendering-Engine Browser Review: Verdict—Three Trick Pony</title>
		<link>http://www.htmlist.com/development/lunascape-multi-rendering-engine-browser-review-verdict%e2%80%94three-trick-pony/</link>
		<comments>http://www.htmlist.com/development/lunascape-multi-rendering-engine-browser-review-verdict%e2%80%94three-trick-pony/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 00:08:26 +0000</pubDate>
		<dc:creator>Chris Cardinal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[gecko]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[lunascape]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[rendering engines]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[trident]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=391</guid>
		<description><![CDATA[We take a look at Lunascape: a new browser that allows users to switch their rendering engine on the fly.]]></description>
			<content:encoded><![CDATA[<p><a title="Lunascape" href="http://www.lunascape.tv/"><img class="alignnone size-full wp-image-392" title="lunascape" src="http://www.htmlist.com/wordpress/wp-content/uploads/2008/11/lunascape.png" alt="lunascape" width="392" height="182" align="left" /></a> <a title="Lunascape" href="http://www.lunascape.tv/">Lunascape</a> is a new browser that allows you to switch rendering engines on-the-fly. Internet Explorer, Firefox, and Google Chrome/Apple Safari all use different rendering engines and JavaScript engines to display your pretty web pages to you. This is the root cause of browser incompatibility issues—different engines interpret things (like web &#8220;standards&#8221;) differently and so you see pages display differently. This is the bane of a lot of developers, as we have to fight the many, many quirks that abound when we use certain parts of the DOM or certain JavaScript or CSS tricks. For a lot more on these issues, <a title="QuirksMode" href="http://www.quirksmode.org/">QuirksMode</a> is a great resource.</p>
<p>Lunascape presents an interesting product, though one that&#8217;s only in the Alpha stage, so I&#8217;m sure we&#8217;ll be seeing a lot of things evolve from them. As a developer, I have Firefox, Internet Explorer and Google Chrome all installed and at the ready. It&#8217;s pretty simple, though a bit annoying, to boot up IE to make sure a page renders properly, even though we develop under Firefox.  (There are FF extensions that make this a simple right-click affair, however.) Lunascape simplifies the process a bit by allowing you to switch a tab&#8217;s rendering engine just with a right-click. And it works, for sure.</p>
<p>But I begin to question the utility of a browser that lets me switch rendering engines, but provides me with very few debugging tools or console access. We develop under Firefox because of things like the <a href="https://addons.mozilla.org/firefox/addon/60">Web Developer</a> extension and <a title="Firebug" href="https://addons.mozilla.org/en-US/firefox/addon/1843">Firebug</a>. These superb debugging tools let us delve into the DOM and help us identify our many AJAX transgressions. Without these tools, though, the workflow isn&#8217;t improved enough to justify a switch from just running the browsers separately.</p>
<p>Now, Lunascape currently supports IE extensions, so perhaps Firefox extension support is on the horizon&#8230; but this seems like something that could be very difficult to accomplish, given that <a title="XUL" href="http://en.wikipedia.org/wiki/XUL">XUL</a> (which powers Firefox and the window chrome surrounding it) is a part of Gecko that exists a bit existentially to the site being rendered: Though, if Lunascape itself is XUL-powered, then that would help considerably.</p>
<p>Even still, the appeal just isn&#8217;t there for me. Lunascape clearly is betting on its three-trick-pony concept, but that only appeals to developers who know what a rendering engine is. Firefox is a considerably better browsing option for regular end users, so they&#8217;re left needing to improve the value proposition for developers and to give us a reason to switch. And they haven&#8217;t done that yet. One way they could start is by offering advanced debugging tools, better if they&#8217;re rendering engine-specific. Another might be to allow for regression testing in IE: Allowing us to render in older IE engines, like how <a title="IETester" href="http://www.my-debugbar.com/wiki/IETester/HomePage">IETester</a> works.</p>
<p>For now, I plan on leaving this in the Alpha bin it came in and working with FF 3, Chrome/Safari and IE, side-by-side.</p>
<p>See also: <a href="http://www.techcrunch.com/2008/11/25/lunascape-browser-firefox-internet-explorer-and-chrome-all-in-one/trackback/">TechCrunch</a> &amp; <a href="http://lifehacker.com/5097777/lunascape-is-firefox-chrome-and-internet-explorer-rolled-into-one">Lifehacker</a>&#8216;s coverage. (The latter, whose screenshot we borrowed.)</p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=391&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/development/lunascape-multi-rendering-engine-browser-review-verdict%e2%80%94three-trick-pony/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Is PHP 5.3 Terminal?  Well, It&#8217;s Getting One For Namespaces</title>
		<link>http://www.htmlist.com/development/php-5-3-namespaces-backslashes-terminals-and-you-the-art-of-language-building/</link>
		<comments>http://www.htmlist.com/development/php-5-3-namespaces-backslashes-terminals-and-you-the-art-of-language-building/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 06:55:26 +0000</pubDate>
		<dc:creator>Edgar Hassler</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[constructs]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[namespaces]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[terminals]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=370</guid>
		<description><![CDATA[A language lives and dies by how easy it is for a person to express something within that language. But the ease in expression is much like the type I and type II error rate in a statistical test: as you adjust one to be nearer to where you want it to be, the other [...]]]></description>
			<content:encoded><![CDATA[<p>A language lives and dies by how easy it is for a person to express something within that language.  But the ease in expression is much like the <a href="http://en.wikipedia.org/wiki/Type_I_and_type_II_errors">type I and type II error rate</a> in a statistical test:  as you adjust one to be nearer to where you want it to be, the other gets farther away.  So the architects of a language have to choose between adding more keywords and constructs or having longer, but simpler sequences of existing ones.</p>
<p>PHP is a very easy language to learn and use because it has a syntax that is a simplified sampling from C++/Java and Perl.  People who use these languages pick up PHP fast, and people who haven&#8217;t used any languages often learn PHP with as much ease as they would learn Perl.</p>
<p><span id="more-370"></span></p>
<h3 id="toc-a-bit-about-namespaces">A bit about namespaces</h3>
<p>Most languages have <a href="http://en.wikipedia.org/wiki/Namespace">namespaces</a> in one form or another. A namespace is a lot like a <a href="http://en.wikipedia.org/wiki/Class_(computer_science)">class</a>: it is a named entity that houses functions and classes, whereas a class is a named entity that houses properties and methods. Namespaces are found, in one form or another, in most popular languages. In C++ there are explicit namespaces and the <code>namespace</code> keyword.   In Java, since you are allowed to have classes nested within classes, classes act as namespaces. Namespaces make it easier to organize and call your code. If you have a bunch of classes that work together to do something you might name them in a similar way. For example, we here at the <a href="http://www.synapsestudios.com/">Studios</a> sometimes use the following classes:</p>
<blockquote><p><code>Canopy_Xml_Document<br />
Canopy_Xml_Document_CDataSection<br />
Canopy_Xml_Document_NodeList<br />
Canopy_Xml_IWritable<br />
Canopy_Xml_Exception</code></p></blockquote>
<p>With namespaces, we could define a namespace <code>Canopy</code>, add to it a namespace <code>Xml</code>, and then add classes <code>Document</code>, <code>Exception</code> and interface <code>IWritable</code>. We could also add a <code>Document</code> namespace and add classes <code>CDataSection</code> and <code>NodeList</code>. Then we could just tell PHP that we want to refer to things in a certain namespace. We would simply write:</p>
<blockquote><p><code>use Canopy::Xml;<br />
$D = new Document(); //$D is equivalent to a Canopy_Xml_Document<br />
</code></p></blockquote>
<p>In the beta builds of PHP 5.3, the terminal &#8220;::&#8221; called the <a href="http://en.wikipedia.org/wiki/Scope_resolution_operator">scope resolution operator</a> (SRO) is used to denote namespaces.  So, in the same way that one would write <code>Class::staticMethod()</code> one could write <code>NamespaceA::NamespaceB::functionInNamespace()</code>.  This is the same operator used in C++, and it is intuitive since it refines a name to a scope where that name belongs.</p>
<h3 id="toc-phps-sro-problem">PHPs SRO problem</h3>
<p>Recently, PHP has had to abandon using the SRO, forego the syntax of other languages and has had to make up their own way of denoting a namespace.  One reason for this is that bare words in PHP can have multiple meanings.  For example, in PHP you can do:</p>
<blockquote><p><code>const('A','constant');<br />
function A() { return 'function'; }<br />
class A(){  public _toString(){ return 'class'; } }<br />
</code></p></blockquote>
<p>such that</p>
<blockquote><p><code>echo A;            // constant<br />
echo A();         // function<br />
echo new A();  // class<br />
</code></p></blockquote>
<p>all do what you&#8217;d expect. But in namespaces, there&#8217;s some ambiguity introduced.  Consider rather <code>A::B::C()</code> is namespace <code>A</code>, class <code>B</code>, static method <code>C</code>, or namespace <code>A::B</code>, function <code>C</code>.  In C++ you&#8217;re not allowed to have a symbol like <code>A</code>, <code>B</code>, or <code>C</code> represent multiple types of things, so using the SRO does not arrive at ambiguity there. (Instead, you get an error.) But since PHP <em>does</em> allow for that type of thing, the internals team had to choose between:</p>
<ol>
<li>Not allowing namespaces to have functions, but rather only classes, thus raising the ire of the community.</li>
<li>Using some terrible terrible other operator to indicate namespaces, thus raising the ire of the community. (Quoth internals team member: &lt;@CelloG&gt; % is also possible but holy god almighty it is fugly</li>
<li>Put off namespaces until (or if) something decent can be figured out, thus raising the ire of the community.</li>
</ol>
<p>The team decided on 2, going with the \ character.</p>
<h3 id="toc-whats-that-mean-for-the-language">What&#8217;s that mean for the language?</h3>
<p>The <a href="http://wiki.php.net/_media/rfc/php.ns.txt?id=rfc%3Anamespaceseparator&amp;cache=cache">discussion</a> was concerned with preventing unanticipated behavior from just making a rule to disambiguate rather a function or static method is called. I feel that throwing an error (or warning and choosing one) whenever that situation arises would be a perfectly acceptable solution. I would also have been happy to see them further follow Java&#8217;s lead and allow classes to be nested. Then there is no ambiguity between a static method and a function because they are the same. This would probably require much more work and you would have to allow class definitions across multiple files, but I feel this is a better option than &#8216;\&#8217;. To that end I would have enjoyed option 1 over option 2.</p>
<p>The most cited complaints about PHP is how there is little consistency in function names and in argument order. This new &#8216;\&#8217; operator adds to the &#8220;weird-factor&#8221; which makes it more difficult for people to read and use the language. It further marginalizes PHP, adding to a series of minor but obnoxious issues proponents are embarrassed by.</p>
<p>The language is adrift with little direction, trying to address the wants of its developers, and adding a terminal is payment for a lack of planning and a general stubbornness of the internals list to consider namespaces back when the 5 changes were initially being discussed.  On one hand I feel like this has ominous portents for PHP, but on the other, I&#8217;m really happy to have namespaces. For our domain, it still doesn&#8217;t make sense to jump ship to Groovy or Python, and it would take a lot of new terminals to push us over the edge. And while it&#8217;d be nice to see PHP not give more ammo to detractors, however menial, the discussion log makes it clear what issues they were struggling with.</p>
<p>Frederik Holmström <a href="http://loveandtheft.org/2008/10/26/set-sail-for-fail-php-namespaces/">points out</a> another flaw with the backslash, as well, but many commenters note that the internals team knew there was no perfect solution here.</p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=370&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/development/php-5-3-namespaces-backslashes-terminals-and-you-the-art-of-language-building/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Stack Overflow: Ask Metafilter For Programmers</title>
		<link>http://www.htmlist.com/cool-stuff/stack-overflow-ask-metafilter-for-programmers/</link>
		<comments>http://www.htmlist.com/cool-stuff/stack-overflow-ask-metafilter-for-programmers/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 00:18:56 +0000</pubDate>
		<dc:creator>Chris Cardinal</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[coding horror]]></category>
		<category><![CDATA[jeff atwood]]></category>
		<category><![CDATA[joel on softare]]></category>
		<category><![CDATA[joel spolsky]]></category>
		<category><![CDATA[programmers]]></category>
		<category><![CDATA[qanda]]></category>
		<category><![CDATA[resources]]></category>
		<category><![CDATA[stack overflow]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=349</guid>
		<description><![CDATA[Stack Overflow is a great new programming Q&#038;A web site meant to help users cut through the clutter and find the answers they need.]]></description>
			<content:encoded><![CDATA[<p><a title="Stack Overflow" href="http://www.stackoverflow.com"><img title="stackoverflow-logo-250" src="http://www.htmlist.com/wordpress/wp-content/uploads/2008/09/stackoverflow-logo-250.png" alt="Stack Overflow logo" width="250" height="70" align="left" /></a> Joel Spolsky of <a title="Joel On Software" href="http://www.joelonsoftware.com/">Joel on Software</a> (and <a title="FogBugz" href="http://www.fogcreek.com/FogBugz/">FogBugz</a>) and Jeff Atwood of <a title="Coding Horror" href="http://www.codinghorror.com/">Coding Horror</a> have teamed up to build a pretty kick-ass programmer Q&amp;A site called <a title="Stack Overflow" href="http://www.stackoverflow.com/">Stack Overflow</a>. It&#8217;s a bit like <a title="Ask Metafilter" href="http://ask.metafilter.com/">Ask Metafilter</a>, but focused entirely on programming. The site builds a unique system to help separate the useful versus the trolls: it&#8217;s based on a reputation system. The more answers you provide that are up-voted by the community, the more reputation points you accrue. The more reputation points you accrue, the more abilities are granted to you on the site. The ability to up-vote or flag-offensive is granted at 15 points, with 10 points awarded when someone up-votes you. At 2,000 points, you can delete comments.</p>
<p>The system being merit based really helps the community entirely moderate itself. Ask Metafilter (and MeFi in general) is a great community because it&#8217;s ruled by moderators who filter the signal-to-noise ratio to something entirely reasonable. But it&#8217;s simply a core group of four people, one of whom is the founder, and they were trusted to understand how things are done on MeFi. Making the community control of SO merit-based is similar in some ways to how Wikipedia is governed. The community members who clearly care the most get the most power, but in a way that should be self-policing and self-balancing.</p>
<p>Most importantly, the site&#8217;s purpose is to provide easy access to clear, concise answers to your programming-related questions, without having to subscribe or buy in or worry about the accuracy of the answers. Because the site is highly editable in that your posts can be edited by highly-enough ranked mods, we&#8217;ll hopefully see a holy grail of sorts for answers to all the very obnoxious problems we run into day in and day out.</p>
<p>Check it out:</p>
<p><a title="Stack Overflow" href="http://www.stackoverflow.com/">Stack Overflow</a></p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=349&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/cool-stuff/stack-overflow-ask-metafilter-for-programmers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hug A Developer&#8230;</title>
		<link>http://www.htmlist.com/development/hug-a-developer/</link>
		<comments>http://www.htmlist.com/development/hug-a-developer/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 01:56:41 +0000</pubDate>
		<dc:creator>Chris Cardinal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[funny]]></category>
		<category><![CDATA[hugs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=341</guid>
		<description><![CDATA[Hug a developer today. Here's why.]]></description>
			<content:encoded><![CDATA[<p>The story of our lives&#8230;</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/1lqxORnQARw&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/1lqxORnQARw&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=341&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/development/hug-a-developer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Project Management Tips from the Developer&#8217;s Point of View</title>
		<link>http://www.htmlist.com/development/project-management-tips-from-the-developers-point-of-view/</link>
		<comments>http://www.htmlist.com/development/project-management-tips-from-the-developers-point-of-view/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 23:48:37 +0000</pubDate>
		<dc:creator>Brandon Ching</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[project management]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[scrum]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[task management]]></category>
		<category><![CDATA[time management]]></category>
		<category><![CDATA[waterfall]]></category>

		<guid isPermaLink="false">http://www.htmlist.com/?p=320</guid>
		<description><![CDATA[Brandon discusses some helpful principles of project management, from the developer's point of view.]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s post is on something a bit different but still very much relevant in the web development world: project management. Now, I&#8217;m not all that old and I haven&#8217;t been a web developer for all that long (about 6 years in total, 3 actually getting paid ;-) but I have had the opportunity of working for a medium-sized media company with a development team of about 25 developers, a small 5-6 person development company (3 developers), and as an independent contractor.</p>
<p>When I began my career at the medium sized company, I initially saw my project managers as a pain in the ass. All I was interested in doing was coding. I had my own ideas of how the project or feature was going to be done and I thought that I could handle deadlines and project requirements better than they could. Was it really necessary to ask me multiple times a day what I was doing and what percentage of the project was still left to be done? PM&#8217;s gave new meaning to the phrase &#8220;avoid like the plague.&#8221; In all honesty, I wondered why in the hell these people were even hired to begin with. I just could not see the role of a project manager as being all that important.</p>
<p><span id="more-320"></span></p>
<p>Of course, after a bit of development work and experience doing projects with and without them, I found myself having moments of&#8230; &#8220;OMFG&#8230;where is my project manager?&#8221; As developers, void of project managers, we often get carried away with the art that is code. We plan for one thing but, weeks post-deadline, end up creating something entirely different. Does it work? Usually. Is it beautiful? Maybe. Is it what was promised to the customer? Well, no.</p>
<p>I&#8217;m not just talking about instances where a simple login feature ballooned into a grand hierarchical authentication scheme. I&#8217;m also talking about those projects, that for some reason or another, we just despise working on and push off completion; sometimes even writing substandard code just to get it over with. And don&#8217;t forget those projects that are just so complex that we&#8217;re not even sure if we are starting at the right place, much less dedicated to a deadline of any sort.</p>
<p>It seems that the problem here is not one of competence—most of us could, if we really tried to, stick within initial specs and scope. To me the problem lies in the fact that without the role of the project manager on the team, we lack the time and task management designed to keep us on track. We are trained in how to solve problems of logic through good coding principals and design. We are artists. Our canvas is digital and we sometimes let our creativity and desire for compounding beauty interfere with the job we were hired to do. We are not trained in restraint; the project manager is, at least in theory.</p>
<p>Depending on your experience, I suppose this next statement may be gospel or blasphemy, but to me, it is gospel all the way. The successful completion of any project hinges upon a solid development methodology based in clearly defined project goals, block specifications, complete use cases, and the division and distribution of task level development. A good project manager will be able to take high level design specs and goals from a product manager or customer contact and break them out into clearly defined and manageable building blocks. Each block can then be broken down into feature/requirement sets which can finally be tasked out to the developer/s for completion. This is the job of the project manager, not the developer. Developers should only be given spec&#8217;d out tasks with detailed use cases and an explanation of <em>exactly </em>what should be done. It is then up to the developer to determine how the task will be done.</p>
<p>Now, this is not to say that developers are not to be involved in planning or design phases of projects; by nature, they have to be. However, design and planning meetings involving developers should be focused on the technical goals of the project or block, not on management and product/customer level concerns. These meetings must be narrow in focus and should have a clearly defined result. For instance, determining the database schema for the project or settling on a development framework. The layer of abstraction here is critical in keeping the project within scope and to prevent developers from expanding on or reducing the project deliverables. Once the meeting objectives have been met, project managers should then be able to chunk and task out the technical specs to the team of developers.</p>
<p>Now, up until a little while ago, I hated the word &#8220;task.&#8221; Every morning I would check my email and see, &#8220;You have been assigned a new task from&#8230;&#8221; after which my head would sink low and I would seriously contemplate my career path yet again. I would constantly wonder why everything had to be a task: a task to change a misspelled word, a task to add 5 pixels of spacing to the end of the page. Wouldn&#8217;t it just be easier to send me an email or IM or for goodness sake, just turn around and tell me? Surely this couldn&#8217;t be the Zen that is programming? However, recent experience has taught me that, by God, we all need tasks just like we all need competent project managers!</p>
<p>Task assignment, and by extension, a good task management system (note that a task/project management system is very different from a strict bug tracking system) is an absolute necessity for project management. Proper task etiquette enabled by a solid and complete project management system serves many purposes. First and foremost to developers, it serves as our grocery list. It tells us EXACTLY what we have to do, when it needs to be done by, and contains a history of the problem or feature (most PM system tasks have comments/histories and file attachment capabilities). From the management side of things, a PM system will track the number of hours developers spend on each task which can then be used for billing or other performance metrics. It also can serve as a yardstick in determining the level of project completion by showing a variety of statistics based on ticket assignment, time used, percentage of tasks complete for a given project, and developer performance.</p>
<p>Not to sound too preachy (or take too much of an aside), but I have come across a number of good techniques gathered from the various project managers and lead developers I have worked with in the past that I would like to share and recommend that people use.</p>
<h3 id="toc-quote-tasks">Quote Tasks</h3>
<p>Make use of quote tasks. It may take a little more time and to some it may seem really useless, but in the end it will serve as a good measure of your time estimation abilities and speak to the thoroughness of your work. The way it works is that for every task you are assigned, unless fixing the problem will take less than 10 min., in the comments section you should list the files and line numbers that you will need to make changes to in addition to a brief one liner explaining the expected change. You then assign the ticket back to your project manager to quickly review. If your time estimate falls within the allowable project time, then you will get the task back and no matter how many days or weeks may pass, you will know immediately what needs to be fixed and where.</p>
<h3 id="toc-notate-completed-tasks">Notate Completed Tasks</h3>
<p>When tasks are complete, you should list each file and line number range that you made modifications to and provide a one or two sentence description of changes (in addition your regular brief outlining the totality of changes). This makes tracking changes easier for those who may follow you and serves as a written history in a developers words of exactly what was done for the task.</p>
<h3 id="toc-the-six-hour-work-day">The Six-Hour Work Day</h3>
<p>One small tip on time management and allocation I learned from my last PM was to only allot 6 hours of estimated work in a day. He said that the remaining 2 hours are spent on bathroom breaks, water cooler conversations, task switching ramp up, nerf fights, etc. At first I thought this was strange. Could bathroom breaks really take up 2 hours of my working day? But as I was tasked on this schedule, it seemed to work out pretty well. While I didn&#8217;t exactly lose 2 hours doing random things, what did happen was that I was rarely under pressure to squeeze out tasks leaving me less stressed and able to produce better quality and more thoroughly tested code and documentation. Funny thing, comparing a &#8220;6 hour&#8221; work day with the regular, &#8220;get as much work done in the 8 hours you are here&#8221; approach, I felt more productive and competent under the 6 hour routine. Give it a try, you may be surprised.</p>
<h3 id="toc-developers-as-project-managers-warning">Developers as Project Managers: Warning</h3>
<p>Developers should never be placed in the role of a project manager; creating and managing their own tasks. However, sometimes there is little choice (little company resources, sole operation, etc). If this is the case, expect that as a developer you will be spending probably 1/4-1/3 of your day planning and managing tasks; <em>not</em> working on them. Be sure your boss knows this if they are not willing or able to task out projects properly to begin with. This is really for your sanity and for the thoroughness that comes with being a competent developer. Now, in the rare case where you as the developer are tasked with actually taking customer specs and being told to simply get it done, placing the entire development life cycle on you or your team&#8217;s shoulders, I strongly suggest that you ask management to hire a project manager. If that is not possible then maybe you should be dusting off that resume because project specing, chunking, and higher level project management duties like those are not your job. There is a good reason developers are not PM&#8217;s and PM&#8217;s are not developers.</p>
<h3 id="toc-the-devils-in-the-details">The Devil&#8217;s in the Details</h3>
<p>Nag, nag, nag. If you get assigned tasks that are too general in scope and you have any questions about exactly what it is that your PM or boss is asking for, send the ticket back and ask for further explanation. It usually only takes a few times doing this for your boss to get the idea of what information you need to get your work done right. Remember, training goes both ways; you learn from your boss as much as your boss learns from you. It&#8217;s better to take the time upfront and get accurate and detailed specs than for you to guess and have to go back and rewrite something down the road.</p>
<p>All that being said, there are a number of development methodologies out there to help you and your team develop software in an efficient and smart manner. Now, as I&#8217;ve made crystal clear, I&#8217;m not a PM so I don&#8217;t claim to be an expert on any development methodology, but I take particular affinity to <a href="http://en.wikipedia.org/wiki/Agile_software_development" target="_blank">Agile</a> development methods like <a href="http://en.wikipedia.org/wiki/SCRUM" target="_blank">Scrum</a>. Any methodology where you as a developer are protected from business processes (changes in specs/customer expectations, etc) external to your core job function is a winner in my book. Avoid the traditional <a href="http://en.wikipedia.org/wiki/Waterfall_model" target="_blank">waterfall</a> and <a href="http://en.wikipedia.org/wiki/Cowboy_coding" target="_blank">cowboy</a> coding approaches as they are highly inflexible and in the former case, plain stupid as a development methodology for any business.</p>
<p>So there! I hope I&#8217;ve been able to give a little personal experience to you developers out there (and you managers) who may be a little too code-centric. Don&#8217;t ignore the management side of your business. It can save your sanity and make you a better developer in the process!</p>
<img src="http://www.htmlist.com/wordpress/?ak_action=api_record_view&id=320&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.htmlist.com/development/project-management-tips-from-the-developers-point-of-view/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

