<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Agile software development using Kanban &amp; Scrum. We code Flex &amp; Ruby on Rails in Auckland, New Zealand.</description><title>vWork Development</title><generator>Tumblr (3.0; @vworkdev)</generator><link>http://devblog.vworkapp.com/</link><item><title>Builder pattern is so easy in Robotlegs</title><description>&lt;p&gt;The &lt;a href="http://en.wikipedia.org/wiki/Builder_pattern"&gt;Builder Pattern&lt;/a&gt; is a breeze in &lt;a href="http://www.robotlegs.org"&gt;Robotlegs&lt;/a&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class ConcreteWidgetBuilder implements IWidgetBuilder {

  [Inject]
  public var injector:IInjector;

  public function buildPart(parameterised:IThing):IWidget {
    var widget:IWidget = injector.getInstance(IWidget);
    widget.param = parameterised;

    return widget;
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Parameterized builder&lt;/h2&gt;

&lt;p&gt;If you want to control what gets instanced based on a parameter:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class ConcreteWidgetBuilder implements IWidgetBuilder {

  [Inject]
  public var injector:IInjector;

  public function buildPart(parameterised:IThing):IWidget {
    var interface:Class;

    switch(parameterised.style) {
      case ThingConst.COOL:
        interface = ICoolWidget;
        break;
      case ThingConst.HOT:
        interface = IHotWidget;
        break;
      default:
        interface = IDefaultWidget;
    }

    var widget:IWidget = injector.getInstance(interface);
    widget.param = parameterised;

    return widget;
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Bit freakin’ &lt;strong&gt;sexy&lt;/strong&gt; if you ask me.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/1007347267</link><guid>http://devblog.vworkapp.com/post/1007347267</guid><pubDate>Wed, 25 Aug 2010 17:16:34 +1200</pubDate><category>flex</category><category>robotlegs</category><category>builder</category><category>factory</category></item><item><title>Visfleet's Radiator (v 0.0.1)</title><description>&lt;p&gt;I started a project not too long ago to implement an information radiator here at Visfleet. The first milestone has been reached: &lt;strong&gt;Show the status of important Hudson builds&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And here it is:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_l6ydxupDDy1qzzubq.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://bit.ly/9iAvzA"&gt;The source is on github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I started out with the intention of using Flex 4 skinning to make a &lt;a href="http://www.panic.com/blog/2010/03/the-panic-status-board/"&gt;super-modern, slick looking radiator like Panic’s&lt;/a&gt;. But somewhere along the way I ended up with a two tone border, it reminded me of my Commodore days, and the rest is ugly :)&lt;/p&gt;

&lt;p&gt;Near term plans include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Show C64 raster bars around building jobs&lt;/li&gt;
&lt;li&gt;Use a horrible blink to highlight broken builds&lt;/li&gt;
&lt;li&gt;Show who has claimed a build&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Show which of our feature build servers has been claimed for a feature branch.&lt;/li&gt;
&lt;li&gt;Show our twitter feed.&lt;/li&gt;
&lt;li&gt;Get a much bigger screen.&lt;/li&gt;
&lt;/ul&gt;</description><link>http://devblog.vworkapp.com/post/933364562</link><guid>http://devblog.vworkapp.com/post/933364562</guid><pubDate>Wed, 11 Aug 2010 08:24:35 +1200</pubDate><category>CI</category><category>Continuous Integration</category><category>Hudson</category><category>Flex</category><category>Radiator</category></item><item><title>Best practice for Ruby's require </title><description>&lt;p&gt;Ruby’s &lt;em&gt;require&lt;/em&gt; method gives you more than enough rope to hang yourself. Having now implemented too many projects with too many different approaches to using &lt;em&gt;require&lt;/em&gt;, we thought it was worth writing down the conclusions we’ve come to.&lt;/p&gt;

&lt;p&gt;We’ve gleaned most of our knowledge from these two articles, &lt;a href="http://chneukirchen.github.com/rps/"&gt;here&lt;/a&gt;, and &lt;a href="http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices"&gt;here&lt;/a&gt;. So a big thank you to their authors.&lt;/p&gt;

&lt;h3&gt;How to require&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; use requires that are relative to ruby’s load path.&lt;/p&gt;

&lt;p&gt;For example,&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require 'my_project/b/c'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This assumesthat a directory containing the &lt;em&gt;my_project&lt;/em&gt; directory is already in Ruby’s load_path (typically your project’s &lt;em&gt;lib&lt;/em&gt; folder). It should be — more on this below.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Don’t&lt;/strong&gt; use requires that are relative to the file.&lt;/p&gt;

&lt;p&gt;For example, avoid:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require File.join(File.dirname(__FILE__), "foo", "bar")
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Require decides if a file has already been loaded based on the unexpanded path it’s given. Two different relative paths are treated as two different files, so will be loaded twice. Moreover, it’s just yuky. If I want to figure which file a class is defined in, then I shouldn’t have to navigate a tangled web of file references.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Don’t&lt;/strong&gt; require rubygems in your code.&lt;/p&gt;

&lt;p&gt;It’s rude, not everyone wants to use Rubygems. If you want to use it then run&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ruby -rubygems my_file.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;OR use the following environment variable&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;RUBYOPT="rubygems"
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Don’t&lt;/strong&gt; manipulate ruby’s load path in your code.&lt;/p&gt;

&lt;p&gt;Gem will always add your project’s &lt;em&gt;lib&lt;/em&gt; directory to ruby’s load path. However, if your running an executable directly from your project (i.e. in your &lt;em&gt;bin&lt;/em&gt; directory), or you’re running a set of units tests, then you’ll need to add your &lt;em&gt;lib&lt;/em&gt; folder to ruby’s load path. There are a few ways to do this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Add this line to the top of your executable (contradicts what I just said, but at least in a consistent way).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Or run Ruby like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ruby -Ilib my_test_runner
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Or set this shell environment variable:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;export RUBYOPT=Ilib
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Structuring your project&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; use underscores as a separator in your project’s name.&lt;/p&gt;

&lt;p&gt;No spaces, dashes, or camel case. Most ruby gems follow this convention, so best not to surprise people.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; create a sub-directory under /lib with the same name as your project. And stick all your ruby files under this.&lt;/p&gt;

&lt;p&gt;This is important if you want to package your project up as a Gem at some stage. The contents of every gem’s lib directory installed on your system automatically gets included in ruby’s $LOAD_PATH. Sticking all your code files directly in your &lt;em&gt;lib&lt;/em&gt; is asking for same filename collisions. Even if you’re not going to package your project as a gem, it pays to follow this rule for consistency reasons.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; create a file within your lib directory that is responsible for requiring in your other project files.&lt;/p&gt;

&lt;p&gt;This is really an extension of the above. If you’ve nested all your code files in a project directory, then you need a single code file that is responsible for loading them all. For example, your lib fold should look like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;lib/my_project.rb
lib/my_project/
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; make your class namespaces correspond to your directory structure.&lt;/p&gt;

&lt;p&gt;Your classes should be within modules that match the directory structure. This way you’re keeping your code namespace consistant with your directory namespace, making it easier to find things. For example, any ruby files in &lt;em&gt;foo/bar&lt;/em&gt; should also be in a module &lt;em&gt;Foo::Bar&lt;/em&gt;. More importantly, you’re reducing the risk of namespace collision from other libraries.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Dealing with executables&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; stick your executables in /bin. This is the default location where Gem will install executables from. You can change it, but you shouldn’t unless you have a good reason to.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don’t&lt;/strong&gt; use a suffix on your executables (i.e. no .rb). If you’re providing an executable to be run from the shell, then it should work like any other executable (i.e not have a .rb appended at the end).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; use the following shebang line at the top of your ruby code to make it into an executable.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env ruby
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Guiding principle&lt;/h2&gt;

&lt;p&gt;If the above were boiled down to a single principle, it would be this:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Treat &lt;em&gt;require&lt;/em&gt; like it’s requiring a namespace, and not a file. This is much the same as how &lt;em&gt;import&lt;/em&gt;, and &lt;em&gt;using&lt;/em&gt;, work in languages such as &gt;C#, C++, and Java.&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://devblog.vworkapp.com/post/910714976</link><guid>http://devblog.vworkapp.com/post/910714976</guid><pubDate>Fri, 06 Aug 2010 15:19:00 +1200</pubDate><category>ruby</category><category>require</category></item><item><title>Another performance tool for AS3</title><description>&lt;a href="http://www.lostinactionscript.com/blog/index.php/2008/10/06/as3-swf-profiler/"&gt;Another performance tool for AS3&lt;/a&gt;</description><link>http://devblog.vworkapp.com/post/840299542</link><guid>http://devblog.vworkapp.com/post/840299542</guid><pubDate>Wed, 21 Jul 2010 22:33:15 +1200</pubDate></item><item><title>Elad's performance monitoring tool for flash</title><description>&lt;a href="http://elromdesign.com/blog/2010/07/20/performance-monitor-tool-to-watch-internal-of-the-flash-player-during-runtime/"&gt;Elad's performance monitoring tool for flash&lt;/a&gt;</description><link>http://devblog.vworkapp.com/post/840294211</link><guid>http://devblog.vworkapp.com/post/840294211</guid><pubDate>Wed, 21 Jul 2010 22:31:00 +1200</pubDate></item><item><title>Mediating ItemRenderers, Again.</title><description>&lt;p&gt;I’ve &lt;a href="http://devblog.vworkapp.com/post/397017548/mediating-itemrenderers"&gt;posted about this before&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I still have no shame about mediating ItemRenderers and to my happy suprise, Flex 4 makes it simpler with the spark.ItemRenderer and its dataChange event.&lt;/p&gt;

&lt;p&gt;Here’s my base prescription in sample form:&lt;/p&gt;

&lt;script src="http://gist.github.com/479231.js?file=JobCard.mxml"&gt;&lt;/script&gt;&lt;script src="http://gist.github.com/479231.js?file=JobCardMediator.as"&gt;&lt;/script&gt;&lt;p&gt;Now you and I both know it can be a lot simpler to achieve the same, namely:&lt;/p&gt;

&lt;script src="http://gist.github.com/479231.js?file=UnmediatedJobCard.mxml"&gt;&lt;/script&gt;&lt;p&gt;Why mediate, it’s so simple? Well the reason is simple too. Things never stay simple. My prescription is a easy template for me to follow, its already second nature for me to do it that way.&lt;/p&gt;

&lt;p&gt;The moment I need to mix selection state (or multiple models) into a single renderer, my mediator is there waiting. This includes ensuring that no matter what data source is generating the itemRenderer, I have a templated method for locating the correct model (hence the comment in my mediator above).&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/822228597</link><guid>http://devblog.vworkapp.com/post/822228597</guid><pubDate>Sat, 17 Jul 2010 16:23:56 +1200</pubDate><category>robotlegs</category><category>flex 4</category></item><item><title>Postgres routine (and not so routine) maintenance</title><description>&lt;p&gt;Postgres is our DB of choice. We run all our vTrack and vWork systems on it.
We have lately been developing data archiving and culling strategies to manage data growth and disk consumption.&lt;/p&gt;

&lt;p&gt;I’ve found a few hints that are best shared.&lt;/p&gt;

&lt;h2&gt;Culling Old Data to Recover Disk Space&lt;/h2&gt;

&lt;p&gt;The initial thought is to perform a quick delete of the old data, a-la:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;DELETE FROM table1 where date &lt; [some date in the past]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Nothing wrong with that. However, it doesn’t recover any disk space. The natural instinct is to follow it with a vacuum:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;VACUUM VERBOSE ANALYZE table1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I like to throw verbose and analyze in there too. But doh, this doesn’t recover any disk space either, it just marks the space used by the deleted as free, making it available for new data later.&lt;/p&gt;

&lt;p&gt;Which leads to &lt;a href="http://www.postgresql.org/docs/8.3/static/sql-vacuum.html"&gt;what the Postgres manual&lt;/a&gt; says about the subject:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The FULL option is not recommended for routine use, but might be useful in special cases. An example is when you have deleted or updated most of the rows in a table and would like the table to physically shrink to occupy less disk space and allow faster table scans. VACUUM FULL will usually shrink the table more than a plain VACUUM would.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ok, let’s do a VACUUM FULL then:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;VACUUM FULL VERBOSE ANALYZE table1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Good; Yay; finally some improvement. But that took bloody ages on the massive table that I just removed a bazillion rows from.&lt;/p&gt;

&lt;p&gt;So, we devised a cunning plan, loosely based on what &lt;a href="http://www.postgresql.org/docs/8.3/static/routine-vacuuming.html"&gt;another page in the Postgres manual&lt;/a&gt; says about recovering disk space. In the manual it says you should perform a TRUNCATE on the table if you want to clean it up quickly, which got me thinking. Instead maybe we should just copy all of the keep-able data into a new table and blow away the old one (along with all the cull-able data).&lt;/p&gt;

&lt;p&gt;In it’s basic form:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;CREATE TABLE table1new
SELECT * INTO table1new FROM table1 WHERE date &gt;= [some date in the past]
DROP TABLE table1
ALTER TABLE table1new RENAME TO table1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Because SELECT INTO doesn’t bring across any of the table meta-data, we then put the correct restrictions on the columns manually:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ALTER TABLE table1 ALTER COLUMN column2 SET NOT NULL
ALTER TABLE table1 ALTER COLUMN column3 SET NOT NULL
....
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;… recreate primary keys and indexes:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ALTER TABLE table1 ADD CONSTRAINT table1_pkey PRIMARY KEY(column1)")
CREATE UNIQUE INDEX index_table1_on_column2_and_column3 ON table1 USING btree (column2, column3)
....
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;… find out the max integer for sequence re-creation. A bit of psuedo code here, depends on your scripting language (we wrap all this stuff around Ruby/Rails and ActiveRecord):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;max_id = SELECT max(column1) FROM table1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then re-create the sequence:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;CREATE SEQUENCE table_column1_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START #{max_id+1} CACHE 1 OWNED BY table1.column1")
ALTER TABLE table1 ALTER COLUMN column1 SET DEFAULT nextval('table1_column1_seq'::regclass)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;All of this work just to save some disk space? Not to mention the fact that you are dropping a table, which has some risk to it - especially if everything breaks half way through through the process.&lt;/p&gt;

&lt;p&gt;It sounds scary and seems like quite a lot of work, but the elapsed run time difference is pretty huge.&lt;/p&gt;

&lt;p&gt;When doing a DELETE FROM followed by a VACUUM FULL, our test system took 130 seconds. In comparison, doing a CREATE TABLE, SELECT INTO, DROP TABLE and RENAME takes around 45 seconds. This is on a very small table (2M rows) by our standards.&lt;/p&gt;

&lt;p&gt;Another difference between the two methods is that the first method keeps the table available for reads. Writes will be locked out because a VACUUM FULL takes out an exclusive lock on the table. The second method drops the table entirely, so an outage would be required for any services or daemons which are accessing that table.&lt;/p&gt;

&lt;p&gt;If you think about it some more though, the fact that you are having to cull data out of the table means that it is probably a write-heavy table. This indicates that an outage would have been necessary anyway, to perform a VACUUM FULL. Given this, you might as well perform the faster (albeit more complicated) form of the cull.&lt;/p&gt;

&lt;h2&gt;A final note about VACUUM FULL and indexes&lt;/h2&gt;

&lt;p&gt;I also stumbled upon another little gem while seeing just how much disk we could save. If you do a VACUUM FULL it doesn’t also hoover the indexes.&lt;/p&gt;

&lt;p&gt;Quote, from &lt;a href="http://www.postgresql.org/docs/8.3/static/sql-vacuum.html"&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The FULL option does not shrink indexes; a periodic REINDEX is still recommended. In fact, it is often faster to drop all indexes, VACUUM FULL, and recreate the indexes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Pretty much says it all really. And it brings me back to the previous section about copying the data into a new table, and re-creating the indexes from scratch.&lt;/p&gt;

&lt;p&gt;If you want to save a few MB without being scary however, &lt;a href="http://www.postgresql.org/docs/8.3/static/sql-reindex.html"&gt;a REINDEX&lt;/a&gt; might be a good command to keep in mind.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/709903598</link><guid>http://devblog.vworkapp.com/post/709903598</guid><pubDate>Fri, 18 Jun 2010 14:03:04 +1200</pubDate></item><item><title>Useful Rules and Guidelines</title><description>&lt;p&gt;In our complex lives, rules and guidelines help us avoid rethinking everything that crosses our paths. Rules are the outcomes of pattern recognition.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;We recognise repeating or similar stimulus in the world, and our ‘understanding’ of these stimuli is a “rule”.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I’m not quoting anyone here, and I may be oversimplifying the case, but I think this is a reasonable statement. Recognise: Drop a ball, it falls to the ground. The rule: releasing a ball causes it to fall toward the ground.&lt;/p&gt;

&lt;p&gt;As programmers, there are a lot of rules to follow. Thankfully. Otherwise every line of code would be the realisation of hours of complex reassessment of stimuli (variables, requirements, other code..)&lt;/p&gt;

&lt;p&gt;However when you discover, or are given, a rule to follow, it may not be “useful”. Hopefully at your disposal, you have the reasoning for the rule, but that can still leave you with more questions than answers. I’m talking about best practices here. If you want people to follow rules, you had better make it easy for them to identify wether they are applying the rules consistently.&lt;/p&gt;

&lt;h2&gt;A Rule&lt;/h2&gt;

&lt;p&gt;In &lt;a href="http://blog.objectmentor.com/articles/2008/04/08/clean-code-whew"&gt;Clean Code&lt;/a&gt;, Uncle Bob wrote:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The following advice has appeared in one form or another for 30 years or more.
  FUNCTIONS SHOULD DO ONE THING. THEY SHOULD DO IT WELL.
  THEY SHOULD DO IT ONLY.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;The Reasoning&lt;/h2&gt;

&lt;p&gt;There are a lot of reasons to follow this rule. The first one that comes to mind:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Any unit of code that does only one thing is easier to comprehend when revisiting it in the future.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s good enough reason for me, but the rule still isn’t useful. And with a great deal of consideration to his readers, Uncle Bob continues with the “useful” part.&lt;/p&gt;

&lt;h2&gt;The useful rule&lt;/h2&gt;

&lt;p&gt;(Or, how to apply the rule.)&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;TO RenderPageWithSetupsAndTeardowns, we check to see whether the page is a test page and if so, we include the setups and teardowns. In either case we render the page in HTML.&lt;/em&gt;&lt;/p&gt;
  
  &lt;p&gt;If a function does only those steps that are one level below the stated name of the function, then the function is doing one thing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is so awesome. The ‘TO’, he advises us, is from LOGO, and is simply the syntax to introduce a method in that language. But I see this as a &lt;em&gt;clue&lt;/em&gt;.&lt;/p&gt;

&lt;h1&gt;Clues&lt;/h1&gt;

&lt;p&gt;Clues remind us how to check if a rule is properly applied. Clues direct us into the mode of thought that originally recognised the pattern to which the rule applies. Perhaps clue’s are unit tests for rules.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.dannorth.net/introducing-bdd/"&gt;Dan North, in his BDD article&lt;/a&gt; uses clues to remind us how to establish a good “User Story” and “Acceptance Criteria”. In fact his clues are so good that I quickly forget the rules and reasoning for user stories and acceptance criteria, and just find myself enjoying the use of the clues.&lt;/p&gt;

&lt;p&gt;Writing a user story is a breeze now. I write down:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;As a&lt;/p&gt;
  
  &lt;p&gt;I want&lt;/p&gt;
  
  &lt;p&gt;So that&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I spend very little time now thinking about the complexity of my user story, instead I’m compelled to keep it simple and provide the three most important bits of information:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Who wants it,&lt;/p&gt;
  
  &lt;p&gt;What do they want,&lt;/p&gt;
  
  &lt;p&gt;To what end?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;In closing&lt;/h2&gt;

&lt;p&gt;Why did I mention any of this? Because I assume people who bother to read our blog are either looking for inspiration to improve their own code, or want to help mentor others.&lt;/p&gt;

&lt;p&gt;For the inspiration-seeking, look for people who give you more than rules and reasoning, but also give you mechanisms to ease the application of them.&lt;/p&gt;

&lt;p&gt;For the educator, provide clues, help others find it easy to apply your rules. The rules should make their life easier, but they’re not enough on their own.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/661744165</link><guid>http://devblog.vworkapp.com/post/661744165</guid><pubDate>Fri, 04 Jun 2010 13:50:08 +1200</pubDate><category>Clean Code</category><category>Crafted Code</category><category>Uncle Bob</category></item><item><title>Ascending the Ivory Tower is good for everyone.</title><description>&lt;p&gt;I attended the &lt;a href="http://blog.flashandthecity.com/"&gt;Flash And The City&lt;/a&gt; conference last week. It was an amazing experience and I met some of my personal &lt;strong&gt;Heroes&lt;/strong&gt;. People who make the effort to popularise good software, good design, good tools, and good practices.&lt;/p&gt;

&lt;p&gt;Sometimes I don’t see eye to eye with them, but I still respect anyone who puts themselves out there to be criticised so willingly :)&lt;/p&gt;

&lt;p&gt;Funnily, a term started re-appearing that I haven’t had applied to my opinions (or the opinions of those I hold in highest regard) in a long while:&lt;/p&gt;

&lt;h2&gt;Ivory Tower&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Ivory_Tower"&gt;Ivory Tower&lt;/a&gt; connotes a place that’s unattainable. It’s being used regularly in the pejorative when discussing best practices for business, development teams and coding standards.&lt;/p&gt;

&lt;p&gt;Now when I started using Object Oriented concepts like message passing, way back in the day, with Flash 4 and Flash 5, the same Ivory-Tower term was often bandied about by hackers and traditional linear programmers. It was often purported that things like Message Passing, Encapsulation and Polymorphism were too hard to understand and ill-suited to the day to day Flash developers’ work.&lt;/p&gt;

&lt;p&gt;In 2000 I presented at the Sydney FlashKit Conference in an attempt to promote Flash as an RIA platform, all we needed was better coding practices. It was an uphill battle, I was asking people to climb an “Ivory Tower”. I was by no means a purist. I still don’t think I’m a purist.&lt;/p&gt;

&lt;p&gt;So I will mix the Ivory Tower metaphor with the climb Mt Everest Metaphor somewhat from here. I think there is a surmountable slope to lofty standards of Agile and Best Practices.&lt;/p&gt;

&lt;h2&gt;Purists&lt;/h2&gt;

&lt;p&gt;A purist is someone who attains the summit and pretends they’ve never had to do a day of climbing in their life. A purist wonders, condescendingly, how you could possibly do things any other way. A purist doesn’t care for outside pressures. This kind of elitism can only be found in people who aren’t pressured into making pragmatic choices.&lt;/p&gt;

&lt;h2&gt;Pragmatism&lt;/h2&gt;

&lt;p&gt;Pragmatism &lt;em&gt;does not mean&lt;/em&gt; “embrace the status-quo”. It means when achieving your goals, you recognise the path to attain them and the alternatives, especially the alternatives that bring everyone else to the summit. You will chose alternatives that let you reach important waypoints during your ascent.&lt;/p&gt;

&lt;p&gt;Pragmatism can be applied to your singular ascent, your current team’s ascent, and everyone else’s ascent.&lt;/p&gt;

&lt;h2&gt;Our experiences&lt;/h2&gt;

&lt;p&gt;2 Years ago we set out to become an Agile development team that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Had continuous integration&lt;/li&gt;
&lt;li&gt;Automated, repeatable deploys&lt;/li&gt;
&lt;li&gt;Encapsulated documentation (Knowledge stored in the same place it needed to be applied)&lt;/li&gt;
&lt;li&gt;Automated Test and Behaviour driven development&lt;/li&gt;
&lt;li&gt;Automated Integration testing&lt;/li&gt;
&lt;li&gt;Clean consistent code&lt;/li&gt;
&lt;li&gt;Software with a great user experience&lt;/li&gt;
&lt;li&gt;Frequent delivery of improvements. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That was out lofty peak. We’re still not there, however I would say that we are in sight of our first peak. We got this far not by being purists, but by being &lt;strong&gt;pragmatists&lt;/strong&gt;. Once we are upon the summit, we’ll look for something taller I am sure :)&lt;/p&gt;

&lt;h2&gt;Micro-architectures&lt;/h2&gt;

&lt;p&gt;Micro-architectures and small prescriptions are a fantastic tool for the worthy climber.&lt;/p&gt;

&lt;p&gt;These are both lightweight prescriptions (easy to follow) that have massive impact:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.robotlegs.org/"&gt;Robotlegs&lt;/a&gt; gives you the Single Responsibility Concept, Code by Contract, Testable code etc.&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.kanbancam.com"&gt;Kanban&lt;/a&gt; gives you focused work-in-process, release-often, faster feedback etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I consider them both important tools for this ascent, others are &lt;a href="http://hudson-ci.org/"&gt;Hudson CI&lt;/a&gt;, &lt;a href="http://flexunit.org/"&gt;FlexUnit&lt;/a&gt;, &lt;a href="http://cukes.info/"&gt;Cucumber&lt;/a&gt; and many many more.&lt;/p&gt;

&lt;h2&gt;In closing&lt;/h2&gt;

&lt;p&gt;So my only argument with some of my heroes who proclaim “Ivory Tower” is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“It’s not healthy to denigrate these attainable best practices”&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With the greatest respect, I ask that we speak instead in the following terms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Find valid, workable stops along the way, and good reasons, not excuses, for stopping short of the summit&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It has a more positive air to it, and it doesn’t devalue the amazing, and often freely given, efforts of the Mountain Climbing Specialists whom I think deserve slightly more respect.&lt;/p&gt;

&lt;p&gt;Hmmm… and  those of us who like to think of ourselves as Mountain Climbing Specialists could work harder to be humble. Not to make a stink so often just because someone cut a corner we wouldn’t have.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/618069675</link><guid>http://devblog.vworkapp.com/post/618069675</guid><pubDate>Fri, 21 May 2010 15:33:00 +1200</pubDate><category>Best Practices</category><category>TDD</category><category>BDD</category><category>Agile</category><category>Kanban</category><category>Robotlegs</category></item><item><title>RSpec Style Unit Testing with FlexUnit4</title><description>&lt;p&gt;We’re still early into our TDD for Flex program, and I am trying to learn “how” to write useful tests while not getting bogged down in any extremes, at least not until I understand it better.&lt;/p&gt;

&lt;p&gt;I asked our CTO who is an accomplished ruby developer to guide and mentor me a little. He prefers to use &lt;a href="http://rspec.info/"&gt;RSpec&lt;/a&gt; for Ruby development. RSpec is designed for “Behaviour Driven Development” which &lt;a href="http://blog.dannorth.net/introducing-bdd/"&gt;Dan North introduces in a compelling way here&lt;/a&gt;. However it’s not clear at first glance why RSpec fits with Dan’s “Acceptance Criteria” template. (Cucumber)[http://cukes.info/] on the other hand, fits really well, but there is nothing even close to Cucumber for Flex that I can see.&lt;/p&gt;

&lt;p&gt;Meanwhile, I needed something applicable and that guided me into my first tests, so I tried to adopt the &lt;a href="http://en.wikipedia.org/wiki/Domain-specific_language"&gt;DSL&lt;/a&gt; that RSpec uses. I think I’ve done an adequate job and I found it &lt;em&gt;really&lt;/em&gt; helpful and inspiring. This article outlines what I do.&lt;/p&gt;

&lt;p&gt;I am using real-world code throughout these samples. &lt;a href="http://github.com/drewbourne/mockolate"&gt;Mockolate&lt;/a&gt; is my mocking framework of choice here because it just works with FlexUnit4. &lt;a href="http://bitbucket.org/loomis/mockito-flex/wiki/Home"&gt;Mockito&lt;/a&gt; also looks great but it’s integration with FlexUnit isn’t quite what I’d hope for.&lt;/p&gt;

&lt;h2&gt;Create a Case (Context)&lt;/h2&gt;

&lt;p&gt;The test case to me, represents the context of “how the unit (class) under test will be configured for testing”. There are sub-contexts which I’ll get to in a moment.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class ProxyListCase {

  private var proxyList:ProxyList;

  private var configurator:IProxyConfigurator;

  [Before(order=1,async, timeout=5000)]
  public function prepareMockolates():void {  
        Async.proceedOnEvent(this, prepare(IProxyConfigurator,VOProxy), Event.COMPLETE);
  }

  [Before(order=2)]
  public function setup():void {
    proxyList = new ProxyList();

    configurator = nice(IProxyConfigurator);
    proxyList.proxyConfigurator = configurator;
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the first “Before” section I pre-initialise Mockolate. In the second, I set up the context.&lt;/p&gt;

&lt;p&gt;The context for &lt;em&gt;ProxyList&lt;/em&gt; is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;That we have a &lt;em&gt;ProxyList&lt;/em&gt; instance to test&lt;/li&gt;
&lt;li&gt;That &lt;em&gt;ProxyList&lt;/em&gt; is configured with required injections for testing anything, in this case, &lt;em&gt;configurator&lt;/em&gt; is required.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Stubbing the Test&lt;/h2&gt;

&lt;p&gt;My first test, if I were to write it down, is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;given
  a simple VO
  a Proxy
then
  it builds a proxy on add
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which I deftly code as:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  [Test(given="a simple VO and a Proxy",
    it="builds a proxy on add")]
  public function ItBuildsAProxyOnAdd():void {
    fail();
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The metadata for the Test doesn’t “mean” anything to FlexUnit. However it can be pulled out by a custom runner on your CI server if you so wish. What it does tho, is gives you, and the next person to read the test, a very clear understanding of the test’s intent. It also lets you mark your sub-contexts in &lt;strong&gt;given&lt;/strong&gt;. Let me show you how.&lt;/p&gt;

&lt;h2&gt;Sub-contexts (Givens)&lt;/h2&gt;

&lt;p&gt;First I translate the givens into &lt;em&gt;with&lt;HelperMethods&gt;&lt;/em&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  [Test(given="a simple VO and a Proxy",
    it="builds a proxy on add")]
  public function ItBuildsAProxyOnAdd():void {
    withSimpleVO();
    withProxy();

    fail();
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I then implement these new ‘givens’&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  public function withProxy():void {
    proxy = nice(VOProxy);
    stub(factory).method("newInstance").returns(proxy);
  }

  private function withSimpleVO():void {
    newVO = {name: "hi"};
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;These given’s get re-used a lot. As you refactor your tests you get a much clearer idea of what your assumptions about prerequisites are.&lt;/p&gt;

&lt;h2&gt;Do something and make assertions&lt;/h2&gt;

&lt;p&gt;Now for the simple bit, the test. This should read very clearly from the &lt;em&gt;it&lt;/em&gt; metadata. In this case, remember: “it builds a proxy on add”&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  [Test(given="a simple VO and a Proxy",
    it="builds a proxy on add")]
  public function ItBuildsAProxyOnAdd():void {
    withSimpleVO();
    withProxy();

    proxyList.add(newVO);

    verify(factory).method("newInstance").once();
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So we &lt;em&gt;added&lt;/em&gt; using a prerequisite &lt;em&gt;newVO&lt;/em&gt; and then we verified that the factory was asked to build a proxy.&lt;/p&gt;

&lt;p&gt;I don’t think I can make a test clearer than that. Any thoughts?&lt;/p&gt;

&lt;p&gt;Heres the whole class with a few tests, it’s a little different but you get the idea.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class ProxyListCase {
  private static const PROXY_DISPOSE:String = "dispose";
  private static const CONFIGURATOR_BUILD:String = "configure";

  private var proxy:VOProxy;
  private var proxyList:ProxyList;
  private var configurator:IProxyConfigurator;
  private var newVO:Object;

  [Before(order=1,async, timeout=5000)]
  public function prepareMockolates():void {  
        Async.proceedOnEvent(this, prepare(IProxyConfigurator,VOProxy), Event.COMPLETE);
  }


  [Before(order=2)]
  public function setup():void {
    proxyList = new ProxyList();

    configurator = nice(IProxyConfigurator);

    proxyList.proxyConfigurator = configurator;
  }


  [Test(given="a simple VO and a Proxy",
    it="builds a proxy on add")]
  public function ItBuildsAProxyOnAdd():void {
    withSimpleVO();
    withProxy();

    proxyList.add(newVO);

    verify(configurator).method(CONFIGURATOR_BUILD).once();
  }


  [Test(given="a Proxy, and one VO added",
    it="disposes the proxy on remove")]
  public function ItDisposesTheProxyOnRemove():void {
    withSimpleVO();
    withProxy();
    withOneVOAdded();

    proxyList.remove(newVO);

    verify(proxy).method(PROXY_DISPOSE).once();
  }

  [Test(given="a Proxy, and one VO added-removed-readded",
    it="builds a proxy on re-add")]
  public function ItBuildsAProxyOnReadd():void {
    withSimpleVO();
    withProxy();
    withOneVOReAdded();

    verify(configurator).method(CONFIGURATOR_BUILD).twice();
  }


  [Test(given="a Proxy and an added VO",
    it="disposes the proxy on dispose")]
  public function ItDisposesTheProxyOnReset():void {
    withSimpleVO();
    withProxy();
    withOneVOAdded();

    proxyList.dispose();

    verify(proxy).method(PROXY_DISPOSE).once();
  }


  /* Sub Contexts */

  private function withSimpleVO():void {
    newVO = {name: "hi"};
  }

  public function withProxy():void {
    proxy = nice(VOProxy);
    stub(configurator).method(CONFIGURATOR_BUILD).returns(proxy);
  }

  private function withOneVOAdded():void {
    proxyList.add(newVO);
  }

  private function withOneVOReAdded():void {
    proxyList.add(newVO);
    proxyList.remove(newVO);
    proxyList.add(newVO);
  }

}
&lt;/code&gt;&lt;/pre&gt;</description><link>http://devblog.vworkapp.com/post/587427689</link><guid>http://devblog.vworkapp.com/post/587427689</guid><pubDate>Tue, 11 May 2010 07:08:11 +1200</pubDate><category>flexunit</category><category>flexunit4</category><category>rspec</category><category>unit test</category></item><item><title>StickyNotes in Windows 7 make good CRC cards (if you don’t...</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_l1yuf8W4sO1qzm7loo1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;StickyNotes in Windows 7 make good CRC cards (if you don’t use them as sticky notes)&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/574359864</link><guid>http://devblog.vworkapp.com/post/574359864</guid><pubDate>Thu, 06 May 2010 09:30:42 +1200</pubDate><category>CRC</category><category>CRC Card</category><category>Object Oriented</category><category>UML</category></item><item><title>IntelliJ my Love</title><description>&lt;p&gt;An un-poetic ode to IntelliJ. Will be amended continuously.&lt;/p&gt;

&lt;h3&gt;Auto-completion in comments&lt;/h3&gt;

&lt;h3&gt;Iteration Live Templates&lt;/h3&gt;

&lt;p&gt;You type ‘iter’ and you get a live template:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;for each (var object:Object in myColl) {

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And a caret over ‘myColl’ letting you pick from accessable itterable types.&lt;/p&gt;

&lt;p&gt;Nice!&lt;/p&gt;

&lt;h3&gt;Color swatches when it “sees” web color strings&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://localhostr.com/files/414c25/DontYouWishYourIDEWasHotLikeMine.png"&gt;Take a look at this image.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if only it recognised &lt;em&gt;0xfefefe&lt;/em&gt; as well.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/541497748</link><guid>http://devblog.vworkapp.com/post/541497748</guid><pubDate>Fri, 23 Apr 2010 10:05:00 +1200</pubDate><category>IntelliJ</category><category>IDEA</category></item><item><title>Robotlegs Plugin for IntelliJ</title><description>&lt;p&gt;So I started a little plugin a few days ago. I’m writing it for IntelliJ and it’s designed to make your life a little simpler, letting you navigate between classes with known ‘Up’ and ‘Down’ relationships in Robotlegs MVCS. Eg, The &lt;strong&gt;view&lt;/strong&gt; is “Up” from the &lt;strong&gt;mediator&lt;/strong&gt; and the &lt;strong&gt;service&lt;/strong&gt; is “Down” from a &lt;strong&gt;command&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;IntelliJ is really cool.&lt;/h2&gt;

&lt;p&gt;Apart from finding great little timesavers all the time, this is my first exposure to the underlying code of IntelliJ. It looks a little ‘patternitis’ but everything makes sense, and even the closed source ‘JavaScript’ plugin was easy enough to take advantage of with just headers.&lt;/p&gt;

&lt;p&gt;It’s also my first time into Java, and the experience has been made sweet because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;IntelliJ is a great IDE and makes light work of what would be chore-like coding&lt;/li&gt;
&lt;li&gt;IntelliJ is written with IntelliJ, and all the Best Practices and quality coding behaviours that IntelliJ promotes, are included in the “OpenAPI”&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I mean the Javadocs are ancient and out of date, and some things are clearly legacy, and yet me, a n00b Java programmer had no trouble cobbling together the first part of the Robotlegs plugin.&lt;/p&gt;

&lt;h2&gt;The Plugin, where’s that then?&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://plugins.intellij.net/plugin/?idea&amp;id=4685"&gt;Here: &lt;a href="http://plugins.intellij.net/plugin/?idea&amp;id=4685"&gt;http://plugins.intellij.net/plugin/?idea&amp;id=4685&lt;/a&gt;&lt;/a&gt; which means it’s also available in your IDE.&lt;/p&gt;

&lt;p&gt;You may need the &lt;a href="http://confluence.jetbrains.net/display/IDEADEV/Maia+EAP"&gt;EAP version&lt;/a&gt; of IntelliJ as that is what I coded against.&lt;/p&gt;

&lt;p&gt;It only does one thing right now. If you are in a mediator, then Ctrl-Alt-PageUp will take you to the linked in view. There is a &lt;a href="http://github.com/visfleet/RobotlegsUpDownPlugin/blob/master/docs/README.markdown"&gt;roadmap here&lt;/a&gt; and all the &lt;a href="http://github.com/visfleet/RobotlegsUpDownPlugin"&gt;source is here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the design is in place and a lot of the ‘discovery’ is done. So things should fall into place. Let me know if you have any trouble with it.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/483557397</link><guid>http://devblog.vworkapp.com/post/483557397</guid><pubDate>Tue, 30 Mar 2010 18:45:00 +1300</pubDate><category>flex</category><category>robotlegs</category><category>intellij idea</category></item><item><title>Mount VBox shared dir as normal user in Linux guest</title><description>&lt;p&gt;Rash wanted to mount a shared folder between his Windows desktop and a Linux guest running inside &lt;a href="http://www.virtualbox.org/"&gt;Virtual Box&lt;/a&gt; on said desktop.&lt;/p&gt;

&lt;p&gt;He also wanted to be able to own and write to the mounted shared folder as himself, ( aka non-root user).&lt;/p&gt;

&lt;p&gt;The syntax to put into /etc/fstab is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[shared folder name] [mount path] vboxsf uid=[uid],gid=[gid],dmode=0755,fmode=0755 0 0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In Rash’s case this was:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Documents /home/rasheed/host_documents vboxsf uid=1000,gid=1000,dmode=0755,fmode=0755 0 0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then, mount it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo mount /home/rasheed/host_documents
&lt;/code&gt;&lt;/pre&gt;</description><link>http://devblog.vworkapp.com/post/466735698</link><guid>http://devblog.vworkapp.com/post/466735698</guid><pubDate>Tue, 23 Mar 2010 13:35:06 +1300</pubDate></item><item><title>Flash Platform Users Group</title><description>&lt;p&gt;VisFleet sponsored the Flash Platform Users Group lastnight. Thanks to the guys and girls of the group for a good night and interesting talks. &lt;/p&gt;
&lt;p&gt;And here’s some pics:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_kzhwtmngOW1qb28ex.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rash taming Flash code into crafted code&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;br/&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_kzhwuv6yMS1qb28ex.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Vinnie wowing the audience with 3D in the browser&lt;/strong&gt;&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/457282012</link><guid>http://devblog.vworkapp.com/post/457282012</guid><pubDate>Fri, 19 Mar 2010 10:01:55 +1300</pubDate></item><item><title>Flash Platform User Group - Thursday @ 6PM at VisFleet's offices  </title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_kzcq641ehv1qb28ex.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;VisFleet are sponsoring the next Flash Platform User Group meeting this &lt;strong&gt;Thursday @ 6PM at VisFleet’s offices&lt;/strong&gt;. Our own Rasheed is giving a talk on the popular new Flex framework (RobotLegs). &lt;/p&gt;
&lt;p&gt;To register, RSVP here:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://aucknzfpug.eventbrite.com/"&gt;http://aucknzfpug.eventbrite.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All welcome. Pizza and beer will be provided. Should be a good night.&lt;/p&gt;
&lt;p&gt;Talks:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rasheed Abdul-aziz.&lt;/strong&gt; Rasheed will be wowing us with the wonders of the new framework RobotLegs. Robotlegs is a pure AS3 micro-architecture (framework) with a light footprint and limited scope. Simply put, Robotlegs is there to help you wire your objects together. (Sounds perfect)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Vinnie Vivace&lt;/strong&gt;. Lately Vinnie has been twittering from the land of 3d and will be showing us a little more about Away3D Lite, a fast and small 3d engine.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/451186205</link><guid>http://devblog.vworkapp.com/post/451186205</guid><pubDate>Tue, 16 Mar 2010 14:42:00 +1300</pubDate></item><item><title>List Model-Service Architecture with Robotlegs</title><description>&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt; Stupid post. I don’t know how I got it into my head that  VO’s needed an abstract factory for testing. They’re &lt;strong&gt;Value&lt;/strong&gt; Objects! Without the Abs-Fac we don’t need ‘IVO’ and we can implement multiple interfaces because the concrete interface is all that our system needs. Sorry if I wasted your time with this drivel.&lt;/p&gt;

&lt;p&gt;I’m currently looking at our services and model tier architectures. I’m focusing right now on the most common requirement of the client model-service tiers at Visfleet:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;ul&gt;
&lt;li&gt;Maintain a client side representation of collection resources (Lists of like information) &lt;/li&gt;
  &lt;li&gt;Keep the list server-canonical (allow the server to provide the most up-to-date state as often as possible)&lt;/li&gt;
  &lt;li&gt;Expose standard REST operations for List, Show, Update, Create, Delete, New, Edit&lt;/li&gt;
  &lt;li&gt;Expose resource specific methods (RPC when needed)&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;So I was looking for a prescription, that as usual, kept my responsibility-count-per-class down near one.&lt;/p&gt;

&lt;p&gt;What follows is my first draft. (&lt;a href="http://www.gliffy.com/publish/2020722/"&gt;Embiggen&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;img src="http://www.gliffy.com/pubdoc/2020722/S.png" alt="Class Diagram"/&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; IUpdateable is the only non-metaclass in this diagram.&lt;/p&gt;

&lt;h2&gt;service.load&lt;/h2&gt;

&lt;p&gt;So in this example I support &lt;em&gt;service.load()&lt;/em&gt; which fetches the state of the whole list, or part of the list, from the server. The description of sequence that follows works as easily for any service request that results in a result record coming back from the server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;service.load()&lt;/em&gt; requests a list form the server.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;service&lt;/em&gt; iterates over the service results

&lt;ol&gt;
&lt;li&gt;Uses &lt;em&gt;voFactory&lt;/em&gt;.create() to create a new concrete VO&lt;/li&gt;
&lt;li&gt;Parses the server result into the VO&lt;/li&gt;
&lt;li&gt;Adds the VO to a payload.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;service&lt;/em&gt; emits a signal that it has results, which carries the payload it just created.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;controller (&lt;em&gt;HandleResultCommand&lt;/em&gt;)&lt;/h2&gt;

&lt;p&gt;Typical Robotlegs behaviour here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;HandleResultCommand&lt;/em&gt; calls &lt;em&gt;listModel.update()&lt;/em&gt; passing the payload of VOs&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;&lt;em&gt;listModel.update()&lt;/em&gt;&lt;/h2&gt;

&lt;p&gt;The list model needs to ensure that its representation of the list is updated by the incoming payload&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Iterates over the payload

&lt;ol&gt;
&lt;li&gt;Adds VO to list if it’s new (not in list)&lt;/li&gt;
&lt;li&gt;Updates existing list VO if it’s an update (in list)&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To update a VO, &lt;em&gt;listModel&lt;/em&gt; depends on &lt;em&gt;IVO&lt;/em&gt; being &lt;em&gt;IUpdateable&lt;/em&gt;. This could be a responsibility of the &lt;em&gt;ListModel&lt;/em&gt; itself, I’m still not sure which is more OO Savvy.&lt;/p&gt;

&lt;p&gt;In my opinion, a broadly updateable VO is a requirement of the Flex framework. Collection types in Flex work best if VO object references don’t change. So do the collection-aware components.&lt;/p&gt;

&lt;h2&gt;The Gap&lt;/h2&gt;

&lt;p&gt;Usually at this point, someone wants to edit a VO. We don’t modify server-canonical VO’s in our apps, we clone them. We edit the clone, and actually share the clone as an ‘EditableModel’ so our whole app has access to the current VO under edit.&lt;/p&gt;

&lt;p&gt;This is a perfect arrangement, however, I’m stuck. Making &lt;em&gt;IVO&lt;/em&gt; &lt;em&gt;ICloneable&lt;/em&gt; is not possible, I could only make VO &lt;em&gt;ICloneable&lt;/em&gt;. If i move the &lt;em&gt;IUpdateable&lt;/em&gt; respnsibility to &lt;em&gt;ListModel&lt;/em&gt; there’s now a gap for &lt;em&gt;ICloneable&lt;/em&gt;, but I’m not pleased with making an unassociated refactor a requirement.&lt;/p&gt;

&lt;p&gt;If I introduce my &lt;em&gt;EditModel&lt;/em&gt; at this point however, I do get a way around this that makes sense.&lt;/p&gt;

&lt;h2&gt;Welcome EditModel&lt;/h2&gt;

&lt;p&gt;(&lt;a href="http://www.gliffy.com/publish/2020876/"&gt;Embiggen&lt;/a&gt;)
&lt;img src="http://www.gliffy.com/pubdoc/2020876/S.png" alt="Class Diagram"/&gt;&lt;/p&gt;

&lt;p&gt;I’ve dropped some components to make this clearer.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;EditModel&lt;/em&gt; is introduced. It maintains the currently ‘under edit’ VO which is a clone. It uses &lt;em&gt;ICloneable&lt;/em&gt; a little like a &lt;a href="http://en.wikipedia.org/wiki/Marker_interface_pattern"&gt;marker interface&lt;/a&gt; to do this. However it does require the VO to implement &lt;em&gt;clone()&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Do you think I should be making the effort to make &lt;em&gt;ICloneable&lt;/em&gt; purely a marker and have a CloneStrategy?&lt;/p&gt;

&lt;p&gt;Please feel free to comment, once you are aware of my &lt;a href="http://squeedee.tumblr.com/post/426566080/the-caveat-emptor-strikes-back"&gt;usual disclaimers&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/437521209</link><guid>http://devblog.vworkapp.com/post/437521209</guid><pubDate>Wed, 10 Mar 2010 10:59:00 +1300</pubDate></item><item><title>On Robotlegs UI Architectures</title><description>&lt;p&gt;There are now &lt;a href="http://squeedee.tumblr.com/post/426566080/the-caveat-emptor-strikes-back"&gt;Caveats&lt;/a&gt; to all my posts.&lt;/p&gt;

&lt;p&gt;I am considering everything in this post from the point of view of a N-Tier RIA developer’s point of view.&lt;/p&gt;

&lt;p&gt;The Robotlegs MVCS presents a myriad of ways you can work with your tiers, without adding one line of extra framework code or departing from the Best Practices. Then there are the few &lt;em&gt;presentation model&lt;/em&gt; mods I’ve seen around, such as &lt;a href="http://elromdesign.com/blog/2010/01/23/robotlegs-presentation-model-access-entire-component-events-lifecycle/"&gt;Elad Elrom’s&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I quite like the “Robotlegs is the presentation model” one we use at Visfleet. Below, I give a little bit of backstory and explain why I like it so.&lt;/p&gt;

&lt;h2&gt;“MVC”&lt;/h2&gt;

&lt;p&gt;I find that the original beauty of MVC is somewhat lost in most breakdowns of MVC-like architectures. I have to wonder if I’m missing something.&lt;/p&gt;

&lt;p&gt;Originally the “View” of MVC was a Component, The original SmallTalk MVC was component oriented. From &lt;a href="http://martinfowler.com/eaaDev/uiArchs.html"&gt;Fowler’s UI Architecture Article&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;At this point I should stress that there’s not just one view and controller, you have a view-controller pair for each element of the screen, each of the controls and the screen as a whole.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are reasons this approach died off and isn’t considered practical. Noteably, when the components are generic (yay re-use) and encapsulate their own modelling. For example, a checkbox has it’s own selection state and transition modelling. All you get as a consumer is a public interface (on the “View” no less) consisting of properties (e.g.: checked), methods and signals (e.g.:VALUE_COMMIT).&lt;/p&gt;

&lt;p&gt;However there is a beauty to the idea of having control/model support for these component views in your MVC-like architecture. This is something I’m a proponent of. Verbs like “select”, “move”, “reorient”, “announce”, “publish”, “change”, “commit”, “save” etc can all become adjectives of state: “Jobs[1] is selected”, “task is running”, “person is facing east”.&lt;/p&gt;

&lt;p&gt;I consider a lot of what most would call ‘view state’ (something kept by view, mediator or presenter) is in fact domain modelling.&lt;/p&gt;

&lt;h2&gt;Domain Modelling&lt;/h2&gt;

&lt;p&gt;Again from &lt;a href="http://martinfowler.com/eaaDev/uiArchs.html"&gt;Fowler’s UI Architecture Article&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The idea behind Separated Presentation is to make a clear division between domain objects that model our perception of the real world, and presentation objects that are the GUI elements we see on the screen. Domain objects should be completely self contained and work without reference to the presentation, they should also be able to support multiple presentations, possibly simultaneously.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I worry that the domain modelling found in the client-tier of most N-Tier applications (read database backed with a server encapsulating business logic) is often treated as a model of the business logic.&lt;/p&gt;

&lt;p&gt;Certainly there is a good case to model some business logic in the client for speed and responsiveness, networks aren’t terribly fast compared to my computer’s bus. However that “business logic” being modelled is actually a part of the client domain model. It should be considered a utility and not actual Business Domain Modelling.&lt;/p&gt;

&lt;p&gt;Let’s reiterrate that through example.&lt;/p&gt;

&lt;p&gt;The business tier (server) says that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A “Job” may transition state from “started” to “finished” or to “not started”.&lt;/li&gt;
&lt;li&gt;A “Job” can not transition from “Started” to “Deleted” (you have to finish the job or back out of it before removing it)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When enforced on the business tier, this is “Business Logic” or “Business Domain Modelling”&lt;/p&gt;

&lt;p&gt;When mimicked in the client tier, this is “Client Domain Modelling”. It is not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Canonincal. So I’m calling it untrusted&lt;/li&gt;
&lt;li&gt;Business Logic. Let’s not have it in two places.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Client Domain Models in N-Tier application clients are there to serve the purpose of presenting the business to the user&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What I take away from this is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A “Start” method is a domain model action.&lt;/li&gt;
&lt;li&gt;selectedItem is domain model state.&lt;/li&gt;
&lt;li&gt;runningJobs is domain model state.&lt;/li&gt;
&lt;li&gt;etc…&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To put it another way, I see my whole Robotlegs MVCS stack as one giant ‘Presentation Model’&lt;/p&gt;

&lt;h2&gt;Re-tiering feels pointless&lt;/h2&gt;

&lt;p&gt;What a lot of people do in their presenters and mediators is have a local state and message bus. This feels awkward to me. Suddenly I’m without a prescription, and frankly it’s really easy for me to write crap again. I can fill my mediator or presenter with awkward code that unsuprisingly is often best served by the MVC pattern.&lt;/p&gt;

&lt;p&gt;I could treat my mediator as the context for another Robotlegs stack, however there is one clear drawback to this: Views, with their own concerns, cannot change containment easily. I explain this with the “Doorbell Model” later.&lt;/p&gt;

&lt;h2&gt;One context to rule them all&lt;/h2&gt;

&lt;p&gt;Or most of them… There’s lots of good reasons to use subcontexts, but within a context, I want to use a single MVCS 4-Tier.&lt;/p&gt;

&lt;p&gt;I mediate as many components as I can, it gives me some of the elegance that the original MVC had. Each component action is mapped to a command, the command changes state in my modelling in some way, the mediator and view ensure they represent the new state. Again, I’ll outline this in the “Doorbell Model”&lt;/p&gt;

&lt;p&gt;If I want to ‘genericise’ a component, and thus limit other users to it’s view’s public interface (as with most UIComponents), then I still create a robotlegs 4-tier stack and pass in dependencies via the view’s public interface. Then the context for the component uses these values as injection mappings (often named value mappings). I don’t do this very often mind you, a single context doesn’t cause me any real pain. Sub contexts &lt;em&gt;might&lt;/em&gt; make for less clutter and I look forward to investigating those further.&lt;/p&gt;

&lt;h2&gt;The Doorbell Model&lt;/h2&gt;

&lt;p&gt;A simple analogy for why I don’t want any more tiers than the 4 in MVCS.&lt;/p&gt;

&lt;h3&gt;First, the views&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A House is composed of a roof, a floor, and walls.&lt;/li&gt;
&lt;li&gt;Walls are composed of Mortar, Bricks, Windows, Adornments and Doors&lt;/li&gt;
&lt;li&gt;Doors have Adornments.&lt;/li&gt;
&lt;li&gt;Example Adornments are: Lights, Doorknockers, Doorbells, Plaques etc..&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;A doorbell, where you might find it.&lt;/h3&gt;

&lt;p&gt;I’ve seen &lt;em&gt;Doorbells&lt;/em&gt; on &lt;em&gt;Doors&lt;/em&gt;, on the &lt;em&gt;Wall&lt;/em&gt; beside &lt;em&gt;Doors&lt;/em&gt; , and even at the back of a &lt;em&gt;House&lt;/em&gt; (for a teenage boy’s mates to ring late in the evening.)&lt;/p&gt;

&lt;p&gt;My original design might call for the &lt;em&gt;Doorbell&lt;/em&gt; to be beside the &lt;em&gt;frontDoor&lt;/em&gt;, thus contained by the &lt;em&gt;frontWall&lt;/em&gt;, in turn contained by the &lt;em&gt;house&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This &lt;em&gt;frontDoorBell&lt;/em&gt; could be mediated by &lt;em&gt;House&lt;/em&gt;’ or &lt;em&gt;Door&lt;/em&gt;’s mediator. But why? Why not put a mediator on &lt;em&gt;DoorBell&lt;/em&gt;. Then when I go to put a &lt;em&gt;DoorBell&lt;/em&gt; on the &lt;em&gt;backWall&lt;/em&gt;, and move the &lt;em&gt;frontDoorBell&lt;/em&gt; to the &lt;em&gt;frontDoor&lt;/em&gt; itself, nothing needs to change.&lt;/p&gt;

&lt;p&gt;I almost imagine the &lt;em&gt;DoorBell&lt;/em&gt;’s mediator to be a little circuit that hooks it to the wire on the &lt;em&gt;House&lt;/em&gt;’ event bus.&lt;/p&gt;

&lt;h3&gt;An identifiable doorbell&lt;/h3&gt;

&lt;p&gt;Did you notice the arrival of the &lt;em&gt;DoorBell&lt;/em&gt; on the &lt;em&gt;backWall&lt;/em&gt;. This puppy makes it interesting. The event bus wants to ring two different bells, one for the &lt;em&gt;teenageKidsRoom.bell&lt;/em&gt; and one for the &lt;em&gt;hallway.bell&lt;/em&gt;. How would we identify the messages coming from these objects? That’s easy, the parent container of the &lt;em&gt;DoorBell&lt;/em&gt; can inform it of it’s location (or the doorbell could ask the parent, it’s not an issue we need to care about right now).&lt;/p&gt;

&lt;p&gt;The DoorBell.location property can be used to identify it’s position within views. This is appropriate intimacy and requires nothing but an obvious refactor to introduce it.&lt;/p&gt;

&lt;h2&gt;All those classes!&lt;/h2&gt;

&lt;p&gt;This approach to architecting my UI means that I have a proliferation of class definitions, and all within the convention of /model /view /controller /events /service. That’s OK. I compartmentalise component of the system by namespaces. Take a look at our &lt;a href="http://github.com/visfleet/robotlegs-documentation/blob/master/Namespaces.markdown"&gt;namespace-prescription&lt;/a&gt; (living document) for Visfleet’s vWork product.&lt;/p&gt;

&lt;h2&gt;RFC&lt;/h2&gt;

&lt;p&gt;If you think I need to clear up anything or ammend anything or consider something, please comment. I crave peer input :)&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/427460271</link><guid>http://devblog.vworkapp.com/post/427460271</guid><pubDate>Fri, 05 Mar 2010 16:10:00 +1300</pubDate><category>flex</category><category>actionScript</category><category>robotlegs</category><category>UI</category><category>Patterns</category><category>MVC</category><category>Presenter</category></item><item><title>Verbose is a dirty word</title><description>&lt;p&gt;I’m not saying verbose &lt;em&gt;should&lt;/em&gt; be a dirty word, just that it does have a pejorative meaning. If you’ve used *nix command line tools often enough, you’ll know that &lt;strong&gt;-v&lt;/strong&gt; is often used as a flag for “verbose”. This usually ends up in some useful information coming out of the log or stdout. &lt;strong&gt;-vvv&lt;/strong&gt; usually means “very verbose” and too much information pours out to be of any use. And this is the risk:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;If &lt;strong&gt;verbose&lt;/strong&gt; is your end-goal, then the more verbose you are, the better.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Right? I mean that makes sense. If “quality” is your end-goal, then more and more quality is a thing to strive for. Same goes for “agile”, “fair”, “loyal”, “just”. All these words suggest that the more you pile it on, the better. This is not true of verbose. Keep getting verbose, and in fact, you just get more &lt;strong&gt;noise&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I’m probably nitpicking this to death, but I’m only doing so, now, because I think I have a better quality to strive for:&lt;/p&gt;

&lt;h2&gt;Expressiveness&lt;/h2&gt;

&lt;p&gt;Really in our code, we wan’t to be more expressive. We want every line we read to convey it’s meaning.&lt;/p&gt;

&lt;p&gt;If you check out &lt;a href="http://dictionary.reference.com/browse/expressive"&gt;expressive at dictionary.com&lt;/a&gt; there’s also a nice set of synonyms:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Synonyms:&lt;/strong&gt; These adjectives mean effectively conveying a feeling, idea, or mood: an expressive gesture; an eloquent speech; a meaningful look; a significant smile.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think &lt;strong&gt;eloquent&lt;/strong&gt; is a good word too, it usually conveys meaning in a &lt;strong&gt;terse&lt;/strong&gt; manner. That’s right, &lt;strong&gt;less verbose&lt;/strong&gt;, just enough meaning and no more.&lt;/p&gt;

&lt;h2&gt;Readable Code&lt;/h2&gt;

&lt;p&gt;This code is readable, but not expressive:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class EmployeeModel {
    ....
    public function save():void {
        if ((editingEmployee.name.length &gt; 0) &amp;&amp; (employees.checkUnique(editingEmployee.ssid))) {
            employees.comit(editingEmployee);
        }
    }
    ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Expressive Code&lt;/h2&gt;

&lt;p&gt;So now I refactor it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class EmployeeModel {
    ....
    protected function employeeIsValid(employee:EmployeeVO):Boolean {
        return ((employee.name.length &gt; 0) &amp;&amp; employees.checkUnique(employee.ssid))
    }

    public function save():void {
        if (!employeeIsValid(editingEmployee)
            return;

        employees.comit(editingEmployee);
    }
    ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I use a guard clause for starters because they convey intent more clearly.&lt;/p&gt;

&lt;p&gt;Then I extract the method (all praise ctrl-alt-m in IntelliJ IDEA) employeeIsValid(). This gives the guard more meaning, and also gives the extracted condition more meaning. It’s a win-win.&lt;/p&gt;

&lt;h2&gt;Verbose Code&lt;/h2&gt;

&lt;p&gt;Now, is this the following code more expressive or more verbose?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public class EmployeeModel {
    ....
    protected function employeeNameIsValid(employee:EmployeeVO):Boolean {
        return employee.name.length &gt; 0;
    }

    protected function employeeIsValid(employee:EmployeeVO):Boolean {
        return (employeeNameIsValid(employee) &amp;&amp; employees.checkUnique(employee.ssid))
    }

    public function save():void {
        if (!employeeIsValid(editingEmployee)
            return;

        employees.comit(editingEmployee);
    }
    ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I extract the name comparison (pretend for a moment that it couldn’t be done in the VO) - employeeNameIsValid().&lt;/p&gt;

&lt;p&gt;This is not too bad, I think. It expresses that an employeeName that’s greater than 0 chars long is valid.&lt;/p&gt;

&lt;p&gt;However this is easily inferred from the previous example, because the test is inside ‘employeeIsValid’ - It would read just as well, and so I wouldn’t bother with this extra step. At least, not until it got more complex. Remember, &lt;strong&gt;most refactorings are bidirectional&lt;/strong&gt;.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/420331301</link><guid>http://devblog.vworkapp.com/post/420331301</guid><pubDate>Tue, 02 Mar 2010 08:49:56 +1300</pubDate><category>flex</category><category>clean code</category><category>expressive</category><category>verbose</category></item><item><title>Install pg gem via Bundler on OSX Snow Leopard</title><description>&lt;p&gt;I encountered three problems installing the Postgres ruby gem (pg) when using &lt;a href="http://github.com/carlhuda/bundler"&gt;Bundler&lt;/a&gt; to install all the gems for a project on my OSX Snow Leopard 10.6 machine.&lt;/p&gt;

&lt;p&gt;Firstly, the gem fails to build on Snow Leopard when you use the binary version of Postgres that is distributed by &lt;a href="http://www.enterprisedb.com/products/pgdownload.do"&gt;Enterprise DB&lt;/a&gt;. To work around this, the Postgres binaires need to be installed using &lt;a href="http://www.macports.org/"&gt;Mac Ports&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Secondly, the pg gem must be installed using additional bash environment variables.&lt;/p&gt;

&lt;p&gt;Thirdly, every time you run &lt;code&gt;bundle install&lt;/code&gt;, the current version of Bundler hard re-installs all gems listed in ./Gemfile. This means that even if you install the pg gem correctly by hand, bundler will still try to reinstall it.&lt;/p&gt;

&lt;p&gt;All three are resolved as below, in my case I am using Postgres 8.4.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Install postgres from &lt;a href="http://www.macports.org/"&gt;Mac Ports&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo port install postgres84
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Include the postgres binaries in the PATH environment variable&lt;/em&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;export PATH=/opt/local/lib/postgresql84/bin:${PATH}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Then run bundle install with the all-important arch flag&lt;/em&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;env ARCHFLAGS="-arch x86_64" bundle install
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Edit: removed sudo from bundle command.&lt;/p&gt;</description><link>http://devblog.vworkapp.com/post/403869225</link><guid>http://devblog.vworkapp.com/post/403869225</guid><pubDate>Mon, 22 Feb 2010 14:49:00 +1300</pubDate></item></channel></rss>
