<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>yobriefca.se</title>
  <subtitle>Published works of James Hughes</subtitle>
  <id>http://yobriefca.se</id>
  <link href="http://yobriefca.se"/>
  <link href="http://yobriefca.se/feed" rel="self"/>
  <entry>
    <title>The Old "Agile is for Developers" Myth</title>
    <link rel="alternate" href="/blog/2013/05/08/the-old-agile-is-for-developers-myth"/>
    <id>/blog/2013/05/08/the-old-agile-is-for-developers-myth</id>
    <published>2013-05-08T00:00:00+01:00</published>
    <updated>2013-05-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;img alt="Agile FUD" src="/images/blog/agile-fear.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;There is a common misconception among people who are just starting out on the agile path that the agile model favors developers and downplays other roles.  While it is true that agile puts a greater focus and added responsibility on developers it also broadens the definition of developer from the niche of &amp;ldquo;people who write code&amp;rdquo; role to a more umbrella term of &amp;ldquo;people who deliver software&amp;rdquo;.&lt;/p&gt;

&lt;p&gt;Another comment I heard being made, admittedly in jest, is that agile is &amp;ldquo;Disneyland for Developers&amp;rdquo; and honestly this couldn&amp;#39;t be further from the truth. In fact agile methods typically expect people involved in delivery to be MORE responsible for delivery.  Developers are no longer just mindless code monkeys banging out tasks against pseudo-code written in a document.  No, developers are expected to &lt;strong&gt;DEVELOP a working solution&lt;/strong&gt;.  This includes analysis, design, architecture, development &amp;amp; testing.  All of this is expected to be done with one eye on the &amp;ldquo;big picture&amp;rdquo;, they are expected to understand WHY they are doing something from, both, a technical and business perspective, they are expected to be at least understand how their code is deployed and often expected to be able to deploy it.  You don&amp;#39;t have &lt;em&gt;the Java guys&lt;/em&gt;, &lt;em&gt;the Web guys&lt;/em&gt; or &lt;em&gt;the DBAs&lt;/em&gt; - no, a single person in a team should at least be capable of driving out a vertical slice of functionality from infrastructure to database to services to HTML and JavaScript.  Of course the slice doesn&amp;#39;t have to be, nor will be, perfect right now. There will always be space for specialists to come in and make their areas better, more secure, faster, whatever needs done.  But at the very least when all but one person on the team catches some rare exotic disease on a team bonding night out that person can still deliver &lt;strong&gt;valuable&lt;/strong&gt; working software until the rest of the team recovers.&lt;/p&gt;

&lt;p&gt;Ultimately though the agile methods that are technically focused are about ensuring quality of delivery.  Delivered features should be &lt;strong&gt;&amp;ldquo;done&amp;rdquo;&lt;/strong&gt; rather than thrown together an handed over a test team to let them find the issues - a common side effect of time constrained, fixed scope, phased delivery.  That practice is unacceptable even in plan based or phased models and regardless of the project approach a development team can and should be making use of practices often associated with agile.&lt;/p&gt;

&lt;p&gt;But other roles necessary in the delivery of a project also benefit greatly from agile approaches.  Just think of some of the things these other roles would do within more traditional project delivery models,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Who has to spend days or even weeks manually running the same few hundred scripted tests every few months to avoid regressions and assert correctness of the system?&lt;/em&gt;  Not the developers thats for sure.  Testers are often required to execute manual scripted tests which are slow, prone to error and have a relatively low ROI compared to other testing techniques.  Manual tests check for issues you know will break your system, but its the unknown issues that typically kill your solution.  Automation of these tests (by developers and testers) gives faster more frequent feedback and allows testers to actually do interesting, rewarding, more valuable testing such as Exploratory Testing.  Testers should not be there to break things but to ensure we build the right thing right in the first place.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Who spends weeks going through multiple versions of documents that seldom get updated and go out of date shortly after sign off?&lt;/em&gt;  Again, not typically the developers.  Business Analysts and Solution Architects spend a long time producing documents that create a contract for all parties involved.  Often, though, they are only pulled out during &amp;ldquo;disputes&amp;rdquo; around agreed functionality (between either developers &amp;amp; tester or customers &amp;amp; analysts).  If that happens though, then who is actually reading these things properly?  No matter how rigorous you make documents there will always be the problem of interpretation.  You can&amp;#39;t misinterpret a running solution.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Who is expected to &amp;ldquo;manage expectations&amp;rdquo; when delivery is slipping beyond the scheduled dates?&lt;/em&gt;.  Long running projects that pin all their plans on up front estimates will slip.  It&amp;#39;s inevitable unless you&amp;#39;ve managed to overestimate everything but then I&amp;#39;d wonder why you are doing the work and not your more aggressive competitor.  When this happens it&amp;#39;s typically the job of the manager and senior technical folks to inform the customer in the best way possible, to &amp;ldquo;manage their expectations&amp;rdquo; (shudder).  No one wants to do that.  In typical agile models visibility is a key differentiator (another way to ensure quick and frequent feedback) which removes the need to for big bang disappointment.  When things change or slip you know about them much quicker and can course adjust, the impact is significantly reduced.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these (arguably wasteful) practices are typically the responsibility of people in non-developer roles.  Now that we have reduced or removed these practices does that mean we&amp;#39;ve made the roles redundant?  Not at all - as with the developer role increasing in scope so does the manager, analyst and tester.  Testers no longer just &amp;ldquo;test&amp;rdquo;, they have a more important function - assuring that what they test is the right thing, they&amp;#39;ve become crucial to analysis.  Analysts also need to understand aspects of project management and managers themselves can move to a more hands-off sales and account management role as delivery is managed by the team itself.  What we will see is a reduction of specific titles on projects, most people no longer fit those niche titles.&lt;/p&gt;

&lt;h2&gt;Facilitators &amp;amp; Implementors&lt;/h2&gt;

&lt;p&gt;So, yes, agile approaches certainly favour working software over volumes of documentation describing what the system &lt;strong&gt;should&lt;/strong&gt; do but heck - so does common sense.  &lt;/p&gt;

&lt;p&gt;Agile approaches flatten the role structure across the delivery of a project.  You end up with umbrella terms like facilitators (who ensure the right thing is being built) and implementors (who ensure the thing is being built right).  &lt;/p&gt;

&lt;p&gt;You go from this,&lt;/p&gt;

&lt;p&gt;&lt;img alt="Traditional View" src="/images/blog/traditional-view.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;To something more like this,&lt;/p&gt;

&lt;p&gt;&lt;img alt="High-level Agile View" src="/images/blog/agile-view.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;If you wanted to map these intentionally nebulous terms back to typical roles in a more traditional model you have,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Facilitators&lt;/strong&gt; - Business Analysts, Solution Architects, Customers, Stakeholders, Users, Testers, Project Managers, Legal etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Implementors&lt;/strong&gt; - Developers, Testers, DBAs, Designers &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Its clear to see where the commonplace agile roles fall as well - Product Owner and Scrum Master would be &lt;strong&gt;facilitators&lt;/strong&gt; and the team would be the &lt;strong&gt;implementors&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Already, even at this high level you&amp;#39;re getting overlaps and in many ways everyone plays their part as both a &lt;strong&gt;facilitator&lt;/strong&gt; and an &lt;strong&gt;implementor&lt;/strong&gt; but its generally obvious what a persons primary function is and you can plan around that accordingly.&lt;/p&gt;

&lt;p&gt;You don&amp;#39;t need fancy, lofty titles because you have a single purpose. Titles only force attribution of responsibility to particular people, they enforce specialism and defensive attitudes.  Titles shouldn&amp;#39;t affect the delivery of a solution.&lt;/p&gt;

&lt;p&gt;So, no, &amp;ldquo;agile&amp;rdquo; is not just for developers, it&amp;#39;s for the facilitators, the stakeholder &amp;amp; the implementors, it&amp;#39;s an all-encompassing first step on the road to refocusing our goals from following a process to delivering the right thing quickly and painlessly. &lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;img alt="Agile FUD" src="/images/blog/agile-fear.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;There is a common misconception among people who are just starting out on the agile path that the agile model favors developers and downplays other roles.  While it is true that agile puts a greater focus and added responsibility on developers it also broadens the definition of developer from the niche of &amp;ldquo;people who write code&amp;rdquo; role to a more umbrella term of &amp;ldquo;people who deliver software&amp;rdquo;.&lt;/p&gt;

&lt;p&gt;Another comment I heard being made, admittedly in jest, is that agile is &amp;ldquo;Disneyland for Developers&amp;rdquo; and honestly this couldn&amp;#39;t be further from the truth. In fact agile methods typically expect people involved in delivery to be MORE responsible for delivery.  Developers are no longer just mindless code monkeys banging out tasks against pseudo-code written in a document.  No, developers are expected to &lt;strong&gt;DEVELOP a working solution&lt;/strong&gt;.  This includes analysis, design, architecture, development &amp;amp; testing.  All of this is expected to be done with one eye on the &amp;ldquo;big picture&amp;rdquo;, they are expected to understand WHY they are doing something from, both, a technical and business perspective, they are expected to be at least understand how their code is deployed and often expected to be able to deploy it.  You don&amp;#39;t have &lt;em&gt;the Java guys&lt;/em&gt;, &lt;em&gt;the Web guys&lt;/em&gt; or &lt;em&gt;the DBAs&lt;/em&gt; - no, a single person in a team should at least be capable of driving out a vertical slice of functionality from infrastructure to database to services to HTML and JavaScript.  Of course the slice doesn&amp;#39;t have to be, nor will be, perfect right now. There will always be space for specialists to come in and make their areas better, more secure, faster, whatever needs done.  But at the very least when all but one person on the team catches some rare exotic disease on a team bonding night out that person can still deliver &lt;strong&gt;valuable&lt;/strong&gt; working software until the rest of the team recovers.&lt;/p&gt;

&lt;p&gt;Ultimately though the agile methods that are technically focused are about ensuring quality of delivery.  Delivered features should be &lt;strong&gt;&amp;ldquo;done&amp;rdquo;&lt;/strong&gt; rather than thrown together an handed over a test team to let them find the issues - a common side effect of time constrained, fixed scope, phased delivery.  That practice is unacceptable even in plan based or phased models and regardless of the project approach a development team can and should be making use of practices often associated with agile.&lt;/p&gt;

&lt;p&gt;But other roles necessary in the delivery of a project also benefit greatly from agile approaches.  Just think of some of the things these other roles would do within more traditional project delivery models,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Who has to spend days or even weeks manually running the same few hundred scripted tests every few months to avoid regressions and assert correctness of the system?&lt;/em&gt;  Not the developers thats for sure.  Testers are often required to execute manual scripted tests which are slow, prone to error and have a relatively low ROI compared to other testing techniques.  Manual tests check for issues you know will break your system, but its the unknown issues that typically kill your solution.  Automation of these tests (by developers and testers) gives faster more frequent feedback and allows testers to actually do interesting, rewarding, more valuable testing such as Exploratory Testing.  Testers should not be there to break things but to ensure we build the right thing right in the first place.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Who spends weeks going through multiple versions of documents that seldom get updated and go out of date shortly after sign off?&lt;/em&gt;  Again, not typically the developers.  Business Analysts and Solution Architects spend a long time producing documents that create a contract for all parties involved.  Often, though, they are only pulled out during &amp;ldquo;disputes&amp;rdquo; around agreed functionality (between either developers &amp;amp; tester or customers &amp;amp; analysts).  If that happens though, then who is actually reading these things properly?  No matter how rigorous you make documents there will always be the problem of interpretation.  You can&amp;#39;t misinterpret a running solution.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Who is expected to &amp;ldquo;manage expectations&amp;rdquo; when delivery is slipping beyond the scheduled dates?&lt;/em&gt;.  Long running projects that pin all their plans on up front estimates will slip.  It&amp;#39;s inevitable unless you&amp;#39;ve managed to overestimate everything but then I&amp;#39;d wonder why you are doing the work and not your more aggressive competitor.  When this happens it&amp;#39;s typically the job of the manager and senior technical folks to inform the customer in the best way possible, to &amp;ldquo;manage their expectations&amp;rdquo; (shudder).  No one wants to do that.  In typical agile models visibility is a key differentiator (another way to ensure quick and frequent feedback) which removes the need to for big bang disappointment.  When things change or slip you know about them much quicker and can course adjust, the impact is significantly reduced.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these (arguably wasteful) practices are typically the responsibility of people in non-developer roles.  Now that we have reduced or removed these practices does that mean we&amp;#39;ve made the roles redundant?  Not at all - as with the developer role increasing in scope so does the manager, analyst and tester.  Testers no longer just &amp;ldquo;test&amp;rdquo;, they have a more important function - assuring that what they test is the right thing, they&amp;#39;ve become crucial to analysis.  Analysts also need to understand aspects of project management and managers themselves can move to a more hands-off sales and account management role as delivery is managed by the team itself.  What we will see is a reduction of specific titles on projects, most people no longer fit those niche titles.&lt;/p&gt;

&lt;h2&gt;Facilitators &amp;amp; Implementors&lt;/h2&gt;

&lt;p&gt;So, yes, agile approaches certainly favour working software over volumes of documentation describing what the system &lt;strong&gt;should&lt;/strong&gt; do but heck - so does common sense.  &lt;/p&gt;

&lt;p&gt;Agile approaches flatten the role structure across the delivery of a project.  You end up with umbrella terms like facilitators (who ensure the right thing is being built) and implementors (who ensure the thing is being built right).  &lt;/p&gt;

&lt;p&gt;You go from this,&lt;/p&gt;

&lt;p&gt;&lt;img alt="Traditional View" src="/images/blog/traditional-view.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;To something more like this,&lt;/p&gt;

&lt;p&gt;&lt;img alt="High-level Agile View" src="/images/blog/agile-view.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;If you wanted to map these intentionally nebulous terms back to typical roles in a more traditional model you have,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Facilitators&lt;/strong&gt; - Business Analysts, Solution Architects, Customers, Stakeholders, Users, Testers, Project Managers, Legal etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Implementors&lt;/strong&gt; - Developers, Testers, DBAs, Designers &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Its clear to see where the commonplace agile roles fall as well - Product Owner and Scrum Master would be &lt;strong&gt;facilitators&lt;/strong&gt; and the team would be the &lt;strong&gt;implementors&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Already, even at this high level you&amp;#39;re getting overlaps and in many ways everyone plays their part as both a &lt;strong&gt;facilitator&lt;/strong&gt; and an &lt;strong&gt;implementor&lt;/strong&gt; but its generally obvious what a persons primary function is and you can plan around that accordingly.&lt;/p&gt;

&lt;p&gt;You don&amp;#39;t need fancy, lofty titles because you have a single purpose. Titles only force attribution of responsibility to particular people, they enforce specialism and defensive attitudes.  Titles shouldn&amp;#39;t affect the delivery of a solution.&lt;/p&gt;

&lt;p&gt;So, no, &amp;ldquo;agile&amp;rdquo; is not just for developers, it&amp;#39;s for the facilitators, the stakeholder &amp;amp; the implementors, it&amp;#39;s an all-encompassing first step on the road to refocusing our goals from following a process to delivering the right thing quickly and painlessly. &lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Micro Service Architecture</title>
    <link rel="alternate" href="/blog/2013/04/29/micro-service-architecture"/>
    <id>/blog/2013/04/29/micro-service-architecture</id>
    <published>2013-04-29T00:00:00+01:00</published>
    <updated>2013-04-29T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;img alt="Micro Service Architecture" src="/images/blog/micro-service-architecture.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Micro Service Architecture is an architectural concept that aims to decouple a solution by decomposing functionality into discrete services.  Think of it as applying many of the principles of &lt;a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)"&gt;SOLID&lt;/a&gt; at an architectural level, instead of classes you&amp;#39;ve got services.&lt;/p&gt;

&lt;p&gt;Conceptually speaking MSA is not particularly difficult to grasp but in practice it does raise many questions.  How do these services communicate? What about latency between services? How do you test the services?  How do you detect and respond to failure? How do you manage deployments when you have a bunch of interdependencies?  So lets expand on some of these throughout this post and see if MSA really is worth the effort.&lt;/p&gt;

&lt;h2&gt;Anatomy of a Micro Service&lt;/h2&gt;

&lt;p&gt;First things first what actually &lt;strong&gt;is&lt;/strong&gt; a micro service?  Well there really isn&amp;#39;t a hard and fast definition but from conversations with various people there seems to be a consensus that a micro service is a simple application that sits around the 10-100 LOC mark.  Now I realise that line count is an atrocious way to compare implementations so take what you will from that.  But they are small, micro even. This means you&amp;#39;re not going to find hundreds of tiny services built on top of large frameworks, it&amp;#39;s simply not practical.  No, simplicity and lightweightyness &lt;sup&gt;(not a real word)&lt;/sup&gt; is the order of the day here.  Small frameworks like &lt;a href="http://www.sinatrarb.com/"&gt;Sinatra&lt;/a&gt;, &lt;a href="https://github.com/webbit/webbit"&gt;Webbit&lt;/a&gt;, &lt;a href="http://twitter.github.io/finagle/"&gt;Finagle&lt;/a&gt; &amp;amp; &lt;a href="http://www.senchalabs.org/connect/"&gt;Connect&lt;/a&gt; do just enough to allow you to wrap your actual code in a thin communication layer.&lt;/p&gt;

&lt;p&gt;In terms of a footprint these services will be small, you&amp;#39;re potentially going to run a lot of them on the same machine so you don&amp;#39;t want to be holding on to memory or resources that you aren&amp;#39;t intending to use.  Once again simple libraries over large frameworks will win out, you&amp;#39;ll also find less of a reliance on 3rd party dependencies.&lt;/p&gt;

&lt;p&gt;This decoupling at a service level also offers another interesting option.  We&amp;#39;ve pushed a lot of the old application complexity down to infrastructure level.  We are no longer bound to a single stack or language.  We can play to the strengths of any stack or language now.  It&amp;#39;s entirely possible to have a system built out with a myriad of languages and libraries, though as we will touch on later this is a double edged sword.&lt;/p&gt;

&lt;p&gt;You&amp;#39;re also not going to find any true micro service based architectures that are hosted in an application server, that kinds of defeats the point.  To this end micro services self host, they grab a port and listen.  This means you&amp;#39;ll lose any benefits your typical enterprise application server may bring and your service will need to provide some of the more essential ones (instrumentation, monitoring etc.).&lt;/p&gt;

&lt;h2&gt;Communication&lt;/h2&gt;

&lt;p&gt;This is an interesting one.  How do your services communicate?  There really isn&amp;#39;t a single answer for this, even in a single solution.  The most basic approach across the board would be to expose all services over HTTP and pass JSON back and forth.  Service discovery (how one service knows where to find another) can be as simple as putting the endpoint details into a configuration file (or simply hardcoded).  &lt;/p&gt;

&lt;p&gt;You may discover, in certain circumstances, the cost of serialising and deserialising JSON payloads through an entire &lt;em&gt;transaction&lt;/em&gt; is causing bottlenecks.  Perhaps JSON isn&amp;#39;t suitable at all (binary formats) and so you&amp;#39;ll want to look at different protocols, like &lt;a href="https://code.google.com/p/protobuf/"&gt;Protobuf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But hardcoded urls kind of imply a certain strict coupling and A-B-C workflow.  In a layered application this makes sense but moving into a service based architecture means you&amp;#39;re not bound by this (potential) constraint.  Some communications between services can be completely decoupled, in fact some services could publish events or data blindly.  They can just throw it into the ether (or at least a message bus) and maybe one day some service can come along and start listening.  Alternatively maybe parts of your system could operate in a batch/offline process, feeding off a queue and flipping bits many hours later.  &lt;/p&gt;

&lt;p&gt;&lt;img alt="Micro Service Architecture Comms" src="/images/blog/micro-service-architecture-comms.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;A micro service approach gives you this kind of flexibility without major architectural rework.&lt;/p&gt;

&lt;h2&gt;Monitoring &amp;amp; Metrics&lt;/h2&gt;

&lt;p&gt;Components of a monolithic, layered solution don&amp;#39;t typically fail silently - it either fails to compile or throws exceptions when something is wrong (unless you go out of your way and silently swallow exceptions like some insane person).  In a service based approach a service might drop off the face of the earth and it&amp;#39;s very easy for no other service to notice (especially in a pub/sub model).  This means it&amp;#39;s imperative that services are properly monitored and orchestrated.  In fact just knowing a service is alive is seldom good enough.  Is it providing enough business benefit? Is it even being used anymore? Is it acting as a bottleneck for reliant transactions?&lt;/p&gt;

&lt;p&gt;Monitoring is always important but more so in a service based architecture where failure is often less obvious.  Good examples of this from the JVM world are &lt;a href="http://metrics.codahale.com/"&gt;Metrics&lt;/a&gt; and &lt;a href="https://github.com/twitter/ostrich"&gt;Ostrich&lt;/a&gt; these libraries not only allow for collection of metrics but provide a means of integrating and reporting that data into other services like &lt;a href="http://www.nagios.org/"&gt;Nagios&lt;/a&gt; or &lt;a href="http://ganglia.sourceforge.net/"&gt;Ganglia&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Testing&lt;/h2&gt;

&lt;p&gt;There is nothing particularly special about testing services in a micro service based system but the point I want to raise here is that you&amp;#39;ve reduced the need to have a full suite of tests for every service.  Because a service does one thing, and should do it well the risk of introducing a system breaking bug is significantly reduced thanks to the natural behavior of a service based system.  Now writing tests for the sake of it, or just in case, holds little to no value but still require the same amount of care or attention during refactoring.&lt;/p&gt;

&lt;p&gt;I&amp;#39;m not saying &lt;em&gt;don&amp;#39;t&lt;/em&gt; test but I am recommending you think before you use the old &amp;ldquo;No. of Tests&amp;rdquo; as a value of code quality.&lt;/p&gt;

&lt;p&gt;In fact lets go one step further and change the way we test entirely.  You&amp;#39;ve got monitoring in place, at any given time you can know what services are broken and recover.  But also why not monitor key business metrics on each service and use them as indicators to know if we&amp;#39;ve broken something.  This is commonly known as a production immune system.  If conversions are dropping, or sales have halted then you can make it so your system rolls back to a known stable state and gives you nasty looks until you fix the problem.  The same approach can be used for A/B testing and Dark Launching new features and services.&lt;/p&gt;

&lt;p&gt;Micro Service Architecture actually makes a whole lot of sense when it comes to ensuring you have a stable system at any scale.&lt;/p&gt;

&lt;h2&gt;Applications of Micro Service Architecture&lt;/h2&gt;

&lt;p&gt;MSA has a number of interesting applications.  Obviously green field solutions of a given size is an obvious use of this approach.  Though I say &amp;ldquo;given size&amp;rdquo; because the cost incurred at an infrastructure level required to support micro services could outweigh the benefits and, for small systems, a simple web app would be totally acceptable.&lt;/p&gt;

&lt;p&gt;Micro Services also have an interesting application in large legacy systems.  Working with legacy code is risky at best.  For systems that have been running for decades there is a chance there is limited knowledge in how the systems actually works internally.  Working with this code can be like working with a house of cards and a simple mistake in one place can have adverse affects elsewhere.  These systems are typically mission critical so mistakes can be costly.  So just don&amp;#39;t touch it.  The micro service approach lets you do this.  Rather than diving into the legacy code base, write a small service that does what you need (yes you may be duplicating legacy code) and proxy service calls through it (e.g. via nginx/apache etc or purely within code).  &lt;/p&gt;

&lt;p&gt;&lt;img alt="Micro Service Architecture Proxy" src="/images/blog/micro-service-architecture-proxy.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Now imagine doing this regularly as part of your maintenance and support program.  You&amp;#39;ll be turning off the old system bit by bit and perhaps eventually be able to turn it off completely.&lt;/p&gt;

&lt;h2&gt;Issues&lt;/h2&gt;

&lt;p&gt;Micro Service based systems aren&amp;#39;t without their problems of course.  For one there is a greater need to better understand non-development areas.  In days of old before DevOps was a broadly misunderstood marketing term developers would deliver working systems over the wall to operations who would deploy it to production and everything would fail.  Of course this was the ops team fault, don&amp;#39;t they know anything?  Jeez.  It was entirely possible for a developer to know only code, running the entire application from their IDE without thinking about how this would work in real life.  MSA forces the developers hand to actually be more responsible and actually get involved in scripting of deployments and understanding integration requirements etc.&lt;/p&gt;

&lt;p&gt;Another issue that I touched on earlier is the fact, left unchecked you could have hundreds of small services written in hundreds of languages.  Simply managing that sort of estate of languages and platforms with their different installations, package managers and requirements can stop a project dead in its tracks.&lt;/p&gt;

&lt;p&gt;An anti-pattern has emerged from the MSA approach - often called the Nano-Service architecture.  These are systems built on services that are so small that duplication of effort is prevalent and it becomes almost impossible to reason about any particular area of a system easily.&lt;/p&gt;

&lt;h2&gt;Macro Post for Micro Services&lt;/h2&gt;

&lt;p&gt;The irony of a large wall of text to introduce the concept of micro services is not lost on me but there is lots to consider.  Micro Service based systems can produce scalable, fault tolerant systems on fairly low cost hardware.  MSA promotes good practices of keeping things lightweight, emerging systems and business monitoring but as with everything should be approached with a rational mindset and solid understanding of what you &lt;strong&gt;need&lt;/strong&gt; to achieve.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;img alt="Micro Service Architecture" src="/images/blog/micro-service-architecture.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Micro Service Architecture is an architectural concept that aims to decouple a solution by decomposing functionality into discrete services.  Think of it as applying many of the principles of &lt;a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)"&gt;SOLID&lt;/a&gt; at an architectural level, instead of classes you&amp;#39;ve got services.&lt;/p&gt;

&lt;p&gt;Conceptually speaking MSA is not particularly difficult to grasp but in practice it does raise many questions.  How do these services communicate? What about latency between services? How do you test the services?  How do you detect and respond to failure? How do you manage deployments when you have a bunch of interdependencies?  So lets expand on some of these throughout this post and see if MSA really is worth the effort.&lt;/p&gt;

&lt;h2&gt;Anatomy of a Micro Service&lt;/h2&gt;

&lt;p&gt;First things first what actually &lt;strong&gt;is&lt;/strong&gt; a micro service?  Well there really isn&amp;#39;t a hard and fast definition but from conversations with various people there seems to be a consensus that a micro service is a simple application that sits around the 10-100 LOC mark.  Now I realise that line count is an atrocious way to compare implementations so take what you will from that.  But they are small, micro even. This means you&amp;#39;re not going to find hundreds of tiny services built on top of large frameworks, it&amp;#39;s simply not practical.  No, simplicity and lightweightyness &lt;sup&gt;(not a real word)&lt;/sup&gt; is the order of the day here.  Small frameworks like &lt;a href="http://www.sinatrarb.com/"&gt;Sinatra&lt;/a&gt;, &lt;a href="https://github.com/webbit/webbit"&gt;Webbit&lt;/a&gt;, &lt;a href="http://twitter.github.io/finagle/"&gt;Finagle&lt;/a&gt; &amp;amp; &lt;a href="http://www.senchalabs.org/connect/"&gt;Connect&lt;/a&gt; do just enough to allow you to wrap your actual code in a thin communication layer.&lt;/p&gt;

&lt;p&gt;In terms of a footprint these services will be small, you&amp;#39;re potentially going to run a lot of them on the same machine so you don&amp;#39;t want to be holding on to memory or resources that you aren&amp;#39;t intending to use.  Once again simple libraries over large frameworks will win out, you&amp;#39;ll also find less of a reliance on 3rd party dependencies.&lt;/p&gt;

&lt;p&gt;This decoupling at a service level also offers another interesting option.  We&amp;#39;ve pushed a lot of the old application complexity down to infrastructure level.  We are no longer bound to a single stack or language.  We can play to the strengths of any stack or language now.  It&amp;#39;s entirely possible to have a system built out with a myriad of languages and libraries, though as we will touch on later this is a double edged sword.&lt;/p&gt;

&lt;p&gt;You&amp;#39;re also not going to find any true micro service based architectures that are hosted in an application server, that kinds of defeats the point.  To this end micro services self host, they grab a port and listen.  This means you&amp;#39;ll lose any benefits your typical enterprise application server may bring and your service will need to provide some of the more essential ones (instrumentation, monitoring etc.).&lt;/p&gt;

&lt;h2&gt;Communication&lt;/h2&gt;

&lt;p&gt;This is an interesting one.  How do your services communicate?  There really isn&amp;#39;t a single answer for this, even in a single solution.  The most basic approach across the board would be to expose all services over HTTP and pass JSON back and forth.  Service discovery (how one service knows where to find another) can be as simple as putting the endpoint details into a configuration file (or simply hardcoded).  &lt;/p&gt;

&lt;p&gt;You may discover, in certain circumstances, the cost of serialising and deserialising JSON payloads through an entire &lt;em&gt;transaction&lt;/em&gt; is causing bottlenecks.  Perhaps JSON isn&amp;#39;t suitable at all (binary formats) and so you&amp;#39;ll want to look at different protocols, like &lt;a href="https://code.google.com/p/protobuf/"&gt;Protobuf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But hardcoded urls kind of imply a certain strict coupling and A-B-C workflow.  In a layered application this makes sense but moving into a service based architecture means you&amp;#39;re not bound by this (potential) constraint.  Some communications between services can be completely decoupled, in fact some services could publish events or data blindly.  They can just throw it into the ether (or at least a message bus) and maybe one day some service can come along and start listening.  Alternatively maybe parts of your system could operate in a batch/offline process, feeding off a queue and flipping bits many hours later.  &lt;/p&gt;

&lt;p&gt;&lt;img alt="Micro Service Architecture Comms" src="/images/blog/micro-service-architecture-comms.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;A micro service approach gives you this kind of flexibility without major architectural rework.&lt;/p&gt;

&lt;h2&gt;Monitoring &amp;amp; Metrics&lt;/h2&gt;

&lt;p&gt;Components of a monolithic, layered solution don&amp;#39;t typically fail silently - it either fails to compile or throws exceptions when something is wrong (unless you go out of your way and silently swallow exceptions like some insane person).  In a service based approach a service might drop off the face of the earth and it&amp;#39;s very easy for no other service to notice (especially in a pub/sub model).  This means it&amp;#39;s imperative that services are properly monitored and orchestrated.  In fact just knowing a service is alive is seldom good enough.  Is it providing enough business benefit? Is it even being used anymore? Is it acting as a bottleneck for reliant transactions?&lt;/p&gt;

&lt;p&gt;Monitoring is always important but more so in a service based architecture where failure is often less obvious.  Good examples of this from the JVM world are &lt;a href="http://metrics.codahale.com/"&gt;Metrics&lt;/a&gt; and &lt;a href="https://github.com/twitter/ostrich"&gt;Ostrich&lt;/a&gt; these libraries not only allow for collection of metrics but provide a means of integrating and reporting that data into other services like &lt;a href="http://www.nagios.org/"&gt;Nagios&lt;/a&gt; or &lt;a href="http://ganglia.sourceforge.net/"&gt;Ganglia&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Testing&lt;/h2&gt;

&lt;p&gt;There is nothing particularly special about testing services in a micro service based system but the point I want to raise here is that you&amp;#39;ve reduced the need to have a full suite of tests for every service.  Because a service does one thing, and should do it well the risk of introducing a system breaking bug is significantly reduced thanks to the natural behavior of a service based system.  Now writing tests for the sake of it, or just in case, holds little to no value but still require the same amount of care or attention during refactoring.&lt;/p&gt;

&lt;p&gt;I&amp;#39;m not saying &lt;em&gt;don&amp;#39;t&lt;/em&gt; test but I am recommending you think before you use the old &amp;ldquo;No. of Tests&amp;rdquo; as a value of code quality.&lt;/p&gt;

&lt;p&gt;In fact lets go one step further and change the way we test entirely.  You&amp;#39;ve got monitoring in place, at any given time you can know what services are broken and recover.  But also why not monitor key business metrics on each service and use them as indicators to know if we&amp;#39;ve broken something.  This is commonly known as a production immune system.  If conversions are dropping, or sales have halted then you can make it so your system rolls back to a known stable state and gives you nasty looks until you fix the problem.  The same approach can be used for A/B testing and Dark Launching new features and services.&lt;/p&gt;

&lt;p&gt;Micro Service Architecture actually makes a whole lot of sense when it comes to ensuring you have a stable system at any scale.&lt;/p&gt;

&lt;h2&gt;Applications of Micro Service Architecture&lt;/h2&gt;

&lt;p&gt;MSA has a number of interesting applications.  Obviously green field solutions of a given size is an obvious use of this approach.  Though I say &amp;ldquo;given size&amp;rdquo; because the cost incurred at an infrastructure level required to support micro services could outweigh the benefits and, for small systems, a simple web app would be totally acceptable.&lt;/p&gt;

&lt;p&gt;Micro Services also have an interesting application in large legacy systems.  Working with legacy code is risky at best.  For systems that have been running for decades there is a chance there is limited knowledge in how the systems actually works internally.  Working with this code can be like working with a house of cards and a simple mistake in one place can have adverse affects elsewhere.  These systems are typically mission critical so mistakes can be costly.  So just don&amp;#39;t touch it.  The micro service approach lets you do this.  Rather than diving into the legacy code base, write a small service that does what you need (yes you may be duplicating legacy code) and proxy service calls through it (e.g. via nginx/apache etc or purely within code).  &lt;/p&gt;

&lt;p&gt;&lt;img alt="Micro Service Architecture Proxy" src="/images/blog/micro-service-architecture-proxy.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Now imagine doing this regularly as part of your maintenance and support program.  You&amp;#39;ll be turning off the old system bit by bit and perhaps eventually be able to turn it off completely.&lt;/p&gt;

&lt;h2&gt;Issues&lt;/h2&gt;

&lt;p&gt;Micro Service based systems aren&amp;#39;t without their problems of course.  For one there is a greater need to better understand non-development areas.  In days of old before DevOps was a broadly misunderstood marketing term developers would deliver working systems over the wall to operations who would deploy it to production and everything would fail.  Of course this was the ops team fault, don&amp;#39;t they know anything?  Jeez.  It was entirely possible for a developer to know only code, running the entire application from their IDE without thinking about how this would work in real life.  MSA forces the developers hand to actually be more responsible and actually get involved in scripting of deployments and understanding integration requirements etc.&lt;/p&gt;

&lt;p&gt;Another issue that I touched on earlier is the fact, left unchecked you could have hundreds of small services written in hundreds of languages.  Simply managing that sort of estate of languages and platforms with their different installations, package managers and requirements can stop a project dead in its tracks.&lt;/p&gt;

&lt;p&gt;An anti-pattern has emerged from the MSA approach - often called the Nano-Service architecture.  These are systems built on services that are so small that duplication of effort is prevalent and it becomes almost impossible to reason about any particular area of a system easily.&lt;/p&gt;

&lt;h2&gt;Macro Post for Micro Services&lt;/h2&gt;

&lt;p&gt;The irony of a large wall of text to introduce the concept of micro services is not lost on me but there is lots to consider.  Micro Service based systems can produce scalable, fault tolerant systems on fairly low cost hardware.  MSA promotes good practices of keeping things lightweight, emerging systems and business monitoring but as with everything should be approached with a rational mindset and solid understanding of what you &lt;strong&gt;need&lt;/strong&gt; to achieve.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Rice</title>
    <link rel="alternate" href="/blog/2013/04/21/rice"/>
    <id>/blog/2013/04/21/rice</id>
    <published>2013-04-21T00:00:00+01:00</published>
    <updated>2013-04-21T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;img alt="Rice" src="/images/blog/rice.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Rice.  A swamp grass that we consume, awesome.  But how do you prepare rice?  You could,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Buy it in pre-prepared microwave packets&lt;/li&gt;
&lt;li&gt;Buy a rice cooker&lt;/li&gt;
&lt;li&gt;Make it yourself using some water and a suacepan&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Theres probably more but that would detract from my carefully constructed metaphor (I&amp;#39;m not drunk, honest).  So whats the point?  Well lets think about the pros and cons of each.&lt;/p&gt;

&lt;h2&gt;Buying In&lt;/h2&gt;

&lt;p&gt;You can buy these little pouches of rice that you pop in the microwave for 3 minutes and &lt;bing&gt; you&amp;#39;ve got hot steamy rice. Sort of.  It&amp;#39;s never perfect.  The work involved in taking a perishable food stuff and making it &amp;ldquo;less&amp;rdquo; perishable, packaging it and shipping it around the world kind of degrades the product a bit.  You ultimately have to trade off quality for convenience.  You can certainly add ingredients to the rice to rejuvenate it but its never quite same and lets be honest the packet size is always either too big or too small and you end up wasting some. &lt;/p&gt;

&lt;h2&gt;Using a Rice Cooker&lt;/h2&gt;

&lt;p&gt;Rice cookers typically cook rice really well but they are an investment, you may only use it occasionally, some of them are a pain to clean and you&amp;#39;ve always got to find space for it in your kitchen (if you had a fancy tool for every type of food you&amp;#39;d need a much bigger kitchen).  Plus these things don&amp;#39;t really scale very well.  They typically make a certain size and if you want more than that you need to start doing it in batches or invest in another rice cooker.  &lt;/p&gt;

&lt;h2&gt;Make it Yourself&lt;/h2&gt;

&lt;p&gt;Rice can be a pain in the ass to cook, it sounds simple.  Too little water and it burns and sticks to the bottom of the pan, too much and it boils over leaving starchy water everywhere.  You can under-cook it, or wore overcook it into a stogy mess.  If you get distracted or try to do too many other things its easy for things to go bad and you&amp;#39;ll be left with a mess that needs cleaning up.  Then theres the problem of judging the right amount of rice to cook.  Eventually though, after a spot of trial and error, cooking rice without fancy tools becomes rather easy and predictable.&lt;/p&gt;

&lt;h2&gt;A Carefully Constructed Metaphor&lt;/h2&gt;

&lt;p&gt;I did mention previously that this was a metaphor and I wasn&amp;#39;t lying.  I&amp;#39;ve been mulling over this analogy for a while (while I was cooking rice for real).  In software you&amp;#39;ve got similar approaches to delivery,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can buy an off-the-shelf solution that accomplishes most things&lt;/li&gt;
&lt;li&gt;You can use a framework with all the bells and whistles&lt;/li&gt;
&lt;li&gt;You can roll your own solution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The all have their own trade-offs that align well with the rice metaphor.  &lt;/p&gt;

&lt;p&gt;Off the shelf products give you a certain level of convenience provided you are willing to live with that you are often compromising user experience to satisfy the view of a &amp;ldquo;typical user&amp;rdquo; that the product must adhere to to appeal to wide user base.  And yes you can typically add your own ingredients through extra development work but it&amp;#39;s never quite right.&lt;/p&gt;

&lt;p&gt;By using a large framework you&amp;#39;ve got accept a certain amount of upfront complexity for the future promise of making the delivery of solutions easier.  Much like the rice cooker, frameworks will invariably bring with them a slew of features that you&amp;#39;ll never use.  However there will always be the need to manage and cope with that extra complexity and often the cost of this complexity (setting up boilerplate for a new feature, writing a bunch of configuration to allow the framework to do it&amp;#39;s magic etc.) could be greater than the value a small feature provides.  Features users want will be deferred because of decisions they did not have a say in.&lt;/p&gt;

&lt;p&gt;Finally the idea of making your own rice, or using a minimal set of common tools to deliver the right amount features.  Yes it may seem initially daunting, you&amp;#39;ll probably get it wrong a few times (do too much or not enough) but eventually you&amp;#39;ll build up enough knowledge and skill that you can see that reliance on heavy abstractions is often more of a burden than a help.  While rolling your own may appear as unnecessary risk - taking this approach in small steps is significantly less risky than pinning all your hopes in a frameworks sales pitch or the promise of buy-and-run COTS products.  &lt;/p&gt;

&lt;p&gt;Building your own stuff has the added future benefit of letting you make more informed decisions.  Clearly there is no one right answer for every situation - sometimes you may just benefit from firing up a ready rolled WordPress site, or, perhaps Middleman or Jekyll would fit in well with the publishing strategy of the project, but sometimes a simple &lt;code&gt;Makefile&lt;/code&gt; with a bunch of &lt;code&gt;sed&lt;/code&gt; calls will do the job.  &lt;/p&gt;

&lt;p&gt;Finally the simple act of actually trying build your own solutions will give you greater clarity when you need to answer questions around build vs buy or technology choices.  Just because frameworks, tools and products allow you to be ignorant of many things it doesn&amp;#39;t mean you should be.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;img alt="Rice" src="/images/blog/rice.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Rice.  A swamp grass that we consume, awesome.  But how do you prepare rice?  You could,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Buy it in pre-prepared microwave packets&lt;/li&gt;
&lt;li&gt;Buy a rice cooker&lt;/li&gt;
&lt;li&gt;Make it yourself using some water and a suacepan&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Theres probably more but that would detract from my carefully constructed metaphor (I&amp;#39;m not drunk, honest).  So whats the point?  Well lets think about the pros and cons of each.&lt;/p&gt;

&lt;h2&gt;Buying In&lt;/h2&gt;

&lt;p&gt;You can buy these little pouches of rice that you pop in the microwave for 3 minutes and &lt;bing&gt; you&amp;#39;ve got hot steamy rice. Sort of.  It&amp;#39;s never perfect.  The work involved in taking a perishable food stuff and making it &amp;ldquo;less&amp;rdquo; perishable, packaging it and shipping it around the world kind of degrades the product a bit.  You ultimately have to trade off quality for convenience.  You can certainly add ingredients to the rice to rejuvenate it but its never quite same and lets be honest the packet size is always either too big or too small and you end up wasting some. &lt;/p&gt;

&lt;h2&gt;Using a Rice Cooker&lt;/h2&gt;

&lt;p&gt;Rice cookers typically cook rice really well but they are an investment, you may only use it occasionally, some of them are a pain to clean and you&amp;#39;ve always got to find space for it in your kitchen (if you had a fancy tool for every type of food you&amp;#39;d need a much bigger kitchen).  Plus these things don&amp;#39;t really scale very well.  They typically make a certain size and if you want more than that you need to start doing it in batches or invest in another rice cooker.  &lt;/p&gt;

&lt;h2&gt;Make it Yourself&lt;/h2&gt;

&lt;p&gt;Rice can be a pain in the ass to cook, it sounds simple.  Too little water and it burns and sticks to the bottom of the pan, too much and it boils over leaving starchy water everywhere.  You can under-cook it, or wore overcook it into a stogy mess.  If you get distracted or try to do too many other things its easy for things to go bad and you&amp;#39;ll be left with a mess that needs cleaning up.  Then theres the problem of judging the right amount of rice to cook.  Eventually though, after a spot of trial and error, cooking rice without fancy tools becomes rather easy and predictable.&lt;/p&gt;

&lt;h2&gt;A Carefully Constructed Metaphor&lt;/h2&gt;

&lt;p&gt;I did mention previously that this was a metaphor and I wasn&amp;#39;t lying.  I&amp;#39;ve been mulling over this analogy for a while (while I was cooking rice for real).  In software you&amp;#39;ve got similar approaches to delivery,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can buy an off-the-shelf solution that accomplishes most things&lt;/li&gt;
&lt;li&gt;You can use a framework with all the bells and whistles&lt;/li&gt;
&lt;li&gt;You can roll your own solution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The all have their own trade-offs that align well with the rice metaphor.  &lt;/p&gt;

&lt;p&gt;Off the shelf products give you a certain level of convenience provided you are willing to live with that you are often compromising user experience to satisfy the view of a &amp;ldquo;typical user&amp;rdquo; that the product must adhere to to appeal to wide user base.  And yes you can typically add your own ingredients through extra development work but it&amp;#39;s never quite right.&lt;/p&gt;

&lt;p&gt;By using a large framework you&amp;#39;ve got accept a certain amount of upfront complexity for the future promise of making the delivery of solutions easier.  Much like the rice cooker, frameworks will invariably bring with them a slew of features that you&amp;#39;ll never use.  However there will always be the need to manage and cope with that extra complexity and often the cost of this complexity (setting up boilerplate for a new feature, writing a bunch of configuration to allow the framework to do it&amp;#39;s magic etc.) could be greater than the value a small feature provides.  Features users want will be deferred because of decisions they did not have a say in.&lt;/p&gt;

&lt;p&gt;Finally the idea of making your own rice, or using a minimal set of common tools to deliver the right amount features.  Yes it may seem initially daunting, you&amp;#39;ll probably get it wrong a few times (do too much or not enough) but eventually you&amp;#39;ll build up enough knowledge and skill that you can see that reliance on heavy abstractions is often more of a burden than a help.  While rolling your own may appear as unnecessary risk - taking this approach in small steps is significantly less risky than pinning all your hopes in a frameworks sales pitch or the promise of buy-and-run COTS products.  &lt;/p&gt;

&lt;p&gt;Building your own stuff has the added future benefit of letting you make more informed decisions.  Clearly there is no one right answer for every situation - sometimes you may just benefit from firing up a ready rolled WordPress site, or, perhaps Middleman or Jekyll would fit in well with the publishing strategy of the project, but sometimes a simple &lt;code&gt;Makefile&lt;/code&gt; with a bunch of &lt;code&gt;sed&lt;/code&gt; calls will do the job.  &lt;/p&gt;

&lt;p&gt;Finally the simple act of actually trying build your own solutions will give you greater clarity when you need to answer questions around build vs buy or technology choices.  Just because frameworks, tools and products allow you to be ignorant of many things it doesn&amp;#39;t mean you should be.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Hardening Sprints: Just Say No?</title>
    <link rel="alternate" href="/blog/2013/04/18/hardening-sprints-just-say-no"/>
    <id>/blog/2013/04/18/hardening-sprints-just-say-no</id>
    <published>2013-04-18T00:00:00+01:00</published>
    <updated>2013-04-18T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;img alt="We’ll Just Squeeze the other bricks in when we’re done with the house" src="/images/blog/hardening-sprints.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;I was recently asked by a PM in my company if &amp;ldquo;hardening sprints&amp;rdquo; are allowed in agile projects and I gave the very pragmatic answer of &amp;ldquo;you do what needs to be done&amp;rdquo;.  I left the conversation not feeling right though and I&amp;#39;ve been thinking about the question ever since.  To be honest my gut instinct is that, with certain exceptions, these sort of sprints are a smell and their origins are firmly rooted in phased/waterfall delivery.  I&amp;#39;ll address the &lt;em&gt;&amp;ldquo;with certain exceptions&amp;rdquo;&lt;/em&gt; caveat a bit later but lets first dive into the idea of hardening sprints.&lt;/p&gt;

&lt;h2&gt;What is a hardening sprint?&lt;/h2&gt;

&lt;p&gt;A hardening sprint is a timebox or sprint reserved at the end of a group of sprints (usually prior to release) to allow testing or hardening of the release.  This could mean extra testing, different types of testing, refactoring, reviews etc.  It brings with it the rather bizarre concept of &amp;ldquo;Done Done&amp;rdquo; - i.e. features that have been delivered in previous sprints may be &amp;ldquo;Done&amp;rdquo; but not &amp;ldquo;Done Done&amp;rdquo;.  So it may be coded and &amp;ldquo;kind-of&amp;rdquo; working and &amp;ldquo;kind-of&amp;rdquo; tested and people are &amp;ldquo;kind-of&amp;rdquo; happy with it and yeah its &amp;ldquo;kind-of&amp;rdquo; done but we&amp;#39;ll wait until the end to know if we are really done.&lt;/p&gt;

&lt;h2&gt;So What?&lt;/h2&gt;

&lt;p&gt;It strikes me as &amp;ldquo;kind-of&amp;rdquo; odd that this sort of thing happens without people raising an eyebrow.  For one thing there is no such thing as &amp;ldquo;Done Done&amp;rdquo; and if we don&amp;#39;t admit it I fear that we&amp;#39;ll see &amp;ldquo;Done Done Done&amp;rdquo; pushing its way into our process vocabulary.  &lt;/p&gt;

&lt;p&gt;The next thing that strikes me - there is absolutely no data available to predict how long this &amp;ldquo;hardening&amp;rdquo; process should take.  If we take it at face value the term implies a single sprint.  How can we be sure whatever unpredicatable stuff comes up during that sprint can actually be addressed and adequatley resolved in that sprint?  Or, taking it to the other extreme (indefinite amount of sprints) how do we know when to stop - afterall nothing is ever perfect.&lt;/p&gt;

&lt;h2&gt;Undoing All The Good Work?&lt;/h2&gt;

&lt;p&gt;So we&amp;#39;ve spent X amount of sprints refining our approach to delivery, continually improving and learning and now we&amp;#39;ve thrown the project into this huge dark pit of uncertainty and &amp;ldquo;hardening&amp;rdquo;.  Surely I&amp;#39;m not alone in thinking this sounds somewhat wrong.&lt;/p&gt;

&lt;p&gt;Another risk is that this kind of strucutre will create is a potential reduction in ongoing quality.  It could be argued that hardening sprints, much like the old phased/waterfall approach to delivery, removes a certain amount of responsibility from the delivery team.  Now there is less of a desire for developers to apply as much rigour to their code as they may have - afterall &lt;em&gt;&amp;ldquo;the testers will find the bugs so why waste my time being thorough?&amp;rdquo;&lt;/em&gt;.  But if you are deferring your user or penetration testing a few months down the line there is always this notion that the team can just &lt;em&gt;&amp;ldquo;throw it in and see what comes out in the wash&amp;rdquo;&lt;/em&gt;. &lt;/p&gt;

&lt;h2&gt;&amp;ldquo;With Certain Exceptions&amp;rdquo;&lt;/h2&gt;

&lt;p&gt;Of course, like every rule, there may be exceptions.  One obvious exception is external penetration testing.  There can be considerable cost and time assoicated with getting a third party specialist in and its certainly not viable to do it every sprint.  So defering a full pen testing cycle until near the release is an acceptable and often necessary exception.  But that doesn&amp;#39;t mean the team should throw all care about security out the window - the goal of the penetration testing should be to validate that there are no vulnerabilities not to discover them.&lt;/p&gt;

&lt;h2&gt;Next Time Gadget&amp;hellip; Next Time&lt;/h2&gt;

&lt;p&gt;So are &amp;ldquo;hardening sprints&amp;rdquo; a good idea?  I&amp;#39;m inclined, as negative as it may be, to start with &amp;ldquo;no&amp;rdquo; and take it from there, afterall its better to start with discovering &lt;strong&gt;why we can&amp;#39;t&lt;/strong&gt; do certain things inside of a sprint rather than assume &lt;strong&gt;we can&amp;#39;t&lt;/strong&gt; and carry on ignorant of the potential benefits.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;img alt="We’ll Just Squeeze the other bricks in when we’re done with the house" src="/images/blog/hardening-sprints.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;I was recently asked by a PM in my company if &amp;ldquo;hardening sprints&amp;rdquo; are allowed in agile projects and I gave the very pragmatic answer of &amp;ldquo;you do what needs to be done&amp;rdquo;.  I left the conversation not feeling right though and I&amp;#39;ve been thinking about the question ever since.  To be honest my gut instinct is that, with certain exceptions, these sort of sprints are a smell and their origins are firmly rooted in phased/waterfall delivery.  I&amp;#39;ll address the &lt;em&gt;&amp;ldquo;with certain exceptions&amp;rdquo;&lt;/em&gt; caveat a bit later but lets first dive into the idea of hardening sprints.&lt;/p&gt;

&lt;h2&gt;What is a hardening sprint?&lt;/h2&gt;

&lt;p&gt;A hardening sprint is a timebox or sprint reserved at the end of a group of sprints (usually prior to release) to allow testing or hardening of the release.  This could mean extra testing, different types of testing, refactoring, reviews etc.  It brings with it the rather bizarre concept of &amp;ldquo;Done Done&amp;rdquo; - i.e. features that have been delivered in previous sprints may be &amp;ldquo;Done&amp;rdquo; but not &amp;ldquo;Done Done&amp;rdquo;.  So it may be coded and &amp;ldquo;kind-of&amp;rdquo; working and &amp;ldquo;kind-of&amp;rdquo; tested and people are &amp;ldquo;kind-of&amp;rdquo; happy with it and yeah its &amp;ldquo;kind-of&amp;rdquo; done but we&amp;#39;ll wait until the end to know if we are really done.&lt;/p&gt;

&lt;h2&gt;So What?&lt;/h2&gt;

&lt;p&gt;It strikes me as &amp;ldquo;kind-of&amp;rdquo; odd that this sort of thing happens without people raising an eyebrow.  For one thing there is no such thing as &amp;ldquo;Done Done&amp;rdquo; and if we don&amp;#39;t admit it I fear that we&amp;#39;ll see &amp;ldquo;Done Done Done&amp;rdquo; pushing its way into our process vocabulary.  &lt;/p&gt;

&lt;p&gt;The next thing that strikes me - there is absolutely no data available to predict how long this &amp;ldquo;hardening&amp;rdquo; process should take.  If we take it at face value the term implies a single sprint.  How can we be sure whatever unpredicatable stuff comes up during that sprint can actually be addressed and adequatley resolved in that sprint?  Or, taking it to the other extreme (indefinite amount of sprints) how do we know when to stop - afterall nothing is ever perfect.&lt;/p&gt;

&lt;h2&gt;Undoing All The Good Work?&lt;/h2&gt;

&lt;p&gt;So we&amp;#39;ve spent X amount of sprints refining our approach to delivery, continually improving and learning and now we&amp;#39;ve thrown the project into this huge dark pit of uncertainty and &amp;ldquo;hardening&amp;rdquo;.  Surely I&amp;#39;m not alone in thinking this sounds somewhat wrong.&lt;/p&gt;

&lt;p&gt;Another risk is that this kind of strucutre will create is a potential reduction in ongoing quality.  It could be argued that hardening sprints, much like the old phased/waterfall approach to delivery, removes a certain amount of responsibility from the delivery team.  Now there is less of a desire for developers to apply as much rigour to their code as they may have - afterall &lt;em&gt;&amp;ldquo;the testers will find the bugs so why waste my time being thorough?&amp;rdquo;&lt;/em&gt;.  But if you are deferring your user or penetration testing a few months down the line there is always this notion that the team can just &lt;em&gt;&amp;ldquo;throw it in and see what comes out in the wash&amp;rdquo;&lt;/em&gt;. &lt;/p&gt;

&lt;h2&gt;&amp;ldquo;With Certain Exceptions&amp;rdquo;&lt;/h2&gt;

&lt;p&gt;Of course, like every rule, there may be exceptions.  One obvious exception is external penetration testing.  There can be considerable cost and time assoicated with getting a third party specialist in and its certainly not viable to do it every sprint.  So defering a full pen testing cycle until near the release is an acceptable and often necessary exception.  But that doesn&amp;#39;t mean the team should throw all care about security out the window - the goal of the penetration testing should be to validate that there are no vulnerabilities not to discover them.&lt;/p&gt;

&lt;h2&gt;Next Time Gadget&amp;hellip; Next Time&lt;/h2&gt;

&lt;p&gt;So are &amp;ldquo;hardening sprints&amp;rdquo; a good idea?  I&amp;#39;m inclined, as negative as it may be, to start with &amp;ldquo;no&amp;rdquo; and take it from there, afterall its better to start with discovering &lt;strong&gt;why we can&amp;#39;t&lt;/strong&gt; do certain things inside of a sprint rather than assume &lt;strong&gt;we can&amp;#39;t&lt;/strong&gt; and carry on ignorant of the potential benefits.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Teams or People?</title>
    <link rel="alternate" href="/blog/2013/04/08/teams-or-people"/>
    <id>/blog/2013/04/08/teams-or-people</id>
    <published>2013-04-08T00:00:00+01:00</published>
    <updated>2013-04-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;A team is much more than a group of people thrown together for the period of a project.  This is quite common in a utilisation based business model where downtime is viewed, on the balance sheets at least, as money wasted. I&amp;#39;d call that myopic. &lt;/p&gt;

&lt;p&gt;Putting aside other arguments for a moment (downtime is quite often good for allowing motivated people to learn and grow) lets think about &lt;a href="http://en.wikipedia.org/wiki/Tuckman%27s_stages_of_group_development"&gt;Tuckman&amp;#39;s Stages of Group Development&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img alt="Half Baked Tuckmans Model" src="/images/blog/tuckmans.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Tuckmans model suggests that teams go through various stages of development, as denoted above.  During these phases various things happen,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Forming&lt;/strong&gt; - the team comes together shares their history and begins to develop an understanding of the problem to be solved.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Storming&lt;/strong&gt; - after the gentle introduction people begin finding their place in the team.  Dominant parties fight for control, less dominant sniff out their leaders and the power struggle kicks off.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Norming&lt;/strong&gt; - the power struggle is over and people understand their place in the team.  Less impediments occur through communication.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performing&lt;/strong&gt; - the team has gelled and is working effectively, everyone is in the role they need to be and everyone trusts each other.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a final stage - &lt;strong&gt;Adjourning&lt;/strong&gt; where the team, as a collective whole, part ways - but I&amp;#39;ll get to that later.&lt;/p&gt;

&lt;p&gt;What does the y-axis in this pseudo-graph represent?  I guess the obvious answer is team productivity but given the many factors that can affect team productivity/efficacy this isn&amp;#39;t a realistic metric.  No, the y-axis in this case reflects the teams &lt;strong&gt;focus on their goal&lt;/strong&gt; of delivering the solution. In this situation it makes sense that a &amp;ldquo;team&amp;rdquo; become a staple unit of delivery vs the old resource rumble of &amp;ldquo;whoever is free&amp;rdquo;.  Short-lived teams of randomly selected individuals are always going to be operating at sub-optimal levels due to the very nature of team dynamics.  Now here&amp;#39;s the rub - more often than not this performance is nigh on impossible to quantify.  In fact if &amp;ldquo;people as units of delivery&amp;rdquo; has been a thing for a while you&amp;#39;ll find people making excuses for inefficiencies by front-loading of estimates.  What happens then in sales and bids, how can a company who&amp;#39;s estimates are derived due to sub-optimal team output remain competitive but keep their process the same?  One dubious tactic would be for sales team gently massaging numbers and rates to make them more appealing.  This makes the entire delivery process from sales to final delivery of a solution highly inefficient and pressured and we haven&amp;#39;t even touched on the evils of potential overselling and micromanaging!&lt;/p&gt;

&lt;p&gt;So - the &lt;strong&gt;team a a unit of delivery&lt;/strong&gt; makes sense IMHO, but it&amp;#39;s not without it&amp;#39;s problems.  Moving to a team-based model requires a significant jump in company culture, accounting, sales and, if you&amp;#39;ll let me use the word, resourcing.  There are potentially huge visible risks in long stretches of downtime for teams.  Arguably though large visible, almost predictable risks, are significantly better than unquantifiable consistent loses right? At least you can mitigate them.&lt;/p&gt;

&lt;h2&gt;Adjourning&lt;/h2&gt;

&lt;p&gt;A team can&amp;#39;t stay a team forever.  People &lt;a href="http://en.wikipedia.org/wiki/Bus_factor"&gt;get hit buses&lt;/a&gt; or worse get bored and a long lived team that refuses to change is simply another silo of knowledge that methodologies like agile try and crack open.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;adjouring&lt;/strong&gt; the team isn&amp;#39;t about throwing the core team to the wind.  Too much team churn and you end up back a square one.  Too little team churn and you&amp;#39;ve got the silo problem.  Team members should be rotated to allow knowledge to propagate (inwards and outwards from the original teams perspective).  However this clearly brings its own problems (is a person who&amp;#39;s constantly rotated really ever part of a team) and the balance needs to be struck over time.  &lt;/p&gt;

&lt;p&gt;Spotify is decent example for this sort of cross-team knowledge sharing and I&amp;#39;d recommend checking out &lt;a href="https://dl.dropbox.com/u/1018963/Articles/SpotifyScaling.pdf"&gt;Scaling Agile @ Spotify&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The team as a unit of delivery&lt;/em&gt; is certainly more suited to product based companies or large, long running projects because it feels more natural.  In a services based outfit or consultancy house being able to ship people about at will is &lt;em&gt;easier&lt;/em&gt; but thats not to say its actually beneficial.  While it brings its own unique challenges team-based resourcing can allow organisations and project to greater realise their true potential.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;A team is much more than a group of people thrown together for the period of a project.  This is quite common in a utilisation based business model where downtime is viewed, on the balance sheets at least, as money wasted. I&amp;#39;d call that myopic. &lt;/p&gt;

&lt;p&gt;Putting aside other arguments for a moment (downtime is quite often good for allowing motivated people to learn and grow) lets think about &lt;a href="http://en.wikipedia.org/wiki/Tuckman%27s_stages_of_group_development"&gt;Tuckman&amp;#39;s Stages of Group Development&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img alt="Half Baked Tuckmans Model" src="/images/blog/tuckmans.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Tuckmans model suggests that teams go through various stages of development, as denoted above.  During these phases various things happen,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Forming&lt;/strong&gt; - the team comes together shares their history and begins to develop an understanding of the problem to be solved.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Storming&lt;/strong&gt; - after the gentle introduction people begin finding their place in the team.  Dominant parties fight for control, less dominant sniff out their leaders and the power struggle kicks off.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Norming&lt;/strong&gt; - the power struggle is over and people understand their place in the team.  Less impediments occur through communication.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performing&lt;/strong&gt; - the team has gelled and is working effectively, everyone is in the role they need to be and everyone trusts each other.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a final stage - &lt;strong&gt;Adjourning&lt;/strong&gt; where the team, as a collective whole, part ways - but I&amp;#39;ll get to that later.&lt;/p&gt;

&lt;p&gt;What does the y-axis in this pseudo-graph represent?  I guess the obvious answer is team productivity but given the many factors that can affect team productivity/efficacy this isn&amp;#39;t a realistic metric.  No, the y-axis in this case reflects the teams &lt;strong&gt;focus on their goal&lt;/strong&gt; of delivering the solution. In this situation it makes sense that a &amp;ldquo;team&amp;rdquo; become a staple unit of delivery vs the old resource rumble of &amp;ldquo;whoever is free&amp;rdquo;.  Short-lived teams of randomly selected individuals are always going to be operating at sub-optimal levels due to the very nature of team dynamics.  Now here&amp;#39;s the rub - more often than not this performance is nigh on impossible to quantify.  In fact if &amp;ldquo;people as units of delivery&amp;rdquo; has been a thing for a while you&amp;#39;ll find people making excuses for inefficiencies by front-loading of estimates.  What happens then in sales and bids, how can a company who&amp;#39;s estimates are derived due to sub-optimal team output remain competitive but keep their process the same?  One dubious tactic would be for sales team gently massaging numbers and rates to make them more appealing.  This makes the entire delivery process from sales to final delivery of a solution highly inefficient and pressured and we haven&amp;#39;t even touched on the evils of potential overselling and micromanaging!&lt;/p&gt;

&lt;p&gt;So - the &lt;strong&gt;team a a unit of delivery&lt;/strong&gt; makes sense IMHO, but it&amp;#39;s not without it&amp;#39;s problems.  Moving to a team-based model requires a significant jump in company culture, accounting, sales and, if you&amp;#39;ll let me use the word, resourcing.  There are potentially huge visible risks in long stretches of downtime for teams.  Arguably though large visible, almost predictable risks, are significantly better than unquantifiable consistent loses right? At least you can mitigate them.&lt;/p&gt;

&lt;h2&gt;Adjourning&lt;/h2&gt;

&lt;p&gt;A team can&amp;#39;t stay a team forever.  People &lt;a href="http://en.wikipedia.org/wiki/Bus_factor"&gt;get hit buses&lt;/a&gt; or worse get bored and a long lived team that refuses to change is simply another silo of knowledge that methodologies like agile try and crack open.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;adjouring&lt;/strong&gt; the team isn&amp;#39;t about throwing the core team to the wind.  Too much team churn and you end up back a square one.  Too little team churn and you&amp;#39;ve got the silo problem.  Team members should be rotated to allow knowledge to propagate (inwards and outwards from the original teams perspective).  However this clearly brings its own problems (is a person who&amp;#39;s constantly rotated really ever part of a team) and the balance needs to be struck over time.  &lt;/p&gt;

&lt;p&gt;Spotify is decent example for this sort of cross-team knowledge sharing and I&amp;#39;d recommend checking out &lt;a href="https://dl.dropbox.com/u/1018963/Articles/SpotifyScaling.pdf"&gt;Scaling Agile @ Spotify&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The team as a unit of delivery&lt;/em&gt; is certainly more suited to product based companies or large, long running projects because it feels more natural.  In a services based outfit or consultancy house being able to ship people about at will is &lt;em&gt;easier&lt;/em&gt; but thats not to say its actually beneficial.  While it brings its own unique challenges team-based resourcing can allow organisations and project to greater realise their true potential.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>The 'New' Value Triangle</title>
    <link rel="alternate" href="/blog/2013/03/30/the-new-value-triangle"/>
    <id>/blog/2013/03/30/the-new-value-triangle</id>
    <published>2013-03-30T00:00:00+00:00</published>
    <updated>2013-03-30T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;img alt="New Value Triangle" src="/images/blog/new-value-triangle.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;A projects delivery effectiveness can be affected by many things.  There is, however, a baseline trade off on three core values and being aware of this trade off can help you make better decisions.  The diagram above highlight these core values,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;New Domain&lt;/strong&gt; - this can be a new problem domain or new challenges within an understood domain.  It may also be considered a &lt;em&gt;new domain&lt;/em&gt; if a large proportion of team have limited or no experience in it. (e.g.coming into the health sector for the first time or possibly new legislation coming into effect).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New Technology&lt;/strong&gt; - New technology can be either mandated (integration work) or just by virtue of the fact technology is always evolving. There are always new (and potentially) improved ways to solve common problems in solutions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New People/Team&lt;/strong&gt; - New people or teams occur when a large proportion of a team has never worked together or are changed between phases.  Depending on the type of organisation you work within you may never work with the same person twice or for very short periods of time.  This is common within utilisation focused service companies for example.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &amp;ldquo;new&amp;rdquo; value triangle proposes that, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given a new project you must only accept up to a maximum of two of the &amp;ldquo;new&amp;rdquo; trade offs.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Obviously the less the better but there will invariably be challenges outside of the project that will have an impact on these values.  Having to cope with all three simultaneously will seriously impede successful delivery of a project and must be avoided at all costs.&lt;/p&gt;

&lt;p&gt;Its worth noting that the term &amp;ldquo;new&amp;rdquo; when looking at each trade-off &lt;strong&gt;on its own merit&lt;/strong&gt; isn&amp;#39;t necessarily a negative thing.  New blood on the team can inject fresh spirit and allow knowledge to propagate beyond the boundary of the team, new technology can speed up delivery of more robust solutions and a new domain can bring considerable business value.  But at scale or combined these &amp;ldquo;new&amp;rdquo; values can become a hindrance on successful delivery.  &lt;/p&gt;

&lt;p&gt;Another consideration is that this is a &lt;strong&gt;general rule&lt;/strong&gt;.  You are not always going to be in a situation that mandates such trade-offs.  Or perhaps you are in a situation that seemingly mandates &lt;strong&gt;all&lt;/strong&gt; of them? It&amp;#39;s possible, with careful thought, to slowly transition through all the &amp;ldquo;new&amp;rdquo; values over time but at any given point its always wise to keep tabs on what you are trading off to ensure you aren&amp;#39;t holding back on the effectiveness of delivery.&lt;/p&gt;

&lt;p&gt;So you&amp;#39;ve got to know when to trade off certain values and when you do what mediation patterns could be applied to prevent unnecessary waste&lt;/p&gt;

&lt;h2&gt;Standardise Technology (&lt;strong&gt;NPT/ND&lt;/strong&gt;)&lt;/h2&gt;

&lt;p&gt;When a team (potentially new to each other) is kicking of a project in a new problem domain (to the team or the organisation at large) there is usually the greatest business risk and as such the team need to be ready for surprises as, and when, they happen.&lt;/p&gt;

&lt;p&gt;One of easiest ways to achieve this is to reduce risk on the technology front.  Standardising and using the most boring, non-shiny, well understood technologies removes any requirement for the team to learn new paradigms and principles while trying to wrap their collective minds around a new domain and potentially &lt;a href="http://en.wikipedia.org/wiki/Tuckman%27s_stages_of_group_development"&gt;getting up to speed&lt;/a&gt; as an effective team.&lt;/p&gt;

&lt;h2&gt;Commoditise Solutions (&lt;strong&gt;NT/NPT&lt;/strong&gt;)&lt;/h2&gt;

&lt;p&gt;From an organisational perspective when you find yourself consistently in a well known domain there is a risk you can begin producing extremely similar systems time and time again.  This is isn&amp;#39;t going to look terrible on the balance sheet but if you have a high team churn there is a lot time being wasted in getting people up to speed that could be avoided.&lt;/p&gt;

&lt;p&gt;This is probably a very good opportunity to commoditise your solution, turn it into a product and sell it.  That way you can establish a baseline consistency via a core team and established technology stack and focus even more on the adding true business value.&lt;/p&gt;

&lt;h2&gt;Iterate &amp;amp; Experiment (&lt;strong&gt;ND/NT&lt;/strong&gt;)&lt;/h2&gt;

&lt;p&gt;Given an established team entering into new domains and technologies the simplest way to reduce risk is to &lt;em&gt;iterate &amp;amp; experiment rapidly&lt;/em&gt;.  If the organisation you work within delivers bespoke software its very likely that the work you do will be within a &lt;em&gt;new domain&lt;/em&gt; or at least a &lt;em&gt;new/different subdomain&lt;/em&gt; of a common domain you typically deliver into.  When introducing new technology as well it&amp;#39;s vital that teams work well and can begin delivering quickly and iteratively to understand both the new domain and any potentially how new technologies fit.&lt;/p&gt;

&lt;p&gt;Having a largely consistent team as your unit of delivery allows us to focus on delivering the right tools to tackle the right problems which adds significantly more business value than the other trade-offs.  Of course - changes are perfectly acceptable &amp;amp; encouraged as long as they aren&amp;#39;t wiping out a large group of the core team in one fell swoop.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;At any point in any project there will be trade-offs.  Many of these trade-offs can be boiled down to something similar to this value triangle and knowing strategies for dealing with these situations allows the project to optimise for the most effective approach.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;img alt="New Value Triangle" src="/images/blog/new-value-triangle.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;A projects delivery effectiveness can be affected by many things.  There is, however, a baseline trade off on three core values and being aware of this trade off can help you make better decisions.  The diagram above highlight these core values,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;New Domain&lt;/strong&gt; - this can be a new problem domain or new challenges within an understood domain.  It may also be considered a &lt;em&gt;new domain&lt;/em&gt; if a large proportion of team have limited or no experience in it. (e.g.coming into the health sector for the first time or possibly new legislation coming into effect).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New Technology&lt;/strong&gt; - New technology can be either mandated (integration work) or just by virtue of the fact technology is always evolving. There are always new (and potentially) improved ways to solve common problems in solutions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New People/Team&lt;/strong&gt; - New people or teams occur when a large proportion of a team has never worked together or are changed between phases.  Depending on the type of organisation you work within you may never work with the same person twice or for very short periods of time.  This is common within utilisation focused service companies for example.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &amp;ldquo;new&amp;rdquo; value triangle proposes that, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given a new project you must only accept up to a maximum of two of the &amp;ldquo;new&amp;rdquo; trade offs.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Obviously the less the better but there will invariably be challenges outside of the project that will have an impact on these values.  Having to cope with all three simultaneously will seriously impede successful delivery of a project and must be avoided at all costs.&lt;/p&gt;

&lt;p&gt;Its worth noting that the term &amp;ldquo;new&amp;rdquo; when looking at each trade-off &lt;strong&gt;on its own merit&lt;/strong&gt; isn&amp;#39;t necessarily a negative thing.  New blood on the team can inject fresh spirit and allow knowledge to propagate beyond the boundary of the team, new technology can speed up delivery of more robust solutions and a new domain can bring considerable business value.  But at scale or combined these &amp;ldquo;new&amp;rdquo; values can become a hindrance on successful delivery.  &lt;/p&gt;

&lt;p&gt;Another consideration is that this is a &lt;strong&gt;general rule&lt;/strong&gt;.  You are not always going to be in a situation that mandates such trade-offs.  Or perhaps you are in a situation that seemingly mandates &lt;strong&gt;all&lt;/strong&gt; of them? It&amp;#39;s possible, with careful thought, to slowly transition through all the &amp;ldquo;new&amp;rdquo; values over time but at any given point its always wise to keep tabs on what you are trading off to ensure you aren&amp;#39;t holding back on the effectiveness of delivery.&lt;/p&gt;

&lt;p&gt;So you&amp;#39;ve got to know when to trade off certain values and when you do what mediation patterns could be applied to prevent unnecessary waste&lt;/p&gt;

&lt;h2&gt;Standardise Technology (&lt;strong&gt;NPT/ND&lt;/strong&gt;)&lt;/h2&gt;

&lt;p&gt;When a team (potentially new to each other) is kicking of a project in a new problem domain (to the team or the organisation at large) there is usually the greatest business risk and as such the team need to be ready for surprises as, and when, they happen.&lt;/p&gt;

&lt;p&gt;One of easiest ways to achieve this is to reduce risk on the technology front.  Standardising and using the most boring, non-shiny, well understood technologies removes any requirement for the team to learn new paradigms and principles while trying to wrap their collective minds around a new domain and potentially &lt;a href="http://en.wikipedia.org/wiki/Tuckman%27s_stages_of_group_development"&gt;getting up to speed&lt;/a&gt; as an effective team.&lt;/p&gt;

&lt;h2&gt;Commoditise Solutions (&lt;strong&gt;NT/NPT&lt;/strong&gt;)&lt;/h2&gt;

&lt;p&gt;From an organisational perspective when you find yourself consistently in a well known domain there is a risk you can begin producing extremely similar systems time and time again.  This is isn&amp;#39;t going to look terrible on the balance sheet but if you have a high team churn there is a lot time being wasted in getting people up to speed that could be avoided.&lt;/p&gt;

&lt;p&gt;This is probably a very good opportunity to commoditise your solution, turn it into a product and sell it.  That way you can establish a baseline consistency via a core team and established technology stack and focus even more on the adding true business value.&lt;/p&gt;

&lt;h2&gt;Iterate &amp;amp; Experiment (&lt;strong&gt;ND/NT&lt;/strong&gt;)&lt;/h2&gt;

&lt;p&gt;Given an established team entering into new domains and technologies the simplest way to reduce risk is to &lt;em&gt;iterate &amp;amp; experiment rapidly&lt;/em&gt;.  If the organisation you work within delivers bespoke software its very likely that the work you do will be within a &lt;em&gt;new domain&lt;/em&gt; or at least a &lt;em&gt;new/different subdomain&lt;/em&gt; of a common domain you typically deliver into.  When introducing new technology as well it&amp;#39;s vital that teams work well and can begin delivering quickly and iteratively to understand both the new domain and any potentially how new technologies fit.&lt;/p&gt;

&lt;p&gt;Having a largely consistent team as your unit of delivery allows us to focus on delivering the right tools to tackle the right problems which adds significantly more business value than the other trade-offs.  Of course - changes are perfectly acceptable &amp;amp; encouraged as long as they aren&amp;#39;t wiping out a large group of the core team in one fell swoop.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;At any point in any project there will be trade-offs.  Many of these trade-offs can be boiled down to something similar to this value triangle and knowing strategies for dealing with these situations allows the project to optimise for the most effective approach.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Uploading Files with Play! 2 </title>
    <link rel="alternate" href="/screencasts/006-uploading-files-with-play-2"/>
    <id>/screencasts/006-uploading-files-with-play-2</id>
    <published>2013-02-25T00:00:00+00:00</published>
    <updated>2013-02-25T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/006-play-file-uploads"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A quick look at how to achieve file uploads with Play! 2 including other form fields and uploading more than one file&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/006-play-file-uploads"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A quick look at how to achieve file uploads with Play! 2 including other form fields and uploading more than one file&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>play-reactivemongo</title>
    <link rel="alternate" href="/screencasts/005-play-reactivemongo"/>
    <id>/screencasts/005-play-reactivemongo</id>
    <published>2013-02-18T00:00:00+00:00</published>
    <updated>2013-02-18T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/005-play-reactivemongo"&gt;Source&lt;/a&gt; | &lt;a href="https://github.com/zenexity/Play-ReactiveMongo"&gt;Official Site&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;play-reactivemongo is a plugin for Play 2.1, enabling support for ReactiveMongo - reactive, asynchronous and non-blocking Scala driver for MongoDB.&lt;/p&gt;

&lt;p&gt;In this episode we will retrofit the app from episode 003 to use Mongo, ReactiveMongo and the play-reactivemongo plugin.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/005-play-reactivemongo"&gt;Source&lt;/a&gt; | &lt;a href="https://github.com/zenexity/Play-ReactiveMongo"&gt;Official Site&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;play-reactivemongo is a plugin for Play 2.1, enabling support for ReactiveMongo - reactive, asynchronous and non-blocking Scala driver for MongoDB.&lt;/p&gt;

&lt;p&gt;In this episode we will retrofit the app from episode 003 to use Mongo, ReactiveMongo and the play-reactivemongo plugin.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>ReactiveMongo</title>
    <link rel="alternate" href="/screencasts/004-reactivemongo"/>
    <id>/screencasts/004-reactivemongo</id>
    <published>2013-02-11T00:00:00+00:00</published>
    <updated>2013-02-11T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/004-reactivemongo"&gt;Source&lt;/a&gt; | &lt;a href="http://reactivemongo.org"&gt;Official Site&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ReactiveMongo is an asynchronous, non-blocking MongoDB driver written in Scala. This screencast will move quickly through the basic concepts that define ReactiveMongo and then show examples of the various basic operations you’d expect from a MongoDB driver&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/004-reactivemongo"&gt;Source&lt;/a&gt; | &lt;a href="http://reactivemongo.org"&gt;Official Site&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ReactiveMongo is an asynchronous, non-blocking MongoDB driver written in Scala. This screencast will move quickly through the basic concepts that define ReactiveMongo and then show examples of the various basic operations you’d expect from a MongoDB driver&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Starter for 10: Play! 2 - Part Three</title>
    <link rel="alternate" href="/screencasts/003-starter-for-10-play-2-part-three"/>
    <id>/screencasts/003-starter-for-10-play-2-part-three</id>
    <published>2013-02-04T00:00:00+00:00</published>
    <updated>2013-02-04T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/003-introducing-play-2/"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part three of the Introducing Play! 2 Series. Play! 2 is a Java/Scala framework based on a lightweight, stateless, web-friendly architecture for highly-scalable applications. This episode will introduce us to the concepts of&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Play Forms for binding request data&lt;/li&gt;
&lt;li&gt;View Helpers, and,&lt;/li&gt;
&lt;li&gt;Form Validation&lt;/li&gt;
&lt;/ul&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/003-introducing-play-2/"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Part three of the Introducing Play! 2 Series. Play! 2 is a Java/Scala framework based on a lightweight, stateless, web-friendly architecture for highly-scalable applications. This episode will introduce us to the concepts of&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Play Forms for binding request data&lt;/li&gt;
&lt;li&gt;View Helpers, and,&lt;/li&gt;
&lt;li&gt;Form Validation&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>Starter for 10: Play! 2 - Part Two</title>
    <link rel="alternate" href="/screencasts/002-starter-for-10-play-2-part-two"/>
    <id>/screencasts/002-starter-for-10-play-2-part-two</id>
    <published>2013-01-27T00:00:00+00:00</published>
    <updated>2013-01-27T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/003-introducing-play-2/tree/spike-1"&gt;SOURCE&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Play! 2 is a Java/Scala framework based on a lightweight, stateless, web-friendly architecture for highly-scalable applications. In this episode we will look at&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating Controllers &amp;amp; Actions&lt;/li&gt;
&lt;li&gt;Creating read-only views&lt;/li&gt;
&lt;li&gt;Routes and URL matching&lt;/li&gt;
&lt;/ul&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="https://github.com/yobriefcasts/003-introducing-play-2/tree/spike-1"&gt;SOURCE&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Play! 2 is a Java/Scala framework based on a lightweight, stateless, web-friendly architecture for highly-scalable applications. In this episode we will look at&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating Controllers &amp;amp; Actions&lt;/li&gt;
&lt;li&gt;Creating read-only views&lt;/li&gt;
&lt;li&gt;Routes and URL matching&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>Screencasts with a JVM flavour</title>
    <link rel="alternate" href="/blog/2013/01/21/screencasts-with-a-jvm-flavour"/>
    <id>/blog/2013/01/21/screencasts-with-a-jvm-flavour</id>
    <published>2013-01-21T00:00:00+00:00</published>
    <updated>2013-01-21T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Today sees the inaugural launch of a new project/passion of mine - &lt;a href="http://yobriefcasts.tv"&gt;yobriefcasts.tv&lt;/a&gt;.  There is a launch post about it on the &lt;a href="http://yobriefcasts.tv"&gt;site&lt;/a&gt; as well as the first in a series of screencasts around Play! 2 (more being edited as you read this no doubt).  Initially I never set out to focus on the world of the JVM but after building a list of potential topics and doing some research there is just so much there and so little audio/visual coverage of it that I think it deserves some attention.&lt;/p&gt;

&lt;p&gt;As it stands right now there is an [optional] price associated with the productions - you can stream everything to your hearts content or you can pay a minimal sum to get a high quality download of the screencast - you can do both if you want.  It took a while to come to an acceptable price point and structure because I have an end goal here - I want to feed any money earned back into the project to get better equipment and thusly produce better quality screencasts.  Futhermore I&amp;#39;d eventually like to turn this into a (mostly) full time gig and move to a subscription model with frequent (weekly) releases - but thats a long way away yet - for now I want to see if I can build something people want and enjoy.&lt;/p&gt;

&lt;p&gt;But hopefully the site can speak for itself - I&amp;#39;ve already got an extensive list of releases coming up over the next while so stay tuned, follow us on &lt;a href="http://twitter.com/yobriefcasts"&gt;twitter as @yobriefcasts&lt;/a&gt; and enjoy the &lt;a href="http://yobriefcasts.tv"&gt;site&lt;/a&gt;.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Today sees the inaugural launch of a new project/passion of mine - &lt;a href="http://yobriefcasts.tv"&gt;yobriefcasts.tv&lt;/a&gt;.  There is a launch post about it on the &lt;a href="http://yobriefcasts.tv"&gt;site&lt;/a&gt; as well as the first in a series of screencasts around Play! 2 (more being edited as you read this no doubt).  Initially I never set out to focus on the world of the JVM but after building a list of potential topics and doing some research there is just so much there and so little audio/visual coverage of it that I think it deserves some attention.&lt;/p&gt;

&lt;p&gt;As it stands right now there is an [optional] price associated with the productions - you can stream everything to your hearts content or you can pay a minimal sum to get a high quality download of the screencast - you can do both if you want.  It took a while to come to an acceptable price point and structure because I have an end goal here - I want to feed any money earned back into the project to get better equipment and thusly produce better quality screencasts.  Futhermore I&amp;#39;d eventually like to turn this into a (mostly) full time gig and move to a subscription model with frequent (weekly) releases - but thats a long way away yet - for now I want to see if I can build something people want and enjoy.&lt;/p&gt;

&lt;p&gt;But hopefully the site can speak for itself - I&amp;#39;ve already got an extensive list of releases coming up over the next while so stay tuned, follow us on &lt;a href="http://twitter.com/yobriefcasts"&gt;twitter as @yobriefcasts&lt;/a&gt; and enjoy the &lt;a href="http://yobriefcasts.tv"&gt;site&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Starter for 10: Play! 2 - Part One</title>
    <link rel="alternate" href="/screencasts/001-starter-for-10-play-2-part-one"/>
    <id>/screencasts/001-starter-for-10-play-2-part-one</id>
    <published>2013-01-21T00:00:00+00:00</published>
    <updated>2013-01-21T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Play! 2 is a Java/Scala framework based on a lightweight, stateless, web-friendly architecture for highly-scalable applications. In this episode we will look at&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Introduction to Play! 2,&lt;/li&gt;
&lt;li&gt;Downloading &amp;amp; Installing Play!&lt;/li&gt;
&lt;li&gt;Using PVM (Play Version Manager) to Install Play!&lt;/li&gt;
&lt;li&gt;A brief tour of the command line interface.&lt;/li&gt;
&lt;/ul&gt;
</summary>
    <content type="html">&lt;p&gt;Play! 2 is a Java/Scala framework based on a lightweight, stateless, web-friendly architecture for highly-scalable applications. In this episode we will look at&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Introduction to Play! 2,&lt;/li&gt;
&lt;li&gt;Downloading &amp;amp; Installing Play!&lt;/li&gt;
&lt;li&gt;Using PVM (Play Version Manager) to Install Play!&lt;/li&gt;
&lt;li&gt;A brief tour of the command line interface.&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>Trello Cards: Materialising Trello Boards</title>
    <link rel="alternate" href="/blog/2012/12/28/trello-cards-materialising-trello-boards"/>
    <id>/blog/2012/12/28/trello-cards-materialising-trello-boards</id>
    <published>2012-12-28T00:00:00+00:00</published>
    <updated>2012-12-28T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;TL;DR I ported &lt;a href="https://github.com/psd/pivotal-cards"&gt;pivotal-cards&lt;/a&gt; to &lt;a href="http://yobriefca.se/trello-cards"&gt;trello-cards&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I recently did a spot of work with the awesome and brilliant people of the &lt;a href="http://digital.cabinetoffice.gov.uk/category/gds/"&gt;Government Digital Service&lt;/a&gt; and being big fans of getting stuff done they make use of whiteboards and index cards to visualise the flow of work on the various projects.  Thats all well and good but it makes reporting to senior managers, stakeholders and remote people a bit difficult (and for the uber paranoid - what about auditing!!!).  To that end this flow of work was also mirrored online - and in GDS&amp;#39;s case the tool of choice was usually &lt;a href="http://pivotaltracker.com"&gt;Pivotal Tracker&lt;/a&gt;.  In order to bridge the gap between the online and &amp;ldquo;real&amp;rdquo; one of the smart chaps at GDS wrote &lt;a href="https://github.com/psd/pivotal-cards"&gt;pivotal-cards&lt;/a&gt; which lets you generate printable index cards from you pivotal board.  Lovely stuff&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.flickr.com/photos/psd/7160723862/" title="Pivotal Cards by psd, on Flickr"&gt;&lt;img src="http://farm8.staticflickr.com/7223/7160723862_ef5d8e59a7.jpg" width="500" height="442" alt="Pivotal Cards"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Anyway - I spent some time today porting this little project to Trello.  I have been using Trello more and more on recent projects but always miss the physicality of real index cards and I&amp;#39;m usually strapped for time to start writing them out myself.&lt;/p&gt;

&lt;p&gt;So here it is - &lt;a href="http://yobriefca.se/trello-cards"&gt;trello-cards&lt;/a&gt;, I&amp;#39;ve tried to keep it pretty much 1:1 with pivotal-cards but there are some &lt;code&gt;TODO&lt;/code&gt;s still outstanding - the current card make up looks a bit like this.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/blog/cardmocks.png" /&gt;&lt;/p&gt;

&lt;p&gt;So basically follow the instructions on the &lt;a href="http://yobriefca.se/trello-cards/"&gt;project page&lt;/a&gt; and hopefully it should all work out.  If it doesn&amp;#39;t - &lt;a href="https://github.com/kouphax/trello-cards"&gt;FORK IT &amp;#39;N FIX IT&lt;/a&gt; or &lt;a href="https://github.com/kouphax/trello-cards/issues"&gt;complain&lt;/a&gt; and I&amp;#39;ll fix it for you :) &lt;/p&gt;

&lt;p&gt;Some other points worth noting,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Currently tested on Chrome 25 (OSX)&lt;/li&gt;
&lt;li&gt;Could do with some basic tests around it&lt;/li&gt;
&lt;li&gt;Currently no markdown support for descriptions&lt;/li&gt;
&lt;li&gt;Story points use the &lt;a href="https://chrome.google.com/webstore/detail/jdbcdblgjdpmfninkoogcfpnkjmndgje?utm_source=chrome-ntp-icon"&gt;Trello Scrum Chrome Extension&lt;/a&gt; convention of &lt;code&gt;(POINTS)&lt;/code&gt; at the start of the card name/title.  If you use that plugin then good for you, if not you can still make use of the points convention&lt;/li&gt;
&lt;li&gt;Tasks are derived from the first checklist on the card&lt;/li&gt;
&lt;/ul&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;TL;DR I ported &lt;a href="https://github.com/psd/pivotal-cards"&gt;pivotal-cards&lt;/a&gt; to &lt;a href="http://yobriefca.se/trello-cards"&gt;trello-cards&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I recently did a spot of work with the awesome and brilliant people of the &lt;a href="http://digital.cabinetoffice.gov.uk/category/gds/"&gt;Government Digital Service&lt;/a&gt; and being big fans of getting stuff done they make use of whiteboards and index cards to visualise the flow of work on the various projects.  Thats all well and good but it makes reporting to senior managers, stakeholders and remote people a bit difficult (and for the uber paranoid - what about auditing!!!).  To that end this flow of work was also mirrored online - and in GDS&amp;#39;s case the tool of choice was usually &lt;a href="http://pivotaltracker.com"&gt;Pivotal Tracker&lt;/a&gt;.  In order to bridge the gap between the online and &amp;ldquo;real&amp;rdquo; one of the smart chaps at GDS wrote &lt;a href="https://github.com/psd/pivotal-cards"&gt;pivotal-cards&lt;/a&gt; which lets you generate printable index cards from you pivotal board.  Lovely stuff&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.flickr.com/photos/psd/7160723862/" title="Pivotal Cards by psd, on Flickr"&gt;&lt;img src="http://farm8.staticflickr.com/7223/7160723862_ef5d8e59a7.jpg" width="500" height="442" alt="Pivotal Cards"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Anyway - I spent some time today porting this little project to Trello.  I have been using Trello more and more on recent projects but always miss the physicality of real index cards and I&amp;#39;m usually strapped for time to start writing them out myself.&lt;/p&gt;

&lt;p&gt;So here it is - &lt;a href="http://yobriefca.se/trello-cards"&gt;trello-cards&lt;/a&gt;, I&amp;#39;ve tried to keep it pretty much 1:1 with pivotal-cards but there are some &lt;code&gt;TODO&lt;/code&gt;s still outstanding - the current card make up looks a bit like this.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/blog/cardmocks.png" /&gt;&lt;/p&gt;

&lt;p&gt;So basically follow the instructions on the &lt;a href="http://yobriefca.se/trello-cards/"&gt;project page&lt;/a&gt; and hopefully it should all work out.  If it doesn&amp;#39;t - &lt;a href="https://github.com/kouphax/trello-cards"&gt;FORK IT &amp;#39;N FIX IT&lt;/a&gt; or &lt;a href="https://github.com/kouphax/trello-cards/issues"&gt;complain&lt;/a&gt; and I&amp;#39;ll fix it for you :) &lt;/p&gt;

&lt;p&gt;Some other points worth noting,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Currently tested on Chrome 25 (OSX)&lt;/li&gt;
&lt;li&gt;Could do with some basic tests around it&lt;/li&gt;
&lt;li&gt;Currently no markdown support for descriptions&lt;/li&gt;
&lt;li&gt;Story points use the &lt;a href="https://chrome.google.com/webstore/detail/jdbcdblgjdpmfninkoogcfpnkjmndgje?utm_source=chrome-ntp-icon"&gt;Trello Scrum Chrome Extension&lt;/a&gt; convention of &lt;code&gt;(POINTS)&lt;/code&gt; at the start of the card name/title.  If you use that plugin then good for you, if not you can still make use of the points convention&lt;/li&gt;
&lt;li&gt;Tasks are derived from the first checklist on the card&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>Eg. Play 2.1 + Scala + Guice + GlobalSettings#getControllerInstance</title>
    <link rel="alternate" href="/blog/2012/12/18/eg-play-2-dot-1-plus-scala-plus-guice-plus-globalsettings-number-getcontrollerinstance"/>
    <id>/blog/2012/12/18/eg-play-2-dot-1-plus-scala-plus-guice-plus-globalsettings-number-getcontrollerinstance</id>
    <published>2012-12-18T00:00:00+00:00</published>
    <updated>2012-12-18T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;TL;DR Here is some &lt;a href="https://github.com/kouphax/play21guice"&gt;sample code&lt;/a&gt; of how to use Play 2.1s GlobalSettings#getControllerInstance feature with Google Guice.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I&amp;#39;ve had the chance to take Play 2.1 RC 1 out for a spin recently and in a bid to make my project a bit more testable I decided to go ahead and give dependency injection a bit of a spin again.  While things like the cake pattern and general dynamic composition are alright I&amp;#39;ve never been happy with the code that I produce using them. So I decided to give &lt;a href="https://code.google.com/p/google-guice/"&gt;Guice&lt;/a&gt; a blast as it seemed very much aligned with how I approached DI in the .NET world.  &lt;/p&gt;

&lt;p&gt;My main need was to create instances of controllers and given Plays appraoch in the past (singleton &lt;code&gt;object&lt;/code&gt;s for controllers) 2.1 new &lt;code&gt;GlobalSettings#getControllerInstance&lt;/code&gt; feature was what I needed.&lt;/p&gt;

&lt;p&gt;First things first we need to add a project dependency to &lt;a href="https://code.google.com/p/google-guice/"&gt;Guice&lt;/a&gt; and while we could just add the Guice dependencies directly I went with a library that offered slightly neater syntax in Scala - &lt;a href="https://github.com/sptz45/sse-guice"&gt;SSE-Guice&lt;/a&gt;.  In short this means instead of writing this sort of noisy code&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classOf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classOf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ServiceImpl&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="n"&gt;in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classOf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We get to write it like this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ServiceImpl&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;in&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So lets add the reference to the &lt;code&gt;Build.scala&lt;/code&gt; file (assuming we just generated a our Play project) for sse-guice&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;jdbc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;anorm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

  &lt;span class="c1"&gt;// Add your project dependencies here,&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;com.tzavellas&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;sse-guice&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;0.7.0&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next up we need to modify the Application controller a bit&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It needs to take a dependency&lt;/li&gt;
&lt;li&gt;It needs to bo be instantiable (e.g. not an &lt;code&gt;object&lt;/code&gt; - this might be doable but the default approach in Guice seems to conflict with Plays approach to defining an instantiable controller)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we want to go from this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Some Message&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;class Application @Inject()(val messeger: Messeger) extends Controller {
  def index = Action {
    Ok(views.html.index(messeger.getMessage))
  }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A few things of note here&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We use the &lt;code&gt;@Inject()&lt;/code&gt; attribute here to mark this constructor as our default one (need by Guice to satisfy constructor injection)&lt;/li&gt;
&lt;li&gt;Application is now a class.  Small change (a Levenshtein Distance of 6 even!) big difference.  Rather than having a singleton we now have something we can construct when we want (even in tests) and set it up really simply.  Construction and lifecycle can be handled via our DI library easily.&lt;/li&gt;
&lt;li&gt;We are passing in some sort of dependency - in this case it&amp;#39;s a simple string barfer (&lt;code&gt;Messeger&lt;/code&gt; is a trait) and the impl looks like this&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;trait&lt;/span&gt; &lt;span class="n"&gt;Messeger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getMessage&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;MessegerImpl&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Messeger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;The Best Super Message&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we need to create our Guice module that will wire up our dependencies,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tzavellas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;guice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ScalaModule&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;SimpleModule&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;ScalaModule&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Messeger&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;toInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MessegerImpl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;ScalaModule&lt;/code&gt; declaration is a Scala-fied version of Guices &lt;code&gt;AbstractModule&lt;/code&gt; with some helper and whatnot.  Guice applies some common sense to wiring so we don&amp;#39;t need to declare each controller type here etc.&lt;/p&gt;

&lt;p&gt;Finally we need to start the DI mechanism and provide a way to instantiate controllers.  We do this via the Play feature of &lt;code&gt;GlobalSettings&lt;/code&gt;.  In our &lt;code&gt;app&lt;/code&gt; package we just put a &lt;code&gt;Global&lt;/code&gt; object and set it up as needed&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Global&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;GlobalSettings&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;lazy&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;injector&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Guice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;createInjector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;SimpleModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getControllerInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;controllerClass&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Class&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controllerClass&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We use a &lt;code&gt;lazy&lt;/code&gt; val to instantiate the &lt;code&gt;injector&lt;/code&gt; with our &lt;code&gt;SimpleModule&lt;/code&gt; and override the &lt;code&gt;getControllerInstance&lt;/code&gt; method of our &lt;code&gt;GlobalSettings&lt;/code&gt; class to use Guices injector.&lt;/p&gt;

&lt;p&gt;Oh one last thing.  We need to tell Play what controllers we want to use this feature (it&amp;#39;s not an all or nothing thing which I guess is good).  We do this by marking the route declaration with an &lt;code&gt;@&lt;/code&gt; in the &lt;code&gt;routes&lt;/code&gt; file.  So it becomes this (notice the &lt;code&gt;@&lt;/code&gt;)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;# Home page&lt;/span&gt;
&lt;span class="n"&gt;GET&lt;/span&gt;     &lt;span class="o"&gt;/&lt;/span&gt;     &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Running the app gives us exactly what we expect but why stop there?  We need to test this stuff right?  Cool.  Testing is made easier - we can simply make use of the various helpers in Play like &lt;code&gt;FakeApplication&lt;/code&gt; and &lt;code&gt;FakeRequest&lt;/code&gt;,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;ApplicationSpec&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Specification&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;Using FakeApplication&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="s"&gt;&amp;quot;get the default message&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;running&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FakeApplication&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FakeRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;
        &lt;span class="n"&gt;contentAsString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;must&lt;/span&gt; &lt;span class="n"&gt;contain&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;The Best Super Message&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or we can create a custom &lt;code&gt;Global&lt;/code&gt; object with a &lt;code&gt;FakeApplication&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;ApplicationSpec&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Specification&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;DummyMessenger&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Messeger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Dummy Message&amp;quot;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="s"&gt;&amp;quot;Using FakeApplication&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;DummyGlobal&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;play&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GlobalSettings&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getControllerInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Class&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DummyMessenger&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;asInstanceOf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="s"&gt;&amp;quot;get the an injected message&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;running&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FakeApplication&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;withGlobal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DummyGlobal&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FakeRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;
        &lt;span class="n"&gt;contentAsString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;must&lt;/span&gt; &lt;span class="n"&gt;contain&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Dummy Message&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And even lighter we can just test the controller as if it was just another class,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;ApplicationSpec&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Specification&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;DummyMessenger&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Messeger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Dummy Message&amp;quot;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="s"&gt;&amp;quot;Using direct controller testing&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;return the dummy message&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DummyMessenger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;()(&lt;/span&gt;&lt;span class="n"&gt;FakeRequest&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
      &lt;span class="n"&gt;contentAsString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;must&lt;/span&gt; &lt;span class="n"&gt;contain&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Dummy Message&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Hopefully this gives you a good starter for using the new Play 2.1 &lt;code&gt;getContollerInstance&lt;/code&gt; feature along with Guice.  As above you can find the code for this post on &lt;a href="GlobalSettings#getControllerInstance"&gt;Ye &amp;#39;Ole Github&lt;/a&gt;&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;TL;DR Here is some &lt;a href="https://github.com/kouphax/play21guice"&gt;sample code&lt;/a&gt; of how to use Play 2.1s GlobalSettings#getControllerInstance feature with Google Guice.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I&amp;#39;ve had the chance to take Play 2.1 RC 1 out for a spin recently and in a bid to make my project a bit more testable I decided to go ahead and give dependency injection a bit of a spin again.  While things like the cake pattern and general dynamic composition are alright I&amp;#39;ve never been happy with the code that I produce using them. So I decided to give &lt;a href="https://code.google.com/p/google-guice/"&gt;Guice&lt;/a&gt; a blast as it seemed very much aligned with how I approached DI in the .NET world.  &lt;/p&gt;

&lt;p&gt;My main need was to create instances of controllers and given Plays appraoch in the past (singleton &lt;code&gt;object&lt;/code&gt;s for controllers) 2.1 new &lt;code&gt;GlobalSettings#getControllerInstance&lt;/code&gt; feature was what I needed.&lt;/p&gt;

&lt;p&gt;First things first we need to add a project dependency to &lt;a href="https://code.google.com/p/google-guice/"&gt;Guice&lt;/a&gt; and while we could just add the Guice dependencies directly I went with a library that offered slightly neater syntax in Scala - &lt;a href="https://github.com/sptz45/sse-guice"&gt;SSE-Guice&lt;/a&gt;.  In short this means instead of writing this sort of noisy code&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classOf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classOf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ServiceImpl&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="n"&gt;in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;classOf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We get to write it like this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ServiceImpl&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;in&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So lets add the reference to the &lt;code&gt;Build.scala&lt;/code&gt; file (assuming we just generated a our Play project) for sse-guice&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;jdbc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;anorm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

  &lt;span class="c1"&gt;// Add your project dependencies here,&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;com.tzavellas&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;sse-guice&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;0.7.0&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next up we need to modify the Application controller a bit&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It needs to take a dependency&lt;/li&gt;
&lt;li&gt;It needs to bo be instantiable (e.g. not an &lt;code&gt;object&lt;/code&gt; - this might be doable but the default approach in Guice seems to conflict with Plays approach to defining an instantiable controller)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we want to go from this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Some Message&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;class Application @Inject()(val messeger: Messeger) extends Controller {
  def index = Action {
    Ok(views.html.index(messeger.getMessage))
  }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A few things of note here&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We use the &lt;code&gt;@Inject()&lt;/code&gt; attribute here to mark this constructor as our default one (need by Guice to satisfy constructor injection)&lt;/li&gt;
&lt;li&gt;Application is now a class.  Small change (a Levenshtein Distance of 6 even!) big difference.  Rather than having a singleton we now have something we can construct when we want (even in tests) and set it up really simply.  Construction and lifecycle can be handled via our DI library easily.&lt;/li&gt;
&lt;li&gt;We are passing in some sort of dependency - in this case it&amp;#39;s a simple string barfer (&lt;code&gt;Messeger&lt;/code&gt; is a trait) and the impl looks like this&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;trait&lt;/span&gt; &lt;span class="n"&gt;Messeger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getMessage&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;MessegerImpl&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Messeger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;The Best Super Message&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we need to create our Guice module that will wire up our dependencies,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tzavellas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;guice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ScalaModule&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;SimpleModule&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;ScalaModule&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Messeger&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;toInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MessegerImpl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;ScalaModule&lt;/code&gt; declaration is a Scala-fied version of Guices &lt;code&gt;AbstractModule&lt;/code&gt; with some helper and whatnot.  Guice applies some common sense to wiring so we don&amp;#39;t need to declare each controller type here etc.&lt;/p&gt;

&lt;p&gt;Finally we need to start the DI mechanism and provide a way to instantiate controllers.  We do this via the Play feature of &lt;code&gt;GlobalSettings&lt;/code&gt;.  In our &lt;code&gt;app&lt;/code&gt; package we just put a &lt;code&gt;Global&lt;/code&gt; object and set it up as needed&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Global&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;GlobalSettings&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;lazy&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;injector&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Guice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;createInjector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;SimpleModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getControllerInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;controllerClass&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Class&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;injector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controllerClass&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We use a &lt;code&gt;lazy&lt;/code&gt; val to instantiate the &lt;code&gt;injector&lt;/code&gt; with our &lt;code&gt;SimpleModule&lt;/code&gt; and override the &lt;code&gt;getControllerInstance&lt;/code&gt; method of our &lt;code&gt;GlobalSettings&lt;/code&gt; class to use Guices injector.&lt;/p&gt;

&lt;p&gt;Oh one last thing.  We need to tell Play what controllers we want to use this feature (it&amp;#39;s not an all or nothing thing which I guess is good).  We do this by marking the route declaration with an &lt;code&gt;@&lt;/code&gt; in the &lt;code&gt;routes&lt;/code&gt; file.  So it becomes this (notice the &lt;code&gt;@&lt;/code&gt;)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;# Home page&lt;/span&gt;
&lt;span class="n"&gt;GET&lt;/span&gt;     &lt;span class="o"&gt;/&lt;/span&gt;     &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Running the app gives us exactly what we expect but why stop there?  We need to test this stuff right?  Cool.  Testing is made easier - we can simply make use of the various helpers in Play like &lt;code&gt;FakeApplication&lt;/code&gt; and &lt;code&gt;FakeRequest&lt;/code&gt;,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;ApplicationSpec&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Specification&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;Using FakeApplication&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="s"&gt;&amp;quot;get the default message&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;running&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FakeApplication&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FakeRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;
        &lt;span class="n"&gt;contentAsString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;must&lt;/span&gt; &lt;span class="n"&gt;contain&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;The Best Super Message&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or we can create a custom &lt;code&gt;Global&lt;/code&gt; object with a &lt;code&gt;FakeApplication&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;ApplicationSpec&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Specification&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;DummyMessenger&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Messeger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Dummy Message&amp;quot;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="s"&gt;&amp;quot;Using FakeApplication&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;DummyGlobal&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;play&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GlobalSettings&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getControllerInstance&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Class&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DummyMessenger&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;asInstanceOf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="s"&gt;&amp;quot;get the an injected message&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;running&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FakeApplication&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;withGlobal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DummyGlobal&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FakeRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;
        &lt;span class="n"&gt;contentAsString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;must&lt;/span&gt; &lt;span class="n"&gt;contain&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Dummy Message&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And even lighter we can just test the controller as if it was just another class,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;ApplicationSpec&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Specification&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;DummyMessenger&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Messeger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getMessage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Dummy Message&amp;quot;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="s"&gt;&amp;quot;Using direct controller testing&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;return the dummy message&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DummyMessenger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;()(&lt;/span&gt;&lt;span class="n"&gt;FakeRequest&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
      &lt;span class="n"&gt;contentAsString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;must&lt;/span&gt; &lt;span class="n"&gt;contain&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Dummy Message&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Hopefully this gives you a good starter for using the new Play 2.1 &lt;code&gt;getContollerInstance&lt;/code&gt; feature along with Guice.  As above you can find the code for this post on &lt;a href="GlobalSettings#getControllerInstance"&gt;Ye &amp;#39;Ole Github&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Neo4J Talk: Using Graphs to Analyse Public Spending on International Development</title>
    <link rel="alternate" href="/blog/2012/12/12/neo4j-talk-using-graphs-to-analyse-public-spending-on-international-development"/>
    <id>/blog/2012/12/12/neo4j-talk-using-graphs-to-analyse-public-spending-on-international-development</id>
    <published>2012-12-12T00:00:00+00:00</published>
    <updated>2012-12-12T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Better late than ever, right?  So a few weeks ago I presented a bit of a case study on my use of Neo4J in a UK government project focused on increasing transparency around how the UK disburses foreign aid.  This post is a collection of all the useful resources mentioned in the talk.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://speakerdeck.com/kouphax/neo4j-a-case-study"&gt;Slides on SpeakerDeck&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://skillsmatter.com/podcast/nosql/using-graphs-to-analyse-public-spending-on-international-development"&gt;Video on Skills Matter&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Plenty of acronyms were thrown about and here are the useful links to some of the key ones.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://digital.cabinetoffice.gov.uk/category/gds/"&gt;GDS (Government Digital Service)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.dfid.gov.uk/"&gt;DFID (Department for International Development)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;IATI (International Aid Transparency Initiative) - &lt;a href="http://iatiregistry.org/"&gt;Registry&lt;/a&gt; and &lt;a href="iatistandard.org"&gt;Standard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;OIPA (Open IATI Parser and API) - &lt;a href="http://oipa.openaidsearch.org/api/v2/"&gt;Open Aid Site&lt;/a&gt; and &lt;a href="https://github.com/openaid-IATI/OIPA-V2"&gt;Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</summary>
    <content type="html">&lt;p&gt;Better late than ever, right?  So a few weeks ago I presented a bit of a case study on my use of Neo4J in a UK government project focused on increasing transparency around how the UK disburses foreign aid.  This post is a collection of all the useful resources mentioned in the talk.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://speakerdeck.com/kouphax/neo4j-a-case-study"&gt;Slides on SpeakerDeck&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://skillsmatter.com/podcast/nosql/using-graphs-to-analyse-public-spending-on-international-development"&gt;Video on Skills Matter&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Plenty of acronyms were thrown about and here are the useful links to some of the key ones.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://digital.cabinetoffice.gov.uk/category/gds/"&gt;GDS (Government Digital Service)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.dfid.gov.uk/"&gt;DFID (Department for International Development)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;IATI (International Aid Transparency Initiative) - &lt;a href="http://iatiregistry.org/"&gt;Registry&lt;/a&gt; and &lt;a href="iatistandard.org"&gt;Standard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;OIPA (Open IATI Parser and API) - &lt;a href="http://oipa.openaidsearch.org/api/v2/"&gt;Open Aid Site&lt;/a&gt; and &lt;a href="https://github.com/openaid-IATI/OIPA-V2"&gt;Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>MongoDB Basics</title>
    <link rel="alternate" href="https://vimeo.com/55048851"/>
    <id>https://vimeo.com/55048851</id>
    <published>2012-12-06T00:00:00+00:00</published>
    <updated>2012-12-06T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>Neo4J: A Case Study</title>
    <link rel="alternate" href="http://skillsmatter.com/podcast/nosql/using-graphs-to-analyse-public-spending-on-international-development"/>
    <id>http://skillsmatter.com/podcast/nosql/using-graphs-to-analyse-public-spending-on-international-development</id>
    <published>2012-11-28T00:00:00+00:00</published>
    <updated>2012-11-28T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>Vertical vs Horizontal Thinking</title>
    <link rel="alternate" href="/blog/2012/11/17/vertical-vs-horizontal-thinking"/>
    <id>/blog/2012/11/17/vertical-vs-horizontal-thinking</id>
    <published>2012-11-17T00:00:00+00:00</published>
    <updated>2012-11-17T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;I&amp;#39;m not quite sure were this ramble is going to lead, it&amp;#39;s been a while since I&amp;#39;ve felt like writing something that hasn&amp;#39;t been clearly defined by my half conscious brain but lets take the journey anyway shall we?&lt;/p&gt;

&lt;p&gt;This is going to be loosely related to agility, not necessarily the &amp;ldquo;agile method or process&amp;rdquo; but more simply about adapting to change and embracing transparency in a software project.  More often than not this can be simply referred to as &amp;ldquo;common sense&amp;rdquo; and it&amp;#39;s a great thing.  &lt;/p&gt;

&lt;p&gt;But I digress,&lt;/p&gt;

&lt;p&gt;In a vertical world you deliver features by implementing vertical spikes through each layer of the system architecture.  It doesn&amp;#39;t have to be right, but it does need to be good enough for now.  Sure it may not deliver the best user experience or maybe there are more HTTP requests or database calls than necessary but it&amp;#39;s useable.  Its shippable.  &lt;/p&gt;

&lt;p&gt;In the horizontal world layers of the architecture are tackled by (possibly pseudo) specialists and delivered en masse.  This is very typical of the Big Design Upfront, Plan Based, Waterfall approach to delivery but its visible in a lot of projects in various guises and it&amp;#39;s rather natural to many people.&lt;/p&gt;

&lt;p&gt;Now, on the surface, getting specialists to deliver what they know best and then smash them altogether actually sounds great.  You know your DB person is going to produce a wonderful hyper-normalised schema for you, your UI/UX person will deliver a gorgeous mockup of the site and your middle layer app people will deliver the best truly ReSTful service layer known to man.  But then you spend an insane amount of time (or many many little periods of time) doing the actual integration and making this vision a reality.  The testing, the regressions, the edge cases the performance hits and sacrifices through integrating perfect works of horizontal art.  Best case you get it done eventually, worst case someone else gets it done by layering hack upon hack at integration points just to get it working.  &lt;/p&gt;

&lt;p&gt;Now imagine your DB person gets eaten by a badger, or your UI person decides they&amp;#39;ve had enough and goes to live in a free-love commune and drink the spiked kool-aid?  I&amp;#39;ve overly dramatised the &lt;a href="http://en.wikipedia.org/wiki/Bus_factor"&gt;Bus Factor&lt;/a&gt; here but the point is still made.  You&amp;#39;ve lost siloed knowledge forever and you need to spend time building it up again, and time and quality slip.&lt;/p&gt;

&lt;p&gt;Finally - projects that deliver horizontally are, more often than not, projects that have limited customer/stakeholder visibility.  Sometimes even less for end-users.  So delivering a mockup of the UI and a DB schema that can be exported as a nice UML diagram is enough to satisfy people that work is on-going and going well.  Even if it isn&amp;#39;t.  It&amp;#39;s not a lie but it is a false impression, and it&amp;#39;s an impression that doesn&amp;#39;t work for long especially if you have shorter release cycles with ongoing customer interaction.  A page of beautiful buttons that don&amp;#39;t do anything will create an impression that you are nearly done and can easily generate disappointment at subsequent demos.  Is it worth it?&lt;/p&gt;

&lt;p&gt;Don&amp;#39;t get me wrong it is very possible to successfully deliver software in this manner, on time and on budget but so many things must fall into place and all the stars must be aligned that it&amp;#39;s a rather big risk, but a risk that people seem to ignore.&lt;/p&gt;

&lt;p&gt;So I&amp;#39;m saying vertical is better and there are many reasons for that and I&amp;#39;ll touch on some of them here but there is one very fundamental reason it&amp;#39;s better.  Working and thinking vertically allows you to create a shippable product early.  It&amp;#39;s not all done, far from it.  It probably looks like ass as well but still it&amp;#39;s usable enough to get the job done, right?  Imagine using a new product that looked amazing but only had 3 working features and the rest of the buttons and knobs didn&amp;#39;t do anything.  Wow factor is for kids and sales men.&lt;/p&gt;

&lt;p&gt;Why else is vertical thinking better?&lt;/p&gt;

&lt;p&gt;For one everyone on the team works across all layers of the solution.  You don&amp;#39;t have huge silos of knowledge contained in a single brain of some crazy bus magnet.  Sure you may involve specialists to ensure you&amp;#39;re not doing it totally wrong but at least you&amp;#39;d be working WITH them and picking up parts of the vast knowledge they may have.&lt;/p&gt;

&lt;p&gt;By delivering something &amp;ldquo;good enough for now&amp;rdquo; you actually reduce waste.  True you may re-write a few things to get it right but you haven&amp;#39;t spent hours crafting perfection only to tear it apart.  Even better the first iteration may make users realise - &amp;ldquo;Actually you know what?  That super whizzy button thing - we don&amp;#39;t need it&amp;rdquo;.  Waterfall attempts to &amp;ldquo;manage change&amp;rdquo; because change in waterfall is scary expensive.  Embrace it early and often and it much less costly.&lt;/p&gt;

&lt;p&gt;Finally, the solution evolves rather than being dragged into existence from a 189 page document of business rules and textual assumptions.  This allows you to experiment and try things, throw them away or discover a better way of doing things.  You can adapt the solution at anytime to suit the changing nature of the environment it lives in.&lt;/p&gt;

&lt;p&gt;Vertical thinking is a proven pattern in many other aspects of the software world.  TDD for example. Rather than writing reams of code and testing it manually later, you create a solution bit by bit and adapt it fearlessly as you go.  UI designers never just bang out one design and leave it there.  Smaller feedback loops are essential to flow and success and vertical thinking gives you this.  Break the habit of wowing people and replace it with the habit of delivering - it&amp;#39;s a better, longer lasting feeling of win.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I&amp;#39;m not quite sure were this ramble is going to lead, it&amp;#39;s been a while since I&amp;#39;ve felt like writing something that hasn&amp;#39;t been clearly defined by my half conscious brain but lets take the journey anyway shall we?&lt;/p&gt;

&lt;p&gt;This is going to be loosely related to agility, not necessarily the &amp;ldquo;agile method or process&amp;rdquo; but more simply about adapting to change and embracing transparency in a software project.  More often than not this can be simply referred to as &amp;ldquo;common sense&amp;rdquo; and it&amp;#39;s a great thing.  &lt;/p&gt;

&lt;p&gt;But I digress,&lt;/p&gt;

&lt;p&gt;In a vertical world you deliver features by implementing vertical spikes through each layer of the system architecture.  It doesn&amp;#39;t have to be right, but it does need to be good enough for now.  Sure it may not deliver the best user experience or maybe there are more HTTP requests or database calls than necessary but it&amp;#39;s useable.  Its shippable.  &lt;/p&gt;

&lt;p&gt;In the horizontal world layers of the architecture are tackled by (possibly pseudo) specialists and delivered en masse.  This is very typical of the Big Design Upfront, Plan Based, Waterfall approach to delivery but its visible in a lot of projects in various guises and it&amp;#39;s rather natural to many people.&lt;/p&gt;

&lt;p&gt;Now, on the surface, getting specialists to deliver what they know best and then smash them altogether actually sounds great.  You know your DB person is going to produce a wonderful hyper-normalised schema for you, your UI/UX person will deliver a gorgeous mockup of the site and your middle layer app people will deliver the best truly ReSTful service layer known to man.  But then you spend an insane amount of time (or many many little periods of time) doing the actual integration and making this vision a reality.  The testing, the regressions, the edge cases the performance hits and sacrifices through integrating perfect works of horizontal art.  Best case you get it done eventually, worst case someone else gets it done by layering hack upon hack at integration points just to get it working.  &lt;/p&gt;

&lt;p&gt;Now imagine your DB person gets eaten by a badger, or your UI person decides they&amp;#39;ve had enough and goes to live in a free-love commune and drink the spiked kool-aid?  I&amp;#39;ve overly dramatised the &lt;a href="http://en.wikipedia.org/wiki/Bus_factor"&gt;Bus Factor&lt;/a&gt; here but the point is still made.  You&amp;#39;ve lost siloed knowledge forever and you need to spend time building it up again, and time and quality slip.&lt;/p&gt;

&lt;p&gt;Finally - projects that deliver horizontally are, more often than not, projects that have limited customer/stakeholder visibility.  Sometimes even less for end-users.  So delivering a mockup of the UI and a DB schema that can be exported as a nice UML diagram is enough to satisfy people that work is on-going and going well.  Even if it isn&amp;#39;t.  It&amp;#39;s not a lie but it is a false impression, and it&amp;#39;s an impression that doesn&amp;#39;t work for long especially if you have shorter release cycles with ongoing customer interaction.  A page of beautiful buttons that don&amp;#39;t do anything will create an impression that you are nearly done and can easily generate disappointment at subsequent demos.  Is it worth it?&lt;/p&gt;

&lt;p&gt;Don&amp;#39;t get me wrong it is very possible to successfully deliver software in this manner, on time and on budget but so many things must fall into place and all the stars must be aligned that it&amp;#39;s a rather big risk, but a risk that people seem to ignore.&lt;/p&gt;

&lt;p&gt;So I&amp;#39;m saying vertical is better and there are many reasons for that and I&amp;#39;ll touch on some of them here but there is one very fundamental reason it&amp;#39;s better.  Working and thinking vertically allows you to create a shippable product early.  It&amp;#39;s not all done, far from it.  It probably looks like ass as well but still it&amp;#39;s usable enough to get the job done, right?  Imagine using a new product that looked amazing but only had 3 working features and the rest of the buttons and knobs didn&amp;#39;t do anything.  Wow factor is for kids and sales men.&lt;/p&gt;

&lt;p&gt;Why else is vertical thinking better?&lt;/p&gt;

&lt;p&gt;For one everyone on the team works across all layers of the solution.  You don&amp;#39;t have huge silos of knowledge contained in a single brain of some crazy bus magnet.  Sure you may involve specialists to ensure you&amp;#39;re not doing it totally wrong but at least you&amp;#39;d be working WITH them and picking up parts of the vast knowledge they may have.&lt;/p&gt;

&lt;p&gt;By delivering something &amp;ldquo;good enough for now&amp;rdquo; you actually reduce waste.  True you may re-write a few things to get it right but you haven&amp;#39;t spent hours crafting perfection only to tear it apart.  Even better the first iteration may make users realise - &amp;ldquo;Actually you know what?  That super whizzy button thing - we don&amp;#39;t need it&amp;rdquo;.  Waterfall attempts to &amp;ldquo;manage change&amp;rdquo; because change in waterfall is scary expensive.  Embrace it early and often and it much less costly.&lt;/p&gt;

&lt;p&gt;Finally, the solution evolves rather than being dragged into existence from a 189 page document of business rules and textual assumptions.  This allows you to experiment and try things, throw them away or discover a better way of doing things.  You can adapt the solution at anytime to suit the changing nature of the environment it lives in.&lt;/p&gt;

&lt;p&gt;Vertical thinking is a proven pattern in many other aspects of the software world.  TDD for example. Rather than writing reams of code and testing it manually later, you create a solution bit by bit and adapt it fearlessly as you go.  UI designers never just bang out one design and leave it there.  Smaller feedback loops are essential to flow and success and vertical thinking gives you this.  Break the habit of wowing people and replace it with the habit of delivering - it&amp;#39;s a better, longer lasting feeling of win.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Technology Techsmology</title>
    <link rel="alternate" href="/blog/2012/11/05/technology-techsmology"/>
    <id>/blog/2012/11/05/technology-techsmology</id>
    <published>2012-11-05T00:00:00+00:00</published>
    <updated>2012-11-05T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;There is an old adage, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Projects don&amp;#39;t fail because of technology decisions&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The younger me would have got all uppity and defensive when he heard this statement.  As a developer/architect type whose main goal is to make key technology decisions on a project (not to mention as a person who likes to grandiously consider themselves a craftsman) this does seem rather belittling.  Are you telling me all my decisions are fairly irrelevant?  I&amp;#39;ll just stay in bed then shall I? &lt;/p&gt;

&lt;p&gt;But you know what?  The statement is also completely true.  &lt;/p&gt;

&lt;p&gt;But hey, wait - do you want to know something else? Yes? Good.  &lt;/p&gt;

&lt;p&gt;The world of technology is not black and white, projects aren&amp;#39;t either a success or a failure, it&amp;#39;s simply not a binary system.  Projects may not fail, but they could be late.  They could be well over budget.  They could have code bases so toxic that you need to hire contractors to do the work because no one wants to touch it.  They could be so overly laden in patterns and complex architecture that even small changes take weeks or months to implement (and who foots the bill for that?).  &lt;/p&gt;

&lt;p&gt;Technology decisions can indirectly ruin the morale of your staff, muddy the relationship with your customers and generate really high turnover of staff in your company (which may be a good fit for some companies but you can never foster excellence if you don&amp;#39;t nurture talent).  &lt;/p&gt;

&lt;p&gt;This statement can also be used as a weapon - a weapon to excuse bad decisions and hold back change (both good and bad, in short it stiffles learning).  People cling to technologies that they used in the past, for fear of more pain with other technologies.  They shoehorn their existing skillset into problem domains that aren&amp;#39;t a good fit.  When this happens, at the extreme you end up with specialists that simply can&amp;#39;t adapt to shifts in technology fast enough.&lt;/p&gt;

&lt;p&gt;So yeah, projects don&amp;#39;t fail because of technology decisions.  But you know what - if your dentist turned round to you with an evil grin and a rusty chisel and &lt;a href="http://en.wikipedia.org/wiki/Law_of_the_instrument"&gt;Maslow&amp;#39;s Hammer&lt;/a&gt; citing - &amp;ldquo;No surgery ever went wrong because of a lack of anesthetic&amp;rdquo; - you&amp;#39;re not likely to get in to that chair and open wide.  And even if you did (maybe, you&amp;#39;re drunk, maybe people keep telling you this dentist is the best, whatever) the experience would be painful, recovery time would be longer and subsequent treatments would probably be more painful.  A rather shambling metaphor I admit but I write what my brain dictates - I have not choice in the matter.&lt;/p&gt;

&lt;p&gt;Finally, I fully accept that many of these decisions are out of our control.  Customers, especially big ones, generally have the final say, they&amp;#39;ve potentially invested a lot of time on a certain stack and have a lot of legacy (read: code that still works) solutions in play.  True, but one of our goals is to at least inform these people of the alternatives and let them make an informed decision - maybe not today but soon enough the cost of developing and maintaining new systems built on out-of-support JDKs will come under scrutiny and they&amp;#39;ll need to consider alternatives, alternatives that you&amp;#39;ve already enlightened them about.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;There is an old adage, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Projects don&amp;#39;t fail because of technology decisions&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The younger me would have got all uppity and defensive when he heard this statement.  As a developer/architect type whose main goal is to make key technology decisions on a project (not to mention as a person who likes to grandiously consider themselves a craftsman) this does seem rather belittling.  Are you telling me all my decisions are fairly irrelevant?  I&amp;#39;ll just stay in bed then shall I? &lt;/p&gt;

&lt;p&gt;But you know what?  The statement is also completely true.  &lt;/p&gt;

&lt;p&gt;But hey, wait - do you want to know something else? Yes? Good.  &lt;/p&gt;

&lt;p&gt;The world of technology is not black and white, projects aren&amp;#39;t either a success or a failure, it&amp;#39;s simply not a binary system.  Projects may not fail, but they could be late.  They could be well over budget.  They could have code bases so toxic that you need to hire contractors to do the work because no one wants to touch it.  They could be so overly laden in patterns and complex architecture that even small changes take weeks or months to implement (and who foots the bill for that?).  &lt;/p&gt;

&lt;p&gt;Technology decisions can indirectly ruin the morale of your staff, muddy the relationship with your customers and generate really high turnover of staff in your company (which may be a good fit for some companies but you can never foster excellence if you don&amp;#39;t nurture talent).  &lt;/p&gt;

&lt;p&gt;This statement can also be used as a weapon - a weapon to excuse bad decisions and hold back change (both good and bad, in short it stiffles learning).  People cling to technologies that they used in the past, for fear of more pain with other technologies.  They shoehorn their existing skillset into problem domains that aren&amp;#39;t a good fit.  When this happens, at the extreme you end up with specialists that simply can&amp;#39;t adapt to shifts in technology fast enough.&lt;/p&gt;

&lt;p&gt;So yeah, projects don&amp;#39;t fail because of technology decisions.  But you know what - if your dentist turned round to you with an evil grin and a rusty chisel and &lt;a href="http://en.wikipedia.org/wiki/Law_of_the_instrument"&gt;Maslow&amp;#39;s Hammer&lt;/a&gt; citing - &amp;ldquo;No surgery ever went wrong because of a lack of anesthetic&amp;rdquo; - you&amp;#39;re not likely to get in to that chair and open wide.  And even if you did (maybe, you&amp;#39;re drunk, maybe people keep telling you this dentist is the best, whatever) the experience would be painful, recovery time would be longer and subsequent treatments would probably be more painful.  A rather shambling metaphor I admit but I write what my brain dictates - I have not choice in the matter.&lt;/p&gt;

&lt;p&gt;Finally, I fully accept that many of these decisions are out of our control.  Customers, especially big ones, generally have the final say, they&amp;#39;ve potentially invested a lot of time on a certain stack and have a lot of legacy (read: code that still works) solutions in play.  True, but one of our goals is to at least inform these people of the alternatives and let them make an informed decision - maybe not today but soon enough the cost of developing and maintaining new systems built on out-of-support JDKs will come under scrutiny and they&amp;#39;ll need to consider alternatives, alternatives that you&amp;#39;ve already enlightened them about.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Neo4J Talk in November</title>
    <link rel="alternate" href="/blog/2012/11/02/neo4j-talk-in-november"/>
    <id>/blog/2012/11/02/neo4j-talk-in-november</id>
    <published>2012-11-02T00:00:00+00:00</published>
    <updated>2012-11-02T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Its been rather quiet around here of late, truth be told I&amp;#39;ve been rather busy with my work (this peak is a rather large one).  Being busy for me usually implies I&amp;#39;m not getting bored on cookie cutter, by the numbers web apps, being busy means I&amp;#39;m doing new interesting stuff.  I&amp;#39;ve been doing a bit of work with the UK Government, specifically DFID (Department for International Developement) around the nobel goal of transaprency and open data.  The project involves interrogating a lot of highly connected data in weird and wonderful ways which can mean only one thing - Graph Databases.  We tried the relational database route early on and it was causing too much pain to get the data we wanted,&lt;/p&gt;

&lt;div style="text-align:center; margin-bottom:15px;"&gt;
  &lt;img src="/images/joins.jpg" /&gt;
&lt;/div&gt;

&lt;p&gt;So having recently been enlightened by &lt;a href="https://twitter.com/jimwebber"&gt;Jim Webbers&lt;/a&gt; talk on &lt;a href="http://neo4j.org/"&gt;Neo4J&lt;/a&gt; I decided to try the Graph Database appraoch and it paid off, in spades.  Then one humble brag on Twitter later and I get asked to present a case study on Neo4J at the London User Group - and I&amp;#39;m stoked.  This is the first talk I&amp;#39;ve ever given that I don&amp;#39;t have to pretend to know what I&amp;#39;m talking about - awesome.&lt;/p&gt;

&lt;p&gt;If you&amp;#39;re in London on the 28th of November come along and see how I&amp;#39;ve (probably incorrectly) used Neo4J.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;CASE&lt;/span&gt; &lt;span class="n"&gt;STUDY&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;graphs&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;analyse&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;spending&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;international&lt;/span&gt; &lt;span class="n"&gt;development&lt;/span&gt;
&lt;span class="n"&gt;Wednesday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;November&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2012&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="n"&gt;PM&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="n"&gt;PM&lt;/span&gt;

&lt;span class="n"&gt;Skills&lt;/span&gt; &lt;span class="n"&gt;Matter&lt;/span&gt;
&lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="n"&gt;Skills&lt;/span&gt; &lt;span class="n"&gt;Matter&lt;/span&gt; &lt;span class="n"&gt;eXchange&lt;/span&gt;
&lt;span class="mi"&gt;116&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt; &lt;span class="n"&gt;Goswell&lt;/span&gt; &lt;span class="n"&gt;Road&lt;/span&gt;
&lt;span class="n"&gt;London&lt;/span&gt; &lt;span class="n"&gt;EC1V7DP&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://www.meetup.com/graphdb-london/events/87069112/" data-event="87069112" class="mu-rsvp-btn"&gt;RSVP&lt;/a&gt;&lt;/p&gt;

&lt;script&gt;!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s); js.id=id;js.async=true;js.src="https://secure.meetup.com/890357987448484755600/script/api/mu.btns.js?id=9e8dku34o6mqp5knqbjlk6lfvj";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","mu-bootjs");&lt;/script&gt;
</summary>
    <content type="html">&lt;p&gt;Its been rather quiet around here of late, truth be told I&amp;#39;ve been rather busy with my work (this peak is a rather large one).  Being busy for me usually implies I&amp;#39;m not getting bored on cookie cutter, by the numbers web apps, being busy means I&amp;#39;m doing new interesting stuff.  I&amp;#39;ve been doing a bit of work with the UK Government, specifically DFID (Department for International Developement) around the nobel goal of transaprency and open data.  The project involves interrogating a lot of highly connected data in weird and wonderful ways which can mean only one thing - Graph Databases.  We tried the relational database route early on and it was causing too much pain to get the data we wanted,&lt;/p&gt;

&lt;div style="text-align:center; margin-bottom:15px;"&gt;
  &lt;img src="/images/joins.jpg" /&gt;
&lt;/div&gt;

&lt;p&gt;So having recently been enlightened by &lt;a href="https://twitter.com/jimwebber"&gt;Jim Webbers&lt;/a&gt; talk on &lt;a href="http://neo4j.org/"&gt;Neo4J&lt;/a&gt; I decided to try the Graph Database appraoch and it paid off, in spades.  Then one humble brag on Twitter later and I get asked to present a case study on Neo4J at the London User Group - and I&amp;#39;m stoked.  This is the first talk I&amp;#39;ve ever given that I don&amp;#39;t have to pretend to know what I&amp;#39;m talking about - awesome.&lt;/p&gt;

&lt;p&gt;If you&amp;#39;re in London on the 28th of November come along and see how I&amp;#39;ve (probably incorrectly) used Neo4J.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;CASE&lt;/span&gt; &lt;span class="n"&gt;STUDY&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;graphs&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;analyse&lt;/span&gt; &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;spending&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;international&lt;/span&gt; &lt;span class="n"&gt;development&lt;/span&gt;
&lt;span class="n"&gt;Wednesday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;November&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2012&lt;/span&gt;
&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="n"&gt;PM&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="n"&gt;PM&lt;/span&gt;

&lt;span class="n"&gt;Skills&lt;/span&gt; &lt;span class="n"&gt;Matter&lt;/span&gt;
&lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="n"&gt;Skills&lt;/span&gt; &lt;span class="n"&gt;Matter&lt;/span&gt; &lt;span class="n"&gt;eXchange&lt;/span&gt;
&lt;span class="mi"&gt;116&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt; &lt;span class="n"&gt;Goswell&lt;/span&gt; &lt;span class="n"&gt;Road&lt;/span&gt;
&lt;span class="n"&gt;London&lt;/span&gt; &lt;span class="n"&gt;EC1V7DP&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://www.meetup.com/graphdb-london/events/87069112/" data-event="87069112" class="mu-rsvp-btn"&gt;RSVP&lt;/a&gt;&lt;/p&gt;

&lt;script&gt;!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s); js.id=id;js.async=true;js.src="https://secure.meetup.com/890357987448484755600/script/api/mu.btns.js?id=9e8dku34o6mqp5knqbjlk6lfvj";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","mu-bootjs");&lt;/script&gt;
</content>
  </entry>
  <entry>
    <title>Learning Resources for Scala, Play! and Mongo</title>
    <link rel="alternate" href="/blog/2012/10/06/learning-resources-for-scala-play-and-mongo"/>
    <id>/blog/2012/10/06/learning-resources-for-scala-play-and-mongo</id>
    <published>2012-10-06T00:00:00+01:00</published>
    <updated>2012-10-06T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;I&amp;#39;ve been asked a lot recently for some resources on various technologies, namely Scala, Play! (2.0) and Mongo so I thought I&amp;#39;d share the wealth (so to speak).&lt;/p&gt;

&lt;p&gt;Got any good resources that I haven&amp;#39;t listed here?  Let me know.&lt;/p&gt;

&lt;h2&gt;Scala&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.scala-lang.org/"&gt;Official Site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vimeo.com/40255430"&gt;Screencast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.scala-lang.org/node/1305"&gt;Various Links from the official site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://scalatron.github.com/"&gt;Scalatron&lt;/a&gt; - learn Scala by programming a game&lt;/li&gt;
&lt;li&gt;&lt;a href="http://twitter.github.com/scala_school/"&gt;Scala School&lt;/a&gt; - Twitters learning resource&lt;/li&gt;
&lt;li&gt;&lt;a href="http://typesafe.com/resources/book/scala-for-the-impatient"&gt;Scala for the Impatient&lt;/a&gt; - excellent &amp;ldquo;lite&amp;rdquo; version of a great book.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://typesafe.com/resources/videos"&gt;Scala Videos&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.coursera.org/course/progfun"&gt;Coursera Course&lt;/a&gt; - Scala course on Coursera by Martin Odersky. Only good for five weeks or so but during that time anyone can sign up and download the video lectures and materials.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Play!&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.playframework.org/"&gt;Official Site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.playframework.org/documentation/2.0.3/ScalaHome"&gt;Official Docs&lt;/a&gt; - Excellent resource&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/playframework/Play20/tree/master/samples/scala"&gt;Scala Code Samples&lt;/a&gt; - Some nice examples from the official Github repo.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://yobriefca.se/blog/2012/05/08/starter-for-10-scala/"&gt;Scala, Play! and Mongo&lt;/a&gt; - Blog post on writing a simple app using all those technologies.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.artima.com/articles/play2_scala_squeryl.html"&gt;Getting Started with Play! 2, Scala and Squeryl&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jamesward.com/2012/02/21/play-framework-2-with-scala-anorm-json-coffeescript-jquery-heroku"&gt;Play! 2 Getting Started&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Mongo&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.mongodb.org/"&gt;Official Website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://try.mongodb.org/"&gt;Try Mongo&lt;/a&gt; - A Tiny MongoDB Browser Shell (mini tutorial included)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://openmymind.net/mongodb.pdf"&gt;Little Book of Mongo&lt;/a&gt; (&lt;a href="http://openmymind.net/mongodb.epub"&gt;epub&lt;/a&gt;) - Book about Mongo&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mongly.com/"&gt;Mongly&lt;/a&gt; - Various tutorials and essays on MongoDB&lt;/li&gt;
&lt;li&gt;&lt;a href="https://speakerdeck.com/u/kouphax/p/mongodb"&gt;Presentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</summary>
    <content type="html">&lt;p&gt;I&amp;#39;ve been asked a lot recently for some resources on various technologies, namely Scala, Play! (2.0) and Mongo so I thought I&amp;#39;d share the wealth (so to speak).&lt;/p&gt;

&lt;p&gt;Got any good resources that I haven&amp;#39;t listed here?  Let me know.&lt;/p&gt;

&lt;h2&gt;Scala&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.scala-lang.org/"&gt;Official Site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vimeo.com/40255430"&gt;Screencast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.scala-lang.org/node/1305"&gt;Various Links from the official site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://scalatron.github.com/"&gt;Scalatron&lt;/a&gt; - learn Scala by programming a game&lt;/li&gt;
&lt;li&gt;&lt;a href="http://twitter.github.com/scala_school/"&gt;Scala School&lt;/a&gt; - Twitters learning resource&lt;/li&gt;
&lt;li&gt;&lt;a href="http://typesafe.com/resources/book/scala-for-the-impatient"&gt;Scala for the Impatient&lt;/a&gt; - excellent &amp;ldquo;lite&amp;rdquo; version of a great book.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://typesafe.com/resources/videos"&gt;Scala Videos&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.coursera.org/course/progfun"&gt;Coursera Course&lt;/a&gt; - Scala course on Coursera by Martin Odersky. Only good for five weeks or so but during that time anyone can sign up and download the video lectures and materials.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Play!&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.playframework.org/"&gt;Official Site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.playframework.org/documentation/2.0.3/ScalaHome"&gt;Official Docs&lt;/a&gt; - Excellent resource&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/playframework/Play20/tree/master/samples/scala"&gt;Scala Code Samples&lt;/a&gt; - Some nice examples from the official Github repo.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://yobriefca.se/blog/2012/05/08/starter-for-10-scala/"&gt;Scala, Play! and Mongo&lt;/a&gt; - Blog post on writing a simple app using all those technologies.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.artima.com/articles/play2_scala_squeryl.html"&gt;Getting Started with Play! 2, Scala and Squeryl&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jamesward.com/2012/02/21/play-framework-2-with-scala-anorm-json-coffeescript-jquery-heroku"&gt;Play! 2 Getting Started&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Mongo&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.mongodb.org/"&gt;Official Website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://try.mongodb.org/"&gt;Try Mongo&lt;/a&gt; - A Tiny MongoDB Browser Shell (mini tutorial included)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://openmymind.net/mongodb.pdf"&gt;Little Book of Mongo&lt;/a&gt; (&lt;a href="http://openmymind.net/mongodb.epub"&gt;epub&lt;/a&gt;) - Book about Mongo&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mongly.com/"&gt;Mongly&lt;/a&gt; - Various tutorials and essays on MongoDB&lt;/li&gt;
&lt;li&gt;&lt;a href="https://speakerdeck.com/u/kouphax/p/mongodb"&gt;Presentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>StackMob: Baas meets PaaS (Lightning Talk)</title>
    <link rel="alternate" href="https://vimeo.com/49405807"/>
    <id>https://vimeo.com/49405807</id>
    <published>2012-09-13T00:00:00+01:00</published>
    <updated>2012-09-13T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>StackMob Lightning Talk</title>
    <link rel="alternate" href="/blog/2012/09/13/stackmob-lightning-talk"/>
    <id>/blog/2012/09/13/stackmob-lightning-talk</id>
    <published>2012-09-13T00:00:00+01:00</published>
    <updated>2012-09-13T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;So I finally found an opportunity to deliver a quick lightning talk on &lt;a href="http://stackmob.com"&gt;StackMob&lt;/a&gt; at our
monthly CodeSlice sessions in work.  Knocked it up today over lunch and presented it tonight.  Would like to
pull this one out into a more in depth and interactive look&amp;hellip; just waiting for someone to ask :)&lt;/p&gt;

&lt;iframe src="http://player.vimeo.com/video/49405807?title=0&amp;amp;byline=0&amp;amp;portrait=0&amp;amp;color=ffffff" width="600" height="450" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;

&lt;script async class="speakerdeck-embed" data-id="5051d07ffe08c30002031d18" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;
</summary>
    <content type="html">&lt;p&gt;So I finally found an opportunity to deliver a quick lightning talk on &lt;a href="http://stackmob.com"&gt;StackMob&lt;/a&gt; at our
monthly CodeSlice sessions in work.  Knocked it up today over lunch and presented it tonight.  Would like to
pull this one out into a more in depth and interactive look&amp;hellip; just waiting for someone to ask :)&lt;/p&gt;

&lt;iframe src="http://player.vimeo.com/video/49405807?title=0&amp;amp;byline=0&amp;amp;portrait=0&amp;amp;color=ffffff" width="600" height="450" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;

&lt;script async class="speakerdeck-embed" data-id="5051d07ffe08c30002031d18" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;
</content>
  </entry>
  <entry>
    <title>Securely Serving Static Files on Heroku</title>
    <link rel="alternate" href="/blog/2012/08/21/securely-serving-static-files-on-heroku"/>
    <id>/blog/2012/08/21/securely-serving-static-files-on-heroku</id>
    <published>2012-08-21T00:00:00+01:00</published>
    <updated>2012-08-21T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;More than once I&amp;#39;ve had a need to host what is essentially static content on Heroku.  For example when building a simple internal web app for my company that used an existing API or Parse.  Invariably in this situation I have also needed to secure this app - nothing to drastic, no need for multiple user accounts or roles or any such nonsense (we generally run our non-essential systems on the honour system).  Basic auth is more than enough.&lt;/p&gt;

&lt;p&gt;So, static content plus basic auth.  Heroku itself doesn&amp;#39;t offer basic auth as an option (why would it?) and so you&amp;#39;d need to roll it into your app.  Once I hosted my static stuff inside a Scala/Play! app, once a Sinatra app and the other a Rails app - variety is the spice of life.  But each time I did it I felt a little dirty - it was noticeably slower serving this content from within an app and it seemed rather wasteful.  So, in a bid to stamp out technical debt, I&amp;#39;ve ripped out all those web frameworks an replaced them with good old Apache.&lt;/p&gt;

&lt;p&gt;Now anyone with any knowledge of Apache will already be able to deduce the steps required here - but I want to note it for posterity, for myself, when I forget, in about a week.&lt;/p&gt;

&lt;h2&gt;BuildPack&lt;/h2&gt;

&lt;p&gt;First things first you&amp;#39;ll want to get your hands on a custom &lt;a href="https://devcenter.heroku.com/articles/buildpacks"&gt;Heroku BuildPack&lt;/a&gt; - these are the things that prepare your app instance with all the software and support it needs to run.&lt;/p&gt;

&lt;p&gt;I recommend you fork and clone the &lt;a href="https://github.com/pearkes/heroku-buildpack-static"&gt;heroku-buildpack-static&lt;/a&gt; buildpack available from pearkes on GitHub.&lt;/p&gt;

&lt;h2&gt;.htpassword&lt;/h2&gt;

&lt;p&gt;Next you need to generate your &lt;code&gt;.htpasswd&lt;/code&gt; file that will serve as your store for your Basic Auth credentials.  The two simplest ways to generate one of these is to either use &lt;a href="http://www.htaccesstools.com/htpasswd-generator/"&gt;htaccesstools.com&amp;#39;s htpasswd generator&lt;/a&gt; or generate on via the command line.&lt;/p&gt;

&lt;p&gt;The simplest command to generate one is this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;htpasswd&lt;/span&gt; &lt;span class="na"&gt;-cb&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;password_file&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For example,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;htpasswd&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;cb&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;htpasswd&lt;/span&gt; &lt;span class="n"&gt;james&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Will generate a file in the current directory called .htpasswd (the standard name for these files) with a single entry of username = james and password = password.&lt;/p&gt;

&lt;h2&gt;Updating the BuildPack&lt;/h2&gt;

&lt;p&gt;Either run the above command in the &lt;code&gt;heroku-buildpack-static/conf&lt;/code&gt; folder or move your &lt;code&gt;.htpasswd&lt;/code&gt; file into the that folder.&lt;/p&gt;

&lt;p&gt;Next up you want to configure apache to authenticate against that generate password file.  Adding the following lines to the &lt;code&gt;httpd.conf&lt;/code&gt; file in the &lt;code&gt;heroku-buildpack-static/conf&lt;/code&gt; will lock all assets under your apps site down,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="n"&gt;AuthType&lt;/span&gt;      &lt;span class="n"&gt;Basic&lt;/span&gt;
    &lt;span class="n"&gt;AuthName&lt;/span&gt;      &lt;span class="s"&gt;&amp;quot;Authentication Required&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;AuthUserFile&lt;/span&gt;  &lt;span class="s"&gt;&amp;quot;/app/apache/conf/.htpasswd&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;Require&lt;/span&gt;       &lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This block should be added to the configuration section starting &lt;code&gt;&amp;lt;Directory /&amp;gt;&lt;/code&gt; i.e.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;  &lt;span class="nt"&gt;&amp;lt;Directory&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      Options FollowSymLinks
      AllowOverride None

      AuthType      Basic
      AuthName      &amp;quot;Authentication Required&amp;quot;
      AuthUserFile  &amp;quot;/app/apache/conf/.htpasswd&amp;quot;
      Require       valid-user

      Order deny,allow
      Deny from all
  &lt;span class="nt"&gt;&amp;lt;/Directory&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You&amp;#39;ll notice the &lt;code&gt;AuthUserFile&lt;/code&gt; points to the correct absolute path for our custom .htpasswd file.  If you called it anything else please update this line accordingly.&lt;/p&gt;

&lt;p&gt;Commit and push that to your forked repo.&lt;/p&gt;

&lt;h2&gt;Using the BuildPack&lt;/h2&gt;

&lt;p&gt;Finally we need to tell Heroku to use the custom buildpack.  If you have yet to create an app then you can specify the buildpack during creation,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;heroku&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;buildpack&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you have created you app already you can add the buildpack through an additional config setting&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;heroku&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;BUILDPACK_URL&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Push your new or updated site to Heroku and watch in awe as your site is that bit more secure.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;More than once I&amp;#39;ve had a need to host what is essentially static content on Heroku.  For example when building a simple internal web app for my company that used an existing API or Parse.  Invariably in this situation I have also needed to secure this app - nothing to drastic, no need for multiple user accounts or roles or any such nonsense (we generally run our non-essential systems on the honour system).  Basic auth is more than enough.&lt;/p&gt;

&lt;p&gt;So, static content plus basic auth.  Heroku itself doesn&amp;#39;t offer basic auth as an option (why would it?) and so you&amp;#39;d need to roll it into your app.  Once I hosted my static stuff inside a Scala/Play! app, once a Sinatra app and the other a Rails app - variety is the spice of life.  But each time I did it I felt a little dirty - it was noticeably slower serving this content from within an app and it seemed rather wasteful.  So, in a bid to stamp out technical debt, I&amp;#39;ve ripped out all those web frameworks an replaced them with good old Apache.&lt;/p&gt;

&lt;p&gt;Now anyone with any knowledge of Apache will already be able to deduce the steps required here - but I want to note it for posterity, for myself, when I forget, in about a week.&lt;/p&gt;

&lt;h2&gt;BuildPack&lt;/h2&gt;

&lt;p&gt;First things first you&amp;#39;ll want to get your hands on a custom &lt;a href="https://devcenter.heroku.com/articles/buildpacks"&gt;Heroku BuildPack&lt;/a&gt; - these are the things that prepare your app instance with all the software and support it needs to run.&lt;/p&gt;

&lt;p&gt;I recommend you fork and clone the &lt;a href="https://github.com/pearkes/heroku-buildpack-static"&gt;heroku-buildpack-static&lt;/a&gt; buildpack available from pearkes on GitHub.&lt;/p&gt;

&lt;h2&gt;.htpassword&lt;/h2&gt;

&lt;p&gt;Next you need to generate your &lt;code&gt;.htpasswd&lt;/code&gt; file that will serve as your store for your Basic Auth credentials.  The two simplest ways to generate one of these is to either use &lt;a href="http://www.htaccesstools.com/htpasswd-generator/"&gt;htaccesstools.com&amp;#39;s htpasswd generator&lt;/a&gt; or generate on via the command line.&lt;/p&gt;

&lt;p&gt;The simplest command to generate one is this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;htpasswd&lt;/span&gt; &lt;span class="na"&gt;-cb&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;password_file&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For example,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;htpasswd&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;cb&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;htpasswd&lt;/span&gt; &lt;span class="n"&gt;james&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Will generate a file in the current directory called .htpasswd (the standard name for these files) with a single entry of username = james and password = password.&lt;/p&gt;

&lt;h2&gt;Updating the BuildPack&lt;/h2&gt;

&lt;p&gt;Either run the above command in the &lt;code&gt;heroku-buildpack-static/conf&lt;/code&gt; folder or move your &lt;code&gt;.htpasswd&lt;/code&gt; file into the that folder.&lt;/p&gt;

&lt;p&gt;Next up you want to configure apache to authenticate against that generate password file.  Adding the following lines to the &lt;code&gt;httpd.conf&lt;/code&gt; file in the &lt;code&gt;heroku-buildpack-static/conf&lt;/code&gt; will lock all assets under your apps site down,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="n"&gt;AuthType&lt;/span&gt;      &lt;span class="n"&gt;Basic&lt;/span&gt;
    &lt;span class="n"&gt;AuthName&lt;/span&gt;      &lt;span class="s"&gt;&amp;quot;Authentication Required&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;AuthUserFile&lt;/span&gt;  &lt;span class="s"&gt;&amp;quot;/app/apache/conf/.htpasswd&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;Require&lt;/span&gt;       &lt;span class="n"&gt;valid&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This block should be added to the configuration section starting &lt;code&gt;&amp;lt;Directory /&amp;gt;&lt;/code&gt; i.e.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;  &lt;span class="nt"&gt;&amp;lt;Directory&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      Options FollowSymLinks
      AllowOverride None

      AuthType      Basic
      AuthName      &amp;quot;Authentication Required&amp;quot;
      AuthUserFile  &amp;quot;/app/apache/conf/.htpasswd&amp;quot;
      Require       valid-user

      Order deny,allow
      Deny from all
  &lt;span class="nt"&gt;&amp;lt;/Directory&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You&amp;#39;ll notice the &lt;code&gt;AuthUserFile&lt;/code&gt; points to the correct absolute path for our custom .htpasswd file.  If you called it anything else please update this line accordingly.&lt;/p&gt;

&lt;p&gt;Commit and push that to your forked repo.&lt;/p&gt;

&lt;h2&gt;Using the BuildPack&lt;/h2&gt;

&lt;p&gt;Finally we need to tell Heroku to use the custom buildpack.  If you have yet to create an app then you can specify the buildpack during creation,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;heroku&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;buildpack&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you have created you app already you can add the buildpack through an additional config setting&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;heroku&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;BUILDPACK_URL&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;your&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Push your new or updated site to Heroku and watch in awe as your site is that bit more secure.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Dependencies in JavaScript: Constructor, Setter or Global</title>
    <link rel="alternate" href="/blog/2012/08/21/dependencies-in-javascript-constructor-setter-or-global"/>
    <id>/blog/2012/08/21/dependencies-in-javascript-constructor-setter-or-global</id>
    <published>2012-08-21T00:00:00+01:00</published>
    <updated>2012-08-21T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;There has been an interesting conversation on Twitter over the last number of hours between @derickbailey and a number of other people and it all started with this tweet,&lt;/p&gt;

&lt;blockquote class="twitter-tweet tw-align-center"&gt;&lt;p&gt;anyone have links to articles on why setter injection is evil? /cc &lt;a href="https://twitter.com/jbogard"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;jbogard&lt;/b&gt;&lt;/a&gt; &lt;a href="https://twitter.com/jeremydmiller"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;jeremydmiller&lt;/b&gt;&lt;/a&gt; &lt;a href="https://twitter.com/jflanagan"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;jflanagan&lt;/b&gt;&lt;/a&gt; &lt;a href="https://twitter.com/chadmyers"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;chadmyers&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;&amp;mdash; derickbailey (@derickbailey) &lt;a href="https://twitter.com/derickbailey/status/237658824163614720" data-datetime="2012-08-20T21:14:13+00:00"&gt;August 20, 2012&lt;/a&gt;&lt;/blockquote&gt;

&lt;script src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;

&lt;p&gt;The conversation has been around using DI and IoC in JavaScript (yes I know they are not one in the same, and I know a Container is not a necessary part of DI or IoC thank you very much).  Simple answer is this - good patterns have a place in any language provided they aren&amp;#39;t abused mercilessly.  But lets get back to the discussion - why would you use constructor injection over setter injection?  Is setter injection evil?  Obviously no strategy is actually evil per-say - just used in the wrong place at the wrong time. So lets go back to the first question - constructor injection vs. setter injection.&lt;/p&gt;

&lt;h2&gt;Constructor Injection or Setter Injection&lt;/h2&gt;

&lt;p&gt;The simplest answer to this was one I gave @derickbailey earlier,&lt;/p&gt;

&lt;blockquote class="twitter-tweet tw-align-center" data-in-reply-to="237664796298854401"&gt;&lt;p&gt;&lt;a href="https://twitter.com/derickbailey"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;derickbailey&lt;/b&gt;&lt;/a&gt; resolve mandatory dependenciesvia constructor injection, optional dependencies via setter.  This is a common convention.&lt;/p&gt;&amp;mdash; James Hughes (@kouphax) &lt;a href="https://twitter.com/kouphax/status/237792703826522112" data-datetime="2012-08-21T06:06:13+00:00"&gt;August 21, 2012&lt;/a&gt;&lt;/blockquote&gt;

&lt;script src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;

&lt;p&gt;This little bit of knowledge I&amp;#39;ve had since living down in the guts of Spring MVC about 5 years ago and it makes a lot of sense regardless of how those dependencies are getting in there.&lt;/p&gt;

&lt;h2&gt;Fail Early&lt;/h2&gt;

&lt;p&gt;When your code goes into an invalid state you want to fail as quickly as possible, this makes debugging much easier and prevents an avalanche of unexpected behaviour.  Using constructor injection (and asserting the existence of dependencies) gives you this ability.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;   
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;

        &lt;span class="c1"&gt;// rest of my code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// FAIL FAIL FAIL&lt;/span&gt;
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you tried to achieve the same thing with setter injection you would be failing much later in the proceedings,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;  
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// FAIL FAIL FAIL&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now imagine that the last two lines are miles apart in code-lines, you&amp;#39;ve gone and lost all context when debugging.  Sure in this trivial example it would be fairly easy to resolve this but if you&amp;#39;ve gone and lost the plot and created a heavily nested object graph you&amp;#39;ll be crying before they day is out.&lt;/p&gt;

&lt;p&gt;Now setter injection does have it&amp;#39;s place - for &lt;strong&gt;optional&lt;/strong&gt; dependencies,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;   
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;

        &lt;span class="c1"&gt;// rest of my code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setOptionalC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;optionalC&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;optionalC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;optionalC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;optionalC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;optionalC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;doing a thing...&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setOptionalC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// logs &amp;quot;doing a thing...&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So the extension of the rule is that &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Anything injected via &lt;strong&gt;setter injection&lt;/strong&gt; needs to be either defaulted initially or checked for existence before use.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;Readability&lt;/h2&gt;

&lt;p&gt;By following this convention, heck by following any agreed convention, you get better visibility of the expected behaviour of your code.  You know what the object needs to get the job done.  That feels like a poor argument but I think it still warrants a mention here.&lt;/p&gt;

&lt;h2&gt;Over Engineering and Deep Graphs&lt;/h2&gt;

&lt;p&gt;Obviously if you&amp;#39;ve over-designed your classes or it has grown out of control this approach becomes difficult to manage.  I&amp;#39;ve seen something akin to this in some projects,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;CoordinatorOfAllTheThings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;....)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Someone has decided to make every bit of functionality it&amp;#39;s own little class or module and so the dependency graph has become incredibly broad.  In fact this might suggest they are creating a deep graph as well and simply passing the dependencies down the chain.  &lt;strong&gt;If you have a lot of dependencies then there is something wrong with the object you are creating&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For fine grained, inter-object communication dependency injection is fine but when you are scaling up to more coarse, inter-module or component communication an evented or message based approach is almost always a better option.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="c1"&gt;// rest of previous code&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="nx"&gt;EventStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;doneathing&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;EventStream&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;OtherThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredD&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;EventStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;doneathing&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;requiredD&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;other&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;OtherThing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;stuff done&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// logs &amp;quot;stuff done&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is a rather contrived example but it should server a point. &lt;/p&gt;

&lt;h3&gt;The Global Issue&lt;/h3&gt;

&lt;p&gt;You&amp;#39;ll notice the EventStream object in the code above is global, you&amp;#39;ll also notice I have skipped part of this posts title  (&amp;hellip; or Global).  Lets come to that now.  It is possible to achieve the same results as constructor/setter injection using global scope,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;    
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;

        &lt;span class="c1"&gt;// rest of my code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// FAIL FAIL FAIL&lt;/span&gt;
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So rather than inject the necessary dependencies in we are relying on the fact they exist in global scope.  This works fine in some situations.  The EventStream object above is a global hub that can be used throughout the application.  I&amp;#39;m ok with that.  The risk of global scope is that it&amp;#39;s easy for objects to be redefined by other actors in your system so existence or behaviour is never guaranteed.  So use sparingly.&lt;/p&gt;

&lt;h2&gt;Moptional&lt;/h2&gt;

&lt;p&gt;The other alternative approach would be to make everything Moptional.  That is, anything mandatory should be instantiated with a default and provide setter injection for changing default behaviour.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;DefaultRequiredA&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;DefaultRequiredB&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;// rest of my code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredB&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;CustomRequiredB&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You kind of get the best of worlds here - not having to worry about default behaviour but have the ability to override this (for example in testing).  But then you need to think about this.  Why are you providing this sort of strategy?  Are you simply hiding all implementation for an object but providing setters and getter to simply aid testing?  If that&amp;#39;s the case - STOP.  Your code should be testable but you should not change your code to simply aid testing.  Perhaps its time to go back and re-think your strategy?  Also, for testing - it&amp;#39;s entirely possible, given the dynamic nature of JavaScript, to redefine the internal dependencies prior to them being instantiated in your object anyway.  Don&amp;#39;t add features or behaviour that you don&amp;#39;t actually need to deliver the solution.&lt;/p&gt;

&lt;h2&gt;Wrap Up&lt;/h2&gt;

&lt;p&gt;This was playing over and over on my ride into work this morning (I cycle I have a lot of thinking time) and I wanted to get it out there.  Hopefully be useful to people asking some questions on this topic.&lt;/p&gt;

&lt;p&gt;Oh and IoC &lt;strong&gt;Containers&lt;/strong&gt; in JavaScript&amp;hellip;&amp;hellip; don&amp;#39;t.&lt;/p&gt;

&lt;p&gt;My $0.02&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;There has been an interesting conversation on Twitter over the last number of hours between @derickbailey and a number of other people and it all started with this tweet,&lt;/p&gt;

&lt;blockquote class="twitter-tweet tw-align-center"&gt;&lt;p&gt;anyone have links to articles on why setter injection is evil? /cc &lt;a href="https://twitter.com/jbogard"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;jbogard&lt;/b&gt;&lt;/a&gt; &lt;a href="https://twitter.com/jeremydmiller"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;jeremydmiller&lt;/b&gt;&lt;/a&gt; &lt;a href="https://twitter.com/jflanagan"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;jflanagan&lt;/b&gt;&lt;/a&gt; &lt;a href="https://twitter.com/chadmyers"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;chadmyers&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;&amp;mdash; derickbailey (@derickbailey) &lt;a href="https://twitter.com/derickbailey/status/237658824163614720" data-datetime="2012-08-20T21:14:13+00:00"&gt;August 20, 2012&lt;/a&gt;&lt;/blockquote&gt;

&lt;script src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;

&lt;p&gt;The conversation has been around using DI and IoC in JavaScript (yes I know they are not one in the same, and I know a Container is not a necessary part of DI or IoC thank you very much).  Simple answer is this - good patterns have a place in any language provided they aren&amp;#39;t abused mercilessly.  But lets get back to the discussion - why would you use constructor injection over setter injection?  Is setter injection evil?  Obviously no strategy is actually evil per-say - just used in the wrong place at the wrong time. So lets go back to the first question - constructor injection vs. setter injection.&lt;/p&gt;

&lt;h2&gt;Constructor Injection or Setter Injection&lt;/h2&gt;

&lt;p&gt;The simplest answer to this was one I gave @derickbailey earlier,&lt;/p&gt;

&lt;blockquote class="twitter-tweet tw-align-center" data-in-reply-to="237664796298854401"&gt;&lt;p&gt;&lt;a href="https://twitter.com/derickbailey"&gt;&lt;s&gt;@&lt;/s&gt;&lt;b&gt;derickbailey&lt;/b&gt;&lt;/a&gt; resolve mandatory dependenciesvia constructor injection, optional dependencies via setter.  This is a common convention.&lt;/p&gt;&amp;mdash; James Hughes (@kouphax) &lt;a href="https://twitter.com/kouphax/status/237792703826522112" data-datetime="2012-08-21T06:06:13+00:00"&gt;August 21, 2012&lt;/a&gt;&lt;/blockquote&gt;

&lt;script src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;

&lt;p&gt;This little bit of knowledge I&amp;#39;ve had since living down in the guts of Spring MVC about 5 years ago and it makes a lot of sense regardless of how those dependencies are getting in there.&lt;/p&gt;

&lt;h2&gt;Fail Early&lt;/h2&gt;

&lt;p&gt;When your code goes into an invalid state you want to fail as quickly as possible, this makes debugging much easier and prevents an avalanche of unexpected behaviour.  Using constructor injection (and asserting the existence of dependencies) gives you this ability.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;   
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;

        &lt;span class="c1"&gt;// rest of my code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// FAIL FAIL FAIL&lt;/span&gt;
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you tried to achieve the same thing with setter injection you would be failing much later in the proceedings,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;  
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// FAIL FAIL FAIL&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now imagine that the last two lines are miles apart in code-lines, you&amp;#39;ve gone and lost all context when debugging.  Sure in this trivial example it would be fairly easy to resolve this but if you&amp;#39;ve gone and lost the plot and created a heavily nested object graph you&amp;#39;ll be crying before they day is out.&lt;/p&gt;

&lt;p&gt;Now setter injection does have it&amp;#39;s place - for &lt;strong&gt;optional&lt;/strong&gt; dependencies,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;   
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;

        &lt;span class="c1"&gt;// rest of my code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setOptionalC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;optionalC&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;optionalC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;optionalC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;optionalC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;optionalC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;doing a thing...&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setOptionalC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// logs &amp;quot;doing a thing...&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So the extension of the rule is that &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Anything injected via &lt;strong&gt;setter injection&lt;/strong&gt; needs to be either defaulted initially or checked for existence before use.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;Readability&lt;/h2&gt;

&lt;p&gt;By following this convention, heck by following any agreed convention, you get better visibility of the expected behaviour of your code.  You know what the object needs to get the job done.  That feels like a poor argument but I think it still warrants a mention here.&lt;/p&gt;

&lt;h2&gt;Over Engineering and Deep Graphs&lt;/h2&gt;

&lt;p&gt;Obviously if you&amp;#39;ve over-designed your classes or it has grown out of control this approach becomes difficult to manage.  I&amp;#39;ve seen something akin to this in some projects,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;CoordinatorOfAllTheThings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;....)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Someone has decided to make every bit of functionality it&amp;#39;s own little class or module and so the dependency graph has become incredibly broad.  In fact this might suggest they are creating a deep graph as well and simply passing the dependencies down the chain.  &lt;strong&gt;If you have a lot of dependencies then there is something wrong with the object you are creating&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For fine grained, inter-object communication dependency injection is fine but when you are scaling up to more coarse, inter-module or component communication an evented or message based approach is almost always a better option.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="c1"&gt;// rest of previous code&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="nx"&gt;EventStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;doneathing&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;EventStream&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;trigger&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;OtherThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredD&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;EventStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;doneathing&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;requiredD&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;other&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;OtherThing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;stuff done&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// logs &amp;quot;stuff done&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is a rather contrived example but it should server a point. &lt;/p&gt;

&lt;h3&gt;The Global Issue&lt;/h3&gt;

&lt;p&gt;You&amp;#39;ll notice the EventStream object in the code above is global, you&amp;#39;ll also notice I have skipped part of this posts title  (&amp;hellip; or Global).  Lets come to that now.  It is possible to achieve the same results as constructor/setter injection using global scope,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;    
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Missing Dependency&amp;quot;&lt;/span&gt;

        &lt;span class="c1"&gt;// rest of my code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// FAIL FAIL FAIL&lt;/span&gt;
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So rather than inject the necessary dependencies in we are relying on the fact they exist in global scope.  This works fine in some situations.  The EventStream object above is a global hub that can be used throughout the application.  I&amp;#39;m ok with that.  The risk of global scope is that it&amp;#39;s easy for objects to be redefined by other actors in your system so existence or behaviour is never guaranteed.  So use sparingly.&lt;/p&gt;

&lt;h2&gt;Moptional&lt;/h2&gt;

&lt;p&gt;The other alternative approach would be to make everything Moptional.  That is, anything mandatory should be instantiated with a default and provide setter injection for changing default behaviour.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;MyThingy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;DefaultRequiredA&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;DefaultRequiredB&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;// rest of my code&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;MyThingy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;magic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requiredB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;beepboop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;thing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MyThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setRequiredB&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;CustomRequiredB&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="nx"&gt;thing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doAThing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You kind of get the best of worlds here - not having to worry about default behaviour but have the ability to override this (for example in testing).  But then you need to think about this.  Why are you providing this sort of strategy?  Are you simply hiding all implementation for an object but providing setters and getter to simply aid testing?  If that&amp;#39;s the case - STOP.  Your code should be testable but you should not change your code to simply aid testing.  Perhaps its time to go back and re-think your strategy?  Also, for testing - it&amp;#39;s entirely possible, given the dynamic nature of JavaScript, to redefine the internal dependencies prior to them being instantiated in your object anyway.  Don&amp;#39;t add features or behaviour that you don&amp;#39;t actually need to deliver the solution.&lt;/p&gt;

&lt;h2&gt;Wrap Up&lt;/h2&gt;

&lt;p&gt;This was playing over and over on my ride into work this morning (I cycle I have a lot of thinking time) and I wanted to get it out there.  Hopefully be useful to people asking some questions on this topic.&lt;/p&gt;

&lt;p&gt;Oh and IoC &lt;strong&gt;Containers&lt;/strong&gt; in JavaScript&amp;hellip;&amp;hellip; don&amp;#39;t.&lt;/p&gt;

&lt;p&gt;My $0.02&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Backend as a Service - Part One</title>
    <link rel="alternate" href="/blog/2012/08/08/backend-as-a-service-part-one"/>
    <id>/blog/2012/08/08/backend-as-a-service-part-one</id>
    <published>2012-08-08T00:00:00+01:00</published>
    <updated>2012-08-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;I recently wrote an article for &lt;a href="http://cloudspring.com/"&gt;CloudSpring&lt;/a&gt; (a part of the &lt;a href="http://www.sitepoint.com/"&gt;SitePoint&lt;/a&gt; family) around what you can expect and what you should think about when going for one of the &amp;ldquo;Backend as a Service&amp;rdquo; offerings on the market.  &lt;/p&gt;

&lt;p&gt;The article is &lt;a href="http://cloudspring.com/backend-as-a-service-part-1/"&gt;now live&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://cloudspring.com/backend-as-a-service-part-1/"&gt;CloudSpring: Backend as a Service Part 1&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Part 2, the one where I look at whats actually out there, will be ready within the next week.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I recently wrote an article for &lt;a href="http://cloudspring.com/"&gt;CloudSpring&lt;/a&gt; (a part of the &lt;a href="http://www.sitepoint.com/"&gt;SitePoint&lt;/a&gt; family) around what you can expect and what you should think about when going for one of the &amp;ldquo;Backend as a Service&amp;rdquo; offerings on the market.  &lt;/p&gt;

&lt;p&gt;The article is &lt;a href="http://cloudspring.com/backend-as-a-service-part-1/"&gt;now live&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;a href="http://cloudspring.com/backend-as-a-service-part-1/"&gt;CloudSpring: Backend as a Service Part 1&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Part 2, the one where I look at whats actually out there, will be ready within the next week.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Fear of Code</title>
    <link rel="alternate" href="/blog/2012/08/05/fear-of-code"/>
    <id>/blog/2012/08/05/fear-of-code</id>
    <published>2012-08-05T00:00:00+01:00</published>
    <updated>2012-08-05T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;More silly wishy washy nonsense - take what you will.&lt;/p&gt;

&lt;p&gt;Recently Thomas Fuchs has this to say on twitter,&lt;/p&gt;

&lt;blockquote class="twitter-tweet"&gt;&lt;p&gt;As a programmer, you should be afraid of code, and eliminate as much as possible.&lt;/p&gt;&amp;mdash; Thomas Fuchs (@thomasfuchs) &lt;a href="https://twitter.com/thomasfuchs/status/230871987881390081" data-datetime="2012-08-02T03:45:45+00:00"&gt;August 2, 2012&lt;/a&gt;&lt;/blockquote&gt;

&lt;script src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;

&lt;p&gt;Its great, I love this stuff and it got me thinking and I thought why not put my thoughts up here, right?  After all this is what this place is all about.&lt;/p&gt;

&lt;p&gt;Rather than describe the emotion as fear (&amp;ldquo;be afraid of code&amp;rdquo;) i&amp;#39;d posit that, as a programmer, you should be respectful of code.  Rather than eliminate as much as possible you should conserve it as much as possible - don&amp;#39;t write it in the first place.  &lt;/p&gt;

&lt;p&gt;A while back I posted something similar on Twitter - I can&amp;#39;t find the tweet right now but it went a little something like this,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Adding code is great, removing code is greater but not writing the code in the first place is greatest&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As a developer it is very easy to fall into the trap of creating some sort of highly reusable complex masterpiece that is going to change the way we write code forever.  But down that road, madness lies.  Desigining too much, adding too many features, creating too many abstractions, handling every single edge case, writing too many tests - all this stuff is just extra complexity, extra code that simply muddies the solution and makes it harder for someone to understand the solution.  More code doesn&amp;#39;t solve the problem faster, more code doesn&amp;#39;t make things easier, more code doesn&amp;#39;t help.&lt;/p&gt;

&lt;p&gt;In other words - writing too much code, regardless of quality is just a selfish act.  That goes for 3rd party code too.&lt;/p&gt;

&lt;p&gt;Quit it.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;More silly wishy washy nonsense - take what you will.&lt;/p&gt;

&lt;p&gt;Recently Thomas Fuchs has this to say on twitter,&lt;/p&gt;

&lt;blockquote class="twitter-tweet"&gt;&lt;p&gt;As a programmer, you should be afraid of code, and eliminate as much as possible.&lt;/p&gt;&amp;mdash; Thomas Fuchs (@thomasfuchs) &lt;a href="https://twitter.com/thomasfuchs/status/230871987881390081" data-datetime="2012-08-02T03:45:45+00:00"&gt;August 2, 2012&lt;/a&gt;&lt;/blockquote&gt;

&lt;script src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;

&lt;p&gt;Its great, I love this stuff and it got me thinking and I thought why not put my thoughts up here, right?  After all this is what this place is all about.&lt;/p&gt;

&lt;p&gt;Rather than describe the emotion as fear (&amp;ldquo;be afraid of code&amp;rdquo;) i&amp;#39;d posit that, as a programmer, you should be respectful of code.  Rather than eliminate as much as possible you should conserve it as much as possible - don&amp;#39;t write it in the first place.  &lt;/p&gt;

&lt;p&gt;A while back I posted something similar on Twitter - I can&amp;#39;t find the tweet right now but it went a little something like this,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Adding code is great, removing code is greater but not writing the code in the first place is greatest&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As a developer it is very easy to fall into the trap of creating some sort of highly reusable complex masterpiece that is going to change the way we write code forever.  But down that road, madness lies.  Desigining too much, adding too many features, creating too many abstractions, handling every single edge case, writing too many tests - all this stuff is just extra complexity, extra code that simply muddies the solution and makes it harder for someone to understand the solution.  More code doesn&amp;#39;t solve the problem faster, more code doesn&amp;#39;t make things easier, more code doesn&amp;#39;t help.&lt;/p&gt;

&lt;p&gt;In other words - writing too much code, regardless of quality is just a selfish act.  That goes for 3rd party code too.&lt;/p&gt;

&lt;p&gt;Quit it.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>expect.kt - Testing Library for Kotlin</title>
    <link rel="alternate" href="/blog/2012/07/25/expect-dot-kt-testing-library-for-kotlin"/>
    <id>/blog/2012/07/25/expect-dot-kt-testing-library-for-kotlin</id>
    <published>2012-07-25T00:00:00+01:00</published>
    <updated>2012-07-25T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;In a bid to delve into the &lt;a href="http://kotlin.jetbrains.org/"&gt;language&lt;/a&gt; a bit further than a rake of tiny console apps I decided to do something &amp;ldquo;real&amp;rdquo; with Kotlin.  With that in mind - welcome &lt;a href="https://github.com/kouphax/expect.kt"&gt;expect.kt&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It started purely as a learning venture but I think there is a certain usefulness in the library so its probably worth sharing :).  Now it&amp;#39;s worth noting that kotlin already has a number of testing statements that you can achieve a lot of this stuff with - this library gives you a few things over and above these statements &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Alternative syntax.  Testing is quite a personal thing and some people like to write things in different ways.&lt;/li&gt;
&lt;li&gt;Descriptive assertions.  Some would say &lt;code&gt;expect(2).toBePositive()&lt;/code&gt; reads better than &lt;code&gt;assertTrue(2 &amp;gt; 0)&lt;/code&gt; or &lt;code&gt;expect(2 &amp;gt; 0) { true }&lt;/code&gt;.  Again its all about taste, and variety is the spice of life.&lt;/li&gt;
&lt;li&gt;Chained assertions.  See later&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rather than some campaign to replace the inbuilt expectations and assertions this library intended to complement them.&lt;/p&gt;

&lt;h2&gt;So what is expect.kt?&lt;/h2&gt;

&lt;p&gt;Expect.kt is a set of (growing) assertions/expectations that you can use in your kotlin based tests.  It gives you a number of ways to assert your expectations and gives you quite descriptive methods in which to do it.&lt;/p&gt;

&lt;h3&gt;Expect Syntax&lt;/h3&gt;

&lt;p&gt;The  expect syntax is the default way to assert things,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;package&lt;/span&gt; &lt;span class="n"&gt;tests&lt;/span&gt;

&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;junit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Test&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;kotlin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expectations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;StringExpectationTests&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;testHelloWorld&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;toStartWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Most of that is boilerplate JUnit testy things but the key line is&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;toStartWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Reads quite nicely IMHO.&lt;/p&gt;

&lt;h3&gt;Should Syntax&lt;/h3&gt;

&lt;p&gt;The should syntax offers a more fluent syntax if you want to call it that, if we wanted to write the same test above using the should syntax we could do this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So rather than wrap your target with an expect you get and extension function to fluently assert it.&lt;/p&gt;

&lt;h3&gt;Chaining&lt;/h3&gt;

&lt;p&gt;Sometimes making a single assertion on a result isn&amp;#39;t enough and rather than write &lt;code&gt;assertTrue(...)&lt;/code&gt; multiple times you can use extpect.kt&amp;#39;s chaining support.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;toStartWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;toEndWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;rld&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or, with the should syntax,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;endWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;rld&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It&amp;#39;s a bit more readable than expect after expect, right?&lt;/p&gt;

&lt;p&gt;So thats it for now - there are a number of assertions implemented already on the useful types (Strings, Ints, Doubles, Dates, Booleans for example) and there are more planned on the way.  Currently you&amp;#39;ll be wanting to build from source (or copy/paste what you need).&lt;/p&gt;

&lt;p&gt;Finally - A shout out to .NETs &lt;a href="http://fluentassertions.codeplex.com/"&gt;FluentAssertions&lt;/a&gt; where a lot of the assertions found their origin!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/kouphax/expect.kt"&gt;expect.kt&lt;/a&gt;.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;In a bid to delve into the &lt;a href="http://kotlin.jetbrains.org/"&gt;language&lt;/a&gt; a bit further than a rake of tiny console apps I decided to do something &amp;ldquo;real&amp;rdquo; with Kotlin.  With that in mind - welcome &lt;a href="https://github.com/kouphax/expect.kt"&gt;expect.kt&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It started purely as a learning venture but I think there is a certain usefulness in the library so its probably worth sharing :).  Now it&amp;#39;s worth noting that kotlin already has a number of testing statements that you can achieve a lot of this stuff with - this library gives you a few things over and above these statements &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Alternative syntax.  Testing is quite a personal thing and some people like to write things in different ways.&lt;/li&gt;
&lt;li&gt;Descriptive assertions.  Some would say &lt;code&gt;expect(2).toBePositive()&lt;/code&gt; reads better than &lt;code&gt;assertTrue(2 &amp;gt; 0)&lt;/code&gt; or &lt;code&gt;expect(2 &amp;gt; 0) { true }&lt;/code&gt;.  Again its all about taste, and variety is the spice of life.&lt;/li&gt;
&lt;li&gt;Chained assertions.  See later&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rather than some campaign to replace the inbuilt expectations and assertions this library intended to complement them.&lt;/p&gt;

&lt;h2&gt;So what is expect.kt?&lt;/h2&gt;

&lt;p&gt;Expect.kt is a set of (growing) assertions/expectations that you can use in your kotlin based tests.  It gives you a number of ways to assert your expectations and gives you quite descriptive methods in which to do it.&lt;/p&gt;

&lt;h3&gt;Expect Syntax&lt;/h3&gt;

&lt;p&gt;The  expect syntax is the default way to assert things,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;package&lt;/span&gt; &lt;span class="n"&gt;tests&lt;/span&gt;

&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;junit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Test&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;kotlin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expectations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;StringExpectationTests&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;testHelloWorld&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;toStartWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Most of that is boilerplate JUnit testy things but the key line is&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;toStartWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Reads quite nicely IMHO.&lt;/p&gt;

&lt;h3&gt;Should Syntax&lt;/h3&gt;

&lt;p&gt;The should syntax offers a more fluent syntax if you want to call it that, if we wanted to write the same test above using the should syntax we could do this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So rather than wrap your target with an expect you get and extension function to fluently assert it.&lt;/p&gt;

&lt;h3&gt;Chaining&lt;/h3&gt;

&lt;p&gt;Sometimes making a single assertion on a result isn&amp;#39;t enough and rather than write &lt;code&gt;assertTrue(...)&lt;/code&gt; multiple times you can use extpect.kt&amp;#39;s chaining support.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;toStartWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;toEndWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;rld&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or, with the should syntax,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="s"&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hell&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;and&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;endWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;rld&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It&amp;#39;s a bit more readable than expect after expect, right?&lt;/p&gt;

&lt;p&gt;So thats it for now - there are a number of assertions implemented already on the useful types (Strings, Ints, Doubles, Dates, Booleans for example) and there are more planned on the way.  Currently you&amp;#39;ll be wanting to build from source (or copy/paste what you need).&lt;/p&gt;

&lt;p&gt;Finally - A shout out to .NETs &lt;a href="http://fluentassertions.codeplex.com/"&gt;FluentAssertions&lt;/a&gt; where a lot of the assertions found their origin!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/kouphax/expect.kt"&gt;expect.kt&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Kotlin: Nullable Extensions</title>
    <link rel="alternate" href="/blog/2012/07/18/kotlin-nullable-extensions"/>
    <id>/blog/2012/07/18/kotlin-nullable-extensions</id>
    <published>2012-07-18T00:00:00+01:00</published>
    <updated>2012-07-18T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Haskell doesn&amp;#39;t have if statements - that blew my mind the first time my old Scala mentor told me it.  &lt;code&gt;if&lt;/code&gt;s just don&amp;#39;t work with a strong function approach.  Plus you know what - &lt;code&gt;if&lt;/code&gt;s are rather ugly especially when you need to wrap ALL THE THINGS in a null check.  Scala has a type called &lt;code&gt;Option&lt;/code&gt;.  An &lt;code&gt;Option&lt;/code&gt; is essentially a collection of none or one instances of a type.  If everything returned an &lt;code&gt;Option&lt;/code&gt; nothing would be null and you don&amp;#39;t need to do any null checks (they are much more powerful than I am making out but for now this is all that is necessary).&lt;/p&gt;

&lt;p&gt;Kotlin doesn&amp;#39;t have the &lt;code&gt;Option&lt;/code&gt; type but it does have two things that allow you to act like it does,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Nullable types - e.g. &lt;code&gt;String&lt;/code&gt; vs &lt;code&gt;String?&lt;/code&gt; , and,&lt;/li&gt;
&lt;li&gt;Nullable Extension Functions&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember the brief definition of an &lt;code&gt;Option&lt;/code&gt; - it&amp;#39;s a list of 0 or 1 instances of a particualr type and as such we can treat it a bit like a list.  Now once we get functional with our badselves this makes null handling unnecessary.  We can use all those nice little functional methods that you get with collections - map, forEach, filter, fold etc.&lt;/p&gt;

&lt;p&gt;This means you&amp;#39;re less inclined to use &lt;code&gt;if&lt;/code&gt;s and, more importantly, less inclined to use mutable variables which is great for building performant, scalable soltions.&lt;/p&gt;

&lt;p&gt;Lets take a really contrived example to show you what I mean.  OImagine this bit of code&amp;hellip;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;   &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;authenticate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;

   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Invalid Username or Password&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We want to authenticate a user and return a certain view.  Now yes we could refactor this down into something more bitsize but this is a very common state to find code - so bare with me for demonstration purposes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;authenticate&lt;/code&gt; returns a user if the username and password was correct otherwise it returns null.  With our nullable extensions (by importing &lt;code&gt;kotlin.nullable.*&lt;/code&gt;) we can reduce this into something more Scala-like,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;authenticate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Invalid Username or Password&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So what we have done here is basically take an object (the user), if it exists, and transform it to another object which we return.  Otherwise we return something different.  This is much simpler and avoids having to create a mutable var (yes we could have avoided that in the other example but in many cases its very difficult to achieve this).  In fact I am not even a fan of the elvis operator there (&lt;code&gt;?:&lt;/code&gt;) and have a Scala-like syntax &lt;a href="https://github.com/JetBrains/kotlin/pull/100"&gt;pull request&lt;/a&gt; open for getOrElse.  A small syntactic change that I think allows you create a much neater, chainable block of code.&lt;/p&gt;

&lt;p&gt;Thats only the tip of the iceberg on Nullable Extensions - those of you with a functional mind will be able to put these collection-like extensions to great use I reckon.  Not quite Scalas &lt;code&gt;Option&lt;/code&gt; type but good enough at providing the common features for me.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Haskell doesn&amp;#39;t have if statements - that blew my mind the first time my old Scala mentor told me it.  &lt;code&gt;if&lt;/code&gt;s just don&amp;#39;t work with a strong function approach.  Plus you know what - &lt;code&gt;if&lt;/code&gt;s are rather ugly especially when you need to wrap ALL THE THINGS in a null check.  Scala has a type called &lt;code&gt;Option&lt;/code&gt;.  An &lt;code&gt;Option&lt;/code&gt; is essentially a collection of none or one instances of a type.  If everything returned an &lt;code&gt;Option&lt;/code&gt; nothing would be null and you don&amp;#39;t need to do any null checks (they are much more powerful than I am making out but for now this is all that is necessary).&lt;/p&gt;

&lt;p&gt;Kotlin doesn&amp;#39;t have the &lt;code&gt;Option&lt;/code&gt; type but it does have two things that allow you to act like it does,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Nullable types - e.g. &lt;code&gt;String&lt;/code&gt; vs &lt;code&gt;String?&lt;/code&gt; , and,&lt;/li&gt;
&lt;li&gt;Nullable Extension Functions&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember the brief definition of an &lt;code&gt;Option&lt;/code&gt; - it&amp;#39;s a list of 0 or 1 instances of a particualr type and as such we can treat it a bit like a list.  Now once we get functional with our badselves this makes null handling unnecessary.  We can use all those nice little functional methods that you get with collections - map, forEach, filter, fold etc.&lt;/p&gt;

&lt;p&gt;This means you&amp;#39;re less inclined to use &lt;code&gt;if&lt;/code&gt;s and, more importantly, less inclined to use mutable variables which is great for building performant, scalable soltions.&lt;/p&gt;

&lt;p&gt;Lets take a really contrived example to show you what I mean.  OImagine this bit of code&amp;hellip;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;   &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;authenticate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;

   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Invalid Username or Password&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We want to authenticate a user and return a certain view.  Now yes we could refactor this down into something more bitsize but this is a very common state to find code - so bare with me for demonstration purposes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;authenticate&lt;/code&gt; returns a user if the username and password was correct otherwise it returns null.  With our nullable extensions (by importing &lt;code&gt;kotlin.nullable.*&lt;/code&gt;) we can reduce this into something more Scala-like,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;authenticate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Invalid Username or Password&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So what we have done here is basically take an object (the user), if it exists, and transform it to another object which we return.  Otherwise we return something different.  This is much simpler and avoids having to create a mutable var (yes we could have avoided that in the other example but in many cases its very difficult to achieve this).  In fact I am not even a fan of the elvis operator there (&lt;code&gt;?:&lt;/code&gt;) and have a Scala-like syntax &lt;a href="https://github.com/JetBrains/kotlin/pull/100"&gt;pull request&lt;/a&gt; open for getOrElse.  A small syntactic change that I think allows you create a much neater, chainable block of code.&lt;/p&gt;

&lt;p&gt;Thats only the tip of the iceberg on Nullable Extensions - those of you with a functional mind will be able to put these collection-like extensions to great use I reckon.  Not quite Scalas &lt;code&gt;Option&lt;/code&gt; type but good enough at providing the common features for me.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Kotlin: Extension Functions</title>
    <link rel="alternate" href="/blog/2012/07/16/kotlin-extension-functions"/>
    <id>/blog/2012/07/16/kotlin-extension-functions</id>
    <published>2012-07-16T00:00:00+01:00</published>
    <updated>2012-07-16T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;In any language (that supports the concept) extension functions are nothing more than syntactic sugar.  Instead of writing,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Extension functions allow you to write,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once you start moving into the world of chaining things get much cleaner.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;encrypted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;encoded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encrypted&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or worse,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I&amp;#39;ve seen this done a few times, it happens.  But with sugary sweet extension functions (Extension Methods in C#, Implicit Conversions in Scala) you could just do this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Much nicer.&lt;/p&gt;

&lt;p&gt;Kotlin, unlike crusty old Java, supports extension functions.  Here is how you&amp;#39;d implement the methods above&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;StringBuffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ByteArray&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And we can use these, as you&amp;#39;d expect, like so,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;fun&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;mystring&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;james&amp;quot;&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;encoded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mystring.encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So what identified those functions as Extension Functions?  Simple - the prefixing of the method name with the type &lt;code&gt;String.encode&lt;/code&gt;.  No need to create implicit wrappers (Scala), no need to create loads of static classes (C#).  And yes it&amp;#39;s possible to use generics in these methods as well,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;fun&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;T&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getOrElse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;T&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;this&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;t&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This can be applied to any nullable type.&lt;/p&gt;

&lt;h2&gt;Literal Extension Functions&lt;/h2&gt;

&lt;p&gt;An interesting little feature that Kotlin has that makes it a bit different is the use of function literal extension functions.  Basically where you can declare a function as a literal (a lambda method if you will) you can also make that literal an extension function,&lt;/p&gt;

&lt;p&gt;So we could take our methods we wrote above and bring them right into our &lt;code&gt;main&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;fun&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;encrypt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="nx"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;StringBuffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;this&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;encode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="nx"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;this.getBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;mystring&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;james&amp;quot;&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;encoded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mystring.encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This may seem quite unnecessary at first glance but it become quite powerful when creating DSLs - as demonstrated in the docs around the &lt;a href="http://confluence.jetbrains.net/display/Kotlin/Type-safe+Groovy-style+builders"&gt;Groovy Style Builders&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So Kotlin has extension functions that don&amp;#39;t require a load of boilerplate (C#) or rather odd implicit syntax (Scala) - cool, right?&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;In any language (that supports the concept) extension functions are nothing more than syntactic sugar.  Instead of writing,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Extension functions allow you to write,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once you start moving into the world of chaining things get much cleaner.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;encrypted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;encoded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encrypted&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;or worse,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;StringUtils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I&amp;#39;ve seen this done a few times, it happens.  But with sugary sweet extension functions (Extension Methods in C#, Implicit Conversions in Scala) you could just do this,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;mystring&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Much nicer.&lt;/p&gt;

&lt;p&gt;Kotlin, unlike crusty old Java, supports extension functions.  Here is how you&amp;#39;d implement the methods above&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;StringBuffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;fun&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ByteArray&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And we can use these, as you&amp;#39;d expect, like so,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;fun&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;mystring&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;james&amp;quot;&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;encoded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mystring.encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So what identified those functions as Extension Functions?  Simple - the prefixing of the method name with the type &lt;code&gt;String.encode&lt;/code&gt;.  No need to create implicit wrappers (Scala), no need to create loads of static classes (C#).  And yes it&amp;#39;s possible to use generics in these methods as well,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;fun&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;T&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getOrElse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;T&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;T&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;this&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;t&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This can be applied to any nullable type.&lt;/p&gt;

&lt;h2&gt;Literal Extension Functions&lt;/h2&gt;

&lt;p&gt;An interesting little feature that Kotlin has that makes it a bit different is the use of function literal extension functions.  Basically where you can declare a function as a literal (a lambda method if you will) you can also make that literal an extension function,&lt;/p&gt;

&lt;p&gt;So we could take our methods we wrote above and bring them right into our &lt;code&gt;main&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;fun&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;encrypt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="nx"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;StringBuffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;this&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;encode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="nx"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;this.getBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;mystring&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;james&amp;quot;&lt;/span&gt;
    &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="n"&gt;encoded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mystring.encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;salt&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This may seem quite unnecessary at first glance but it become quite powerful when creating DSLs - as demonstrated in the docs around the &lt;a href="http://confluence.jetbrains.net/display/Kotlin/Type-safe+Groovy-style+builders"&gt;Groovy Style Builders&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So Kotlin has extension functions that don&amp;#39;t require a load of boilerplate (C#) or rather odd implicit syntax (Scala) - cool, right?&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Kotlin: Here's What I Think (For Now)</title>
    <link rel="alternate" href="/blog/2012/07/15/kotlin-heres-what-i-think-for-now"/>
    <id>/blog/2012/07/15/kotlin-heres-what-i-think-for-now</id>
    <published>2012-07-15T00:00:00+01:00</published>
    <updated>2012-07-15T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;Before I go shooting my mouth off here - a word of warning - I haven&amp;#39;t really done anything with Kotlin.  I&amp;#39;ve read the docs, played with the &lt;a href="https://github.com/dodyg/Kotlin101"&gt;Kotlin 101 samples&lt;/a&gt; and written a few small console type apps.  So take what you want from this post.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Want to hear something zany?  There actually are people - real living people, with a fully working brain, many much smarter than me - that are &amp;ldquo;happy&amp;rdquo; with Java.  &lt;/p&gt;

&lt;p&gt;Seriously.&lt;/p&gt;

&lt;p&gt;I made a move from Java to .NET about 5 years ago and have dipped back in a few times over that period.  Trying new languages is a sure fire way, for some at least, to make you realise Java is not a language that makes coding fun, or productive.  Java put me right of the JVM.  Any language that makes woking with collections (something you&amp;#39;ll do alot) so long winded and noisy deserves to be shunned.  But this isn&amp;#39;t a Java rant - the JVM is great but it&amp;#39;s just marketed badly because of Java.&lt;/p&gt;

&lt;p&gt;But all the JVM-hate that Java instilled in me 5 years ago; the last 6 months of working with Scala has replaced with love.  So I&amp;#39;ve been looking around the JVM world and discovered &lt;a href="http://kotlin.jetbrains.org/"&gt;Kotlin&lt;/a&gt; a new JVM based language from JetBrains.  Its much closer to Java than what Scala or Clojure is (intentionally).&lt;/p&gt;

&lt;p&gt;One main thing that Kotlin brings to the table is pragmatism.  Without trying to belittle Kotlin - it&amp;#39;s almost like CoffeeScript for Java (yep kind of like what &lt;a href="http://www.eclipse.org/xtend/"&gt;Xtend&lt;/a&gt; is.  Kotlin removes all those annoying necessities in Java that make your code verbose (checked exceptions, semi-colons, null reference checks etc.).  It also adds things that make your life much easier (extension methods, functional collection manipulation etc.).  &lt;/p&gt;

&lt;p&gt;When you write Ruby for the first time you notice that many things just work out like you&amp;#39;d expect, the syntax is quite natural.  The same cannot be said for Java - there is just way too much boilerplate.  Kotlin helps reduce that boilerplate.  So, by extension, it could be said that Kotlin makes you more productive.  A person who knows Java will find Kotlin no challenge to start using - the syntax is nicely aligned, just without the noise.&lt;/p&gt;

&lt;p&gt;Many people, when trying to get their team to adopt Scala, use the &amp;ldquo;you can use Scala like Java til you get used to it&amp;rdquo; mantra.  I don&amp;#39;t agree with that.  Academically it&amp;#39;s true but the minute you start working with other peoples Scala code - you&amp;#39;ve just gotta know Scala and when they have a slew of Implicits thrown in your Scala as Java stuff goes out the window.  Kotlin, on the other hand, has some of the nice functional patterns from Scala but none of the &amp;ldquo;magic-to-a-newcomer&amp;rdquo; features that can make grown men weep.  Now the Kotlin docs themselves even go as far as stating &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you are happy with Scala, you probably don&amp;#39;t need Kotlin.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But I think they are selling themselves short - I think plenty of people use Scala but could easily use Kotlin in its place and find themselves in a better place (easier upskilling, less cryptic codebase).&lt;/p&gt;

&lt;p&gt;Anyway this is a bit of a ramble, what I&amp;#39;m saying is - Kotlin has some really rather nice features (Groovy Like DSL Builders, Pattern Matching, the &lt;code&gt;when&lt;/code&gt; expression, lambdas, Kotlin to JavaScript compilation(!) etc.) and people happy with either Java OR Scala should give it a go.&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;Before I go shooting my mouth off here - a word of warning - I haven&amp;#39;t really done anything with Kotlin.  I&amp;#39;ve read the docs, played with the &lt;a href="https://github.com/dodyg/Kotlin101"&gt;Kotlin 101 samples&lt;/a&gt; and written a few small console type apps.  So take what you want from this post.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Want to hear something zany?  There actually are people - real living people, with a fully working brain, many much smarter than me - that are &amp;ldquo;happy&amp;rdquo; with Java.  &lt;/p&gt;

&lt;p&gt;Seriously.&lt;/p&gt;

&lt;p&gt;I made a move from Java to .NET about 5 years ago and have dipped back in a few times over that period.  Trying new languages is a sure fire way, for some at least, to make you realise Java is not a language that makes coding fun, or productive.  Java put me right of the JVM.  Any language that makes woking with collections (something you&amp;#39;ll do alot) so long winded and noisy deserves to be shunned.  But this isn&amp;#39;t a Java rant - the JVM is great but it&amp;#39;s just marketed badly because of Java.&lt;/p&gt;

&lt;p&gt;But all the JVM-hate that Java instilled in me 5 years ago; the last 6 months of working with Scala has replaced with love.  So I&amp;#39;ve been looking around the JVM world and discovered &lt;a href="http://kotlin.jetbrains.org/"&gt;Kotlin&lt;/a&gt; a new JVM based language from JetBrains.  Its much closer to Java than what Scala or Clojure is (intentionally).&lt;/p&gt;

&lt;p&gt;One main thing that Kotlin brings to the table is pragmatism.  Without trying to belittle Kotlin - it&amp;#39;s almost like CoffeeScript for Java (yep kind of like what &lt;a href="http://www.eclipse.org/xtend/"&gt;Xtend&lt;/a&gt; is.  Kotlin removes all those annoying necessities in Java that make your code verbose (checked exceptions, semi-colons, null reference checks etc.).  It also adds things that make your life much easier (extension methods, functional collection manipulation etc.).  &lt;/p&gt;

&lt;p&gt;When you write Ruby for the first time you notice that many things just work out like you&amp;#39;d expect, the syntax is quite natural.  The same cannot be said for Java - there is just way too much boilerplate.  Kotlin helps reduce that boilerplate.  So, by extension, it could be said that Kotlin makes you more productive.  A person who knows Java will find Kotlin no challenge to start using - the syntax is nicely aligned, just without the noise.&lt;/p&gt;

&lt;p&gt;Many people, when trying to get their team to adopt Scala, use the &amp;ldquo;you can use Scala like Java til you get used to it&amp;rdquo; mantra.  I don&amp;#39;t agree with that.  Academically it&amp;#39;s true but the minute you start working with other peoples Scala code - you&amp;#39;ve just gotta know Scala and when they have a slew of Implicits thrown in your Scala as Java stuff goes out the window.  Kotlin, on the other hand, has some of the nice functional patterns from Scala but none of the &amp;ldquo;magic-to-a-newcomer&amp;rdquo; features that can make grown men weep.  Now the Kotlin docs themselves even go as far as stating &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you are happy with Scala, you probably don&amp;#39;t need Kotlin.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But I think they are selling themselves short - I think plenty of people use Scala but could easily use Kotlin in its place and find themselves in a better place (easier upskilling, less cryptic codebase).&lt;/p&gt;

&lt;p&gt;Anyway this is a bit of a ramble, what I&amp;#39;m saying is - Kotlin has some really rather nice features (Groovy Like DSL Builders, Pattern Matching, the &lt;code&gt;when&lt;/code&gt; expression, lambdas, Kotlin to JavaScript compilation(!) etc.) and people happy with either Java OR Scala should give it a go.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Azure Website Workflow for Bosses</title>
    <link rel="alternate" href="/blog/2012/07/12/azure-website-workflow-for-bosses"/>
    <id>/blog/2012/07/12/azure-website-workflow-for-bosses</id>
    <published>2012-07-12T00:00:00+01:00</published>
    <updated>2012-07-12T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;So consider my indefinite hiatus suspended definitely.  I suck at quitting!  But we wont dive into the whys and wherefores  around that now.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I&amp;#39;ve a confession to make, the &amp;ldquo;new&amp;rdquo; Azure, I like it.  Yeah I do, s&amp;#39;nice.  I like the way it blends PaaS with IaaS (though I do feel that adding 1st class node.js and PHP support is a bit of a tacked on marketing ploy).  So you dont have the &amp;ldquo;Add-On&amp;rdquo; model you get from Appharbor and Heroku but thats fine because this blending of &amp;ldquo;as a Services&amp;rdquo; gives you an alternate approach.  For a start you can just use the external services without them having to be &amp;ldquo;Add-Ons&amp;rdquo;.  Sure you lose out on the nice automatic integration points for managing your services but it&amp;#39;s not the end of the world and what happens when you want something that isn&amp;#39;t available as an Add-On or worse not available as a cloudy SaaS thing?  Well I guess you need to go off to EC2 or similar and host your own (assuming you want to stick with the cloudy infrastructure).  But with Azure you also get another option - you want to use Mongo or some huge enterprisey platform that isn&amp;#39;t SaaSified?  Stick it on an Azure VM.  Everything managed under one cloud provider.  Thats such a nice thing to have at your disposal.&lt;/p&gt;

&lt;p&gt;But thats not the point of this post.  Most posts out there cover a workflow for Azure WebSites that make use of the portal to provision new sites (and then usually &lt;code&gt;git&lt;/code&gt; to deploy) but that&amp;#39;s weak sauce (the portal part at least - gits still aces).  No, no no - You want hyper-productivity, you want automated provisioning,  you want to be hip; node.js hip; and you want to feel like a boss hanging out on your command line while other &amp;ldquo;lesser people&amp;rdquo; click stuff with a silly little rodent.  I just read your mind, didn&amp;#39;t I?  Well then - you got that with Azure.&lt;/p&gt;

&lt;h2&gt;Setting Up&lt;/h2&gt;

&lt;p&gt;First things first you need to install a few things.&lt;/p&gt;

&lt;h3&gt;Installing node.js + NPM&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://nodejs.org/#download"&gt;Download&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The tools are built and deployed in node via NPM, the node package manager so just run the one click installer and you&amp;#39;ll be all setup.&lt;/p&gt;

&lt;h3&gt;Installing Azure CLI Tools&lt;/h3&gt;

&lt;p&gt;Install these via NPM so fire up your terminal/command prompt/whatever and type&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;npm&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then let NPM install all the dependencies and what not (the &lt;code&gt;-g&lt;/code&gt; option just tells NPM to install the tools globally so they are accessible from the command line)&lt;/p&gt;

&lt;h3&gt;Adding your account&lt;/h3&gt;

&lt;p&gt;Next up you need to tell azure what account to use so fire this command into you command line&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="n"&gt;download&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You&amp;#39;ll then be taken to the Azure website and it should (assuming you&amp;#39;re logged in already) download a &lt;code&gt;publishsettings&lt;/code&gt; file.  Next up you need to import this file into your azure toolchain.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;YOUR_DOWNLOADED_FILE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;publishsettings&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After some scrolling text you&amp;#39;ll be all set up and ready to deploy.  You&amp;#39;ll be asked to delete the file you downloaded - probably best to do this :)&lt;/p&gt;

&lt;h2&gt;Creating the app&lt;/h2&gt;

&lt;p&gt;OK then lets create an app - what we create is irrelevant here so lets just create the default ASP.NET MVC website and use that as our sample app.  Remeber though, if you&amp;#39;re a cutting edge awesome-addict to switch from .NET 4.5 to 4 or else you&amp;#39;ll get some issues when deploying your site to Azure.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt; : The next few steps can be condensed, thanks to the feedback from Glenn Block (@gblock),
&lt;blockquote class="twitter-tweet" data-in-reply-to="224800579388575744"&gt;&lt;p&gt;@&lt;a href="https://twitter.com/kouphax"&gt;kouphax&lt;/a&gt; oh dude, you don&amp;#39;t need all those steps! Do &amp;ldquo;azure site create my site &amp;ndash;git&amp;rdquo; It will create the repo for you and add the remote!&lt;/p&gt;&amp;mdash; Glenn Block (@gblock) &lt;a href="https://twitter.com/gblock/status/224855192800215040" data-datetime="2012-07-16T13:17:10+00:00"&gt;July 16, 2012&lt;/a&gt;&lt;/blockquote&gt;
&lt;script src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;
This sets up your git repo during creation of the site, adds the remote endpoint and even generates a .gitignore file (which you need to edit yourelf for .NET projects.  WIN!!!!&lt;/p&gt;

&lt;p&gt;Anyway&amp;hellip;. on with the old post.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you&amp;#39;ve created you app and saved it then you&amp;#39;ll want to intialise an empty repo at the root of the solution,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we need to create a site on Azure we can push to.&lt;/p&gt;

&lt;h2&gt;Creating a new site&lt;/h2&gt;

&lt;p&gt;Back to the command line now,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;SITE_NAME&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If we execute this, again at the root of our solution, it will do a number of things,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Validate the request (site name availability and what not)&lt;/li&gt;
&lt;li&gt;Create a new site on Azure&lt;/li&gt;
&lt;li&gt;Add a new git &lt;code&gt;remote&lt;/code&gt; to your &lt;code&gt;.git\config&lt;/code&gt; file&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;Pushing site&lt;/h2&gt;

&lt;p&gt;As I&amp;#39;ve said the last command actually added a remote repo to our git configuration so if we do the usual gitty stuff (you&amp;#39;ll want to, for neatness sake, set up your &lt;code&gt;.gitignore&lt;/code&gt; but we can skip this for brevity),&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Boring commit message&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now we push,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;push&lt;/span&gt; &lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;master&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Done!&lt;/p&gt;

&lt;h2&gt;Viewing your site&lt;/h2&gt;

&lt;p&gt;You could just browse to your new site but thats just not hip enough, hell no.  Instead lets launch it from the command line&amp;hellip;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt; &lt;span class="n"&gt;browse&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That will launch our new site without having to touch a silly old, out of date rodent.&lt;/p&gt;

&lt;h2&gt;Wrapping up&lt;/h2&gt;

&lt;p&gt;Ok so thats the basic workflow for using CLI tools to manage Azure sites.  You can do this with most of the Azure services (VMs, Certs, Cloud Services etc.) aswell.&lt;/p&gt;

&lt;p&gt;So apart from making you look all hackery working in the terminal it does have other uses, specifically around the fact terminal command can be easily executed in a headless automated environment.  Think of creating new sites as part of your CI&amp;#39;s deployment pipeline, or as part of some disaster recovery process.  The possibilities are endless&amp;hellip; heck even write your own UI for managing sites or deploying new sites/VM/whatever!&lt;/p&gt;

&lt;p&gt;So lets see - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CLI hackery coolness&amp;hellip; ✓&lt;/li&gt;
&lt;li&gt;Node.js hipster bragging rights&amp;hellip; ✓&lt;/li&gt;
&lt;li&gt;Azure website created and deployed with about 6 commands&amp;hellip; ✓&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not bad for a few minutes work!&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;So consider my indefinite hiatus suspended definitely.  I suck at quitting!  But we wont dive into the whys and wherefores  around that now.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I&amp;#39;ve a confession to make, the &amp;ldquo;new&amp;rdquo; Azure, I like it.  Yeah I do, s&amp;#39;nice.  I like the way it blends PaaS with IaaS (though I do feel that adding 1st class node.js and PHP support is a bit of a tacked on marketing ploy).  So you dont have the &amp;ldquo;Add-On&amp;rdquo; model you get from Appharbor and Heroku but thats fine because this blending of &amp;ldquo;as a Services&amp;rdquo; gives you an alternate approach.  For a start you can just use the external services without them having to be &amp;ldquo;Add-Ons&amp;rdquo;.  Sure you lose out on the nice automatic integration points for managing your services but it&amp;#39;s not the end of the world and what happens when you want something that isn&amp;#39;t available as an Add-On or worse not available as a cloudy SaaS thing?  Well I guess you need to go off to EC2 or similar and host your own (assuming you want to stick with the cloudy infrastructure).  But with Azure you also get another option - you want to use Mongo or some huge enterprisey platform that isn&amp;#39;t SaaSified?  Stick it on an Azure VM.  Everything managed under one cloud provider.  Thats such a nice thing to have at your disposal.&lt;/p&gt;

&lt;p&gt;But thats not the point of this post.  Most posts out there cover a workflow for Azure WebSites that make use of the portal to provision new sites (and then usually &lt;code&gt;git&lt;/code&gt; to deploy) but that&amp;#39;s weak sauce (the portal part at least - gits still aces).  No, no no - You want hyper-productivity, you want automated provisioning,  you want to be hip; node.js hip; and you want to feel like a boss hanging out on your command line while other &amp;ldquo;lesser people&amp;rdquo; click stuff with a silly little rodent.  I just read your mind, didn&amp;#39;t I?  Well then - you got that with Azure.&lt;/p&gt;

&lt;h2&gt;Setting Up&lt;/h2&gt;

&lt;p&gt;First things first you need to install a few things.&lt;/p&gt;

&lt;h3&gt;Installing node.js + NPM&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://nodejs.org/#download"&gt;Download&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The tools are built and deployed in node via NPM, the node package manager so just run the one click installer and you&amp;#39;ll be all setup.&lt;/p&gt;

&lt;h3&gt;Installing Azure CLI Tools&lt;/h3&gt;

&lt;p&gt;Install these via NPM so fire up your terminal/command prompt/whatever and type&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;npm&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then let NPM install all the dependencies and what not (the &lt;code&gt;-g&lt;/code&gt; option just tells NPM to install the tools globally so they are accessible from the command line)&lt;/p&gt;

&lt;h3&gt;Adding your account&lt;/h3&gt;

&lt;p&gt;Next up you need to tell azure what account to use so fire this command into you command line&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="n"&gt;download&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You&amp;#39;ll then be taken to the Azure website and it should (assuming you&amp;#39;re logged in already) download a &lt;code&gt;publishsettings&lt;/code&gt; file.  Next up you need to import this file into your azure toolchain.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;YOUR_DOWNLOADED_FILE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;publishsettings&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After some scrolling text you&amp;#39;ll be all set up and ready to deploy.  You&amp;#39;ll be asked to delete the file you downloaded - probably best to do this :)&lt;/p&gt;

&lt;h2&gt;Creating the app&lt;/h2&gt;

&lt;p&gt;OK then lets create an app - what we create is irrelevant here so lets just create the default ASP.NET MVC website and use that as our sample app.  Remeber though, if you&amp;#39;re a cutting edge awesome-addict to switch from .NET 4.5 to 4 or else you&amp;#39;ll get some issues when deploying your site to Azure.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt; : The next few steps can be condensed, thanks to the feedback from Glenn Block (@gblock),
&lt;blockquote class="twitter-tweet" data-in-reply-to="224800579388575744"&gt;&lt;p&gt;@&lt;a href="https://twitter.com/kouphax"&gt;kouphax&lt;/a&gt; oh dude, you don&amp;#39;t need all those steps! Do &amp;ldquo;azure site create my site &amp;ndash;git&amp;rdquo; It will create the repo for you and add the remote!&lt;/p&gt;&amp;mdash; Glenn Block (@gblock) &lt;a href="https://twitter.com/gblock/status/224855192800215040" data-datetime="2012-07-16T13:17:10+00:00"&gt;July 16, 2012&lt;/a&gt;&lt;/blockquote&gt;
&lt;script src="//platform.twitter.com/widgets.js" charset="utf-8"&gt;&lt;/script&gt;
This sets up your git repo during creation of the site, adds the remote endpoint and even generates a .gitignore file (which you need to edit yourelf for .NET projects.  WIN!!!!&lt;/p&gt;

&lt;p&gt;Anyway&amp;hellip;. on with the old post.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you&amp;#39;ve created you app and saved it then you&amp;#39;ll want to intialise an empty repo at the root of the solution,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we need to create a site on Azure we can push to.&lt;/p&gt;

&lt;h2&gt;Creating a new site&lt;/h2&gt;

&lt;p&gt;Back to the command line now,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt; &lt;span class="n"&gt;SITE_NAME&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If we execute this, again at the root of our solution, it will do a number of things,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Validate the request (site name availability and what not)&lt;/li&gt;
&lt;li&gt;Create a new site on Azure&lt;/li&gt;
&lt;li&gt;Add a new git &lt;code&gt;remote&lt;/code&gt; to your &lt;code&gt;.git\config&lt;/code&gt; file&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;Pushing site&lt;/h2&gt;

&lt;p&gt;As I&amp;#39;ve said the last command actually added a remote repo to our git configuration so if we do the usual gitty stuff (you&amp;#39;ll want to, for neatness sake, set up your &lt;code&gt;.gitignore&lt;/code&gt; but we can skip this for brevity),&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;
&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Boring commit message&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now we push,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;push&lt;/span&gt; &lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;master&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Done!&lt;/p&gt;

&lt;h2&gt;Viewing your site&lt;/h2&gt;

&lt;p&gt;You could just browse to your new site but thats just not hip enough, hell no.  Instead lets launch it from the command line&amp;hellip;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;azure&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt; &lt;span class="n"&gt;browse&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That will launch our new site without having to touch a silly old, out of date rodent.&lt;/p&gt;

&lt;h2&gt;Wrapping up&lt;/h2&gt;

&lt;p&gt;Ok so thats the basic workflow for using CLI tools to manage Azure sites.  You can do this with most of the Azure services (VMs, Certs, Cloud Services etc.) aswell.&lt;/p&gt;

&lt;p&gt;So apart from making you look all hackery working in the terminal it does have other uses, specifically around the fact terminal command can be easily executed in a headless automated environment.  Think of creating new sites as part of your CI&amp;#39;s deployment pipeline, or as part of some disaster recovery process.  The possibilities are endless&amp;hellip; heck even write your own UI for managing sites or deploying new sites/VM/whatever!&lt;/p&gt;

&lt;p&gt;So lets see - &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CLI hackery coolness&amp;hellip; ✓&lt;/li&gt;
&lt;li&gt;Node.js hipster bragging rights&amp;hellip; ✓&lt;/li&gt;
&lt;li&gt;Azure website created and deployed with about 6 commands&amp;hellip; ✓&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not bad for a few minutes work!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Technology in the Cloud</title>
    <link rel="alternate" href="/blog/2012/07/12/technology-in-the-cloud"/>
    <id>/blog/2012/07/12/technology-in-the-cloud</id>
    <published>2012-07-12T00:00:00+01:00</published>
    <updated>2012-07-12T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;The Cloud.  As much as the term has been pummelled into meaningless marketing sputum by the guys in expensive suits and fake smiles it does exist and is distinct from a typical &amp;ldquo;throw all your stuff in a data center&amp;rdquo; setup.&lt;/p&gt;

&lt;p&gt;The Cloud is distinct, as well, in terms of how you think about your solution architecture.  The typical old school approach would be to just create big monoliths to process your data but that doesn&amp;#39;t work out so well in the cloud.  Of course the considerations for the cloud aren&amp;#39;t new, hell no - things like SOA have been around for an age, but if you want to harness the benefits of the cloud as the internet intended you will be narrowing your options.  No more just cobbling common bits together and crossing your fingers.  &lt;/p&gt;

&lt;p&gt;So fine - architecting for the cloud has some special considerations but thats not what I want to talk about - there are better people than me to cover that.&lt;/p&gt;

&lt;p&gt;What I want to talk about is use of technology within that architecture.  I&amp;#39;ve never been a fan of the one-size-fits-all-painful-or-not technology stack driven almost solely by a need to avoid unnecessary education of developers.  And, now I feel the cloud is strengthening my view that a default stack is more trouble than it&amp;#39;s worth.  More importantly it&amp;#39;s really adding momentum to the whole polyglot architecture, or simply using the right tools for the job.&lt;/p&gt;

&lt;p&gt;Let me explain.  Any default stack, by definition, needs to cater to many user cases and as such brings a certain amount of sacrifice with it.  Sacrifices come in many forms but usually in performance, memory footprint and/or verbose configuration.  In the cloud you are, in essence, in a Pay-As-You-Go model, every clock cycle and every bit of storage costs.  Now that heavy ORM with its less than ideal queries and slow relationship mapping is starting to cost you money EVERY request.  In fact, it&amp;#39;s probably backed by that storage heavy relational database for all your non-relational data.  Same for that rather large web framework you&amp;#39;ve got there&amp;hellip;. every time to deal with a spike and scale that badboy out and you&amp;#39;re having to use medium instances rather than small.  That SOAP based webservice that requires triple the bandwidth to service a request&amp;hellip; ugh you get the point.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the cloud the default stack can easily bleed money.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I guess this is less about the default stack and more about just using the right tools to get the job done in the most effective manner - afterall you&amp;#39;re paying for this stuff now.  You kind of were before but in such a coarse grained manner it didn&amp;#39;t matter - it does now.&lt;/p&gt;

&lt;p&gt;In summary - the cloud has started to make technology decisions more accountable and we need to ensure that those decisions aren&amp;#39;t costing our stakeholders more money than necessary.&lt;/p&gt;

&lt;p&gt;PS.&lt;/p&gt;

&lt;p&gt;I&amp;#39;m not going to sit here and preach about the which specific technologies to use but come on - if your storing Session State in a Oracle database, switch to Riak, or Redis.  If you&amp;#39;re building a nice scalable API then use something like Scala which promotes immutable state and concurrency out of the box over something like vanilla Java (or perhaps just a better framework Spring-WS vs Dropwizard for example).  JSON over XML or a binary format (Protobuf for example) for machine to machine communication.  A small node.js web site over ASP.NET Webforms for simple sites.  The list goes on.  That is to say consider this advice against the other factors driving technical decisions - dont JUST go for the smallest, lightest tools because it MIGHT be cheaper.  Do the research.&lt;/p&gt;

&lt;p&gt;Finally, perhaps you&amp;#39;ve got another IT team needing to support this new solution?  Bring them along this journey too, educate them as you educate yourself, dont just throw the finished thing over the wall with a 1 week handover and a pat on the back.&lt;/p&gt;

&lt;p&gt;Don&amp;#39;t be afraid - it&amp;#39;s a super fun world we live in!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;The Cloud.  As much as the term has been pummelled into meaningless marketing sputum by the guys in expensive suits and fake smiles it does exist and is distinct from a typical &amp;ldquo;throw all your stuff in a data center&amp;rdquo; setup.&lt;/p&gt;

&lt;p&gt;The Cloud is distinct, as well, in terms of how you think about your solution architecture.  The typical old school approach would be to just create big monoliths to process your data but that doesn&amp;#39;t work out so well in the cloud.  Of course the considerations for the cloud aren&amp;#39;t new, hell no - things like SOA have been around for an age, but if you want to harness the benefits of the cloud as the internet intended you will be narrowing your options.  No more just cobbling common bits together and crossing your fingers.  &lt;/p&gt;

&lt;p&gt;So fine - architecting for the cloud has some special considerations but thats not what I want to talk about - there are better people than me to cover that.&lt;/p&gt;

&lt;p&gt;What I want to talk about is use of technology within that architecture.  I&amp;#39;ve never been a fan of the one-size-fits-all-painful-or-not technology stack driven almost solely by a need to avoid unnecessary education of developers.  And, now I feel the cloud is strengthening my view that a default stack is more trouble than it&amp;#39;s worth.  More importantly it&amp;#39;s really adding momentum to the whole polyglot architecture, or simply using the right tools for the job.&lt;/p&gt;

&lt;p&gt;Let me explain.  Any default stack, by definition, needs to cater to many user cases and as such brings a certain amount of sacrifice with it.  Sacrifices come in many forms but usually in performance, memory footprint and/or verbose configuration.  In the cloud you are, in essence, in a Pay-As-You-Go model, every clock cycle and every bit of storage costs.  Now that heavy ORM with its less than ideal queries and slow relationship mapping is starting to cost you money EVERY request.  In fact, it&amp;#39;s probably backed by that storage heavy relational database for all your non-relational data.  Same for that rather large web framework you&amp;#39;ve got there&amp;hellip;. every time to deal with a spike and scale that badboy out and you&amp;#39;re having to use medium instances rather than small.  That SOAP based webservice that requires triple the bandwidth to service a request&amp;hellip; ugh you get the point.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the cloud the default stack can easily bleed money.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I guess this is less about the default stack and more about just using the right tools to get the job done in the most effective manner - afterall you&amp;#39;re paying for this stuff now.  You kind of were before but in such a coarse grained manner it didn&amp;#39;t matter - it does now.&lt;/p&gt;

&lt;p&gt;In summary - the cloud has started to make technology decisions more accountable and we need to ensure that those decisions aren&amp;#39;t costing our stakeholders more money than necessary.&lt;/p&gt;

&lt;p&gt;PS.&lt;/p&gt;

&lt;p&gt;I&amp;#39;m not going to sit here and preach about the which specific technologies to use but come on - if your storing Session State in a Oracle database, switch to Riak, or Redis.  If you&amp;#39;re building a nice scalable API then use something like Scala which promotes immutable state and concurrency out of the box over something like vanilla Java (or perhaps just a better framework Spring-WS vs Dropwizard for example).  JSON over XML or a binary format (Protobuf for example) for machine to machine communication.  A small node.js web site over ASP.NET Webforms for simple sites.  The list goes on.  That is to say consider this advice against the other factors driving technical decisions - dont JUST go for the smallest, lightest tools because it MIGHT be cheaper.  Do the research.&lt;/p&gt;

&lt;p&gt;Finally, perhaps you&amp;#39;ve got another IT team needing to support this new solution?  Bring them along this journey too, educate them as you educate yourself, dont just throw the finished thing over the wall with a 1 week handover and a pat on the back.&lt;/p&gt;

&lt;p&gt;Don&amp;#39;t be afraid - it&amp;#39;s a super fun world we live in!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Quitsies, Well Sort Of</title>
    <link rel="alternate" href="/blog/2012/07/03/quitsies-well-sort-of"/>
    <id>/blog/2012/07/03/quitsies-well-sort-of</id>
    <published>2012-07-03T00:00:00+01:00</published>
    <updated>2012-07-03T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;You know when you start to question why you write these things it&amp;#39;s probably time to quit, or at least take a break.  &lt;/p&gt;

&lt;p&gt;~ me, just there now&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This more of an FYI to anyone who may read this blog than a horrible diatribe about how I am wasting my life with meaningless exercises or technologies I&amp;#39;ll never get to use to a bunch of people that don&amp;#39;t really care, what would be the point?  Plus - it&amp;#39;s probably not even true. &lt;/p&gt;

&lt;p&gt;So rather than pottering on about cool and interesting technologies that will make everyones (read, developers) life infinitely better 100% guaranteed I&amp;#39;ve decided to devote my time to, &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Working on some startup-py type things that have been milling around the back of my head for some time, and, &lt;/li&gt;
&lt;li&gt;Generally getting stuff done &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Yep, like a hipster band, this little testament to bike-shedding is going on indefinite hiatus.&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;You know when you start to question why you write these things it&amp;#39;s probably time to quit, or at least take a break.  &lt;/p&gt;

&lt;p&gt;~ me, just there now&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This more of an FYI to anyone who may read this blog than a horrible diatribe about how I am wasting my life with meaningless exercises or technologies I&amp;#39;ll never get to use to a bunch of people that don&amp;#39;t really care, what would be the point?  Plus - it&amp;#39;s probably not even true. &lt;/p&gt;

&lt;p&gt;So rather than pottering on about cool and interesting technologies that will make everyones (read, developers) life infinitely better 100% guaranteed I&amp;#39;ve decided to devote my time to, &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Working on some startup-py type things that have been milling around the back of my head for some time, and, &lt;/li&gt;
&lt;li&gt;Generally getting stuff done &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Yep, like a hipster band, this little testament to bike-shedding is going on indefinite hiatus.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>[Quick and Dirty, Super Ugly,] Starter for 10 - Dropwizard</title>
    <link rel="alternate" href="/blog/2012/07/03/quick-and-dirty-super-ugly-starter-for-10-dropwizard"/>
    <id>/blog/2012/07/03/quick-and-dirty-super-ugly-starter-for-10-dropwizard</id>
    <published>2012-07-03T00:00:00+01:00</published>
    <updated>2012-07-03T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;So once again I&amp;#39;m writing Java without a gun to my head, and once again I&amp;#39;m finding it enjoyable.  Don&amp;#39;t get me wrong Java as a language feels very long winded, old and cumbersome but the frameworks and stuff that exist around it actually make those issues, less prominent, so much so I think I could easily live with the noise that Java brings.&lt;/p&gt;

&lt;p&gt;Anywho.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dropwizard.codahale.com/"&gt;Dropwizard&lt;/a&gt; is a framework for creating very simple ReSTful Web Services in Java.  Not just that but it also bundles some nice best practise in with it as well.  Things like pluggable health checks, logging, configuration, content negotiation etc.  And, because it&amp;#39;s fairly lightweight its fast.  Very fast.&lt;/p&gt;

&lt;p&gt;In fact you can think of Dropwizard as a collection of pre-existing tools glued together with some simple features to create a cohesive stack for HTTP+JSON web services.  You&amp;#39;ve got &lt;a href="http://www.eclipse.org/jetty/"&gt;Jetty&lt;/a&gt;, &lt;a href="http://jersey.java.net/"&gt;Jersey&lt;/a&gt;, &lt;a href="http://jackson.codehaus.org/"&gt;Jackson&lt;/a&gt;, &lt;a href="http://metrics.codahale.com/"&gt;Metrics&lt;/a&gt;, &lt;a href="http://logback.qos.ch/"&gt;Logback&lt;/a&gt;, &lt;a href="http://www.jdbi.org/"&gt;JDBI&lt;/a&gt; and more.  Dropwizard give you the glue that binds these along with a simple pipeline that makes use of these technologies.&lt;/p&gt;

&lt;h2&gt;Simple Todo&lt;/h2&gt;

&lt;p&gt;I had intended to do something a little more substantial but I am about to make a small annoucemnet that has kind of effectivley stopped me expanding this app much further.  So lets create a simple Todo App.&lt;/p&gt;

&lt;h3&gt;pom.xml&lt;/h3&gt;

&lt;p&gt;As with most Java projects lets start with the &lt;code&gt;pom.xml&lt;/code&gt; which is effectively our project definition.  I&amp;#39;ll not show you my entire POM, at least not on the first date, but let me reveal the important parts.&lt;/p&gt;

&lt;p&gt;Beause it&amp;#39;s awesome I want to include WebJars so I add my repository,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="nt"&gt;&amp;lt;repositories&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;repository&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;id&amp;gt;&lt;/span&gt;webjars&lt;span class="nt"&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;url&amp;gt;&lt;/span&gt;http://webjars.github.com/m2&lt;span class="nt"&gt;&amp;lt;/url&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/repository&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/repositories&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next I add my dependencies,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Dropwizard Core which has everything you&amp;#39;ll need for this&lt;/li&gt;
&lt;li&gt;jQuery from the WebJar repository&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="nt"&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;com.yammer.dropwizard&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;dropwizard-core&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.4.2&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;com.jquery&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;jquery&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.7.2-1&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I also add the &lt;a href="http://maven.apache.org/plugins/maven-shade-plugin/"&gt;shade plugin&lt;/a&gt; which will let me build a Fat Jar (a jar with all my dependencies and what not in it).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="nt"&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.apache.maven.plugins&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;maven-shade-plugin&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.6&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;createDependencyReducedPom&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/createDependencyReducedPom&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;filters&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;filter&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;artifact&amp;gt;&lt;/span&gt;*:*&lt;span class="nt"&gt;&amp;lt;/artifact&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;excludes&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;exclude&amp;gt;&lt;/span&gt;META-INF/*.SF&lt;span class="nt"&gt;&amp;lt;/exclude&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;exclude&amp;gt;&lt;/span&gt;META-INF/*.DSA&lt;span class="nt"&gt;&amp;lt;/exclude&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;exclude&amp;gt;&lt;/span&gt;META-INF/*.RSA&lt;span class="nt"&gt;&amp;lt;/exclude&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;/excludes&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/filter&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/filters&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;executions&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;phase&amp;gt;&lt;/span&gt;package&lt;span class="nt"&gt;&amp;lt;/phase&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;shade&lt;span class="nt"&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;transformers&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;transformer&lt;/span&gt; &lt;span class="na"&gt;implementation=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;org.apache.maven.plugins.shade.resource.ServicesResourceTransformer&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;transformer&lt;/span&gt; &lt;span class="na"&gt;implementation=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;org.apache.maven.plugins.shade.resource.ManifestResourceTransformer&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class="nt"&gt;&amp;lt;mainClass&amp;gt;&lt;/span&gt;se.yobriefca.TodoService&lt;span class="nt"&gt;&amp;lt;/mainClass&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;/transformer&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;/transformers&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/executions&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Configuration&lt;/h3&gt;

&lt;p&gt;Dropwizard has the ability to map configuration options (from a YML or JSON file) into concrete classes that can be accessed by your services.  So first I created a todo.yml at the root of the project (beside the pom.xml) with some basic configuration&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;rootPath&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/app/*&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This configuration tells Dropwizard that my services are located at a url starting with  &lt;code&gt;/app&lt;/code&gt; - eg &lt;code&gt;/app/todo&lt;/code&gt;.  This is necessary as I want to create an asset later that maps to the root url &lt;code&gt;/&lt;/code&gt; that is the default of Dropwizard.  At this point I haven&amp;#39;t needed any of my own configuration but if I did I could create a POJO that maps to proeprties in this file.  The &lt;a href="http://dropwizard.codahale.com/getting-started/#creating-a-configuration-class"&gt;official guide&lt;/a&gt; has more on this.  For now I will create an empty &lt;code&gt;Configuration&lt;/code&gt; class in case I want to extend it later (yeah I know YAGNI YAGNI KISS YAGNI - shutuppayourface!)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;package&lt;/span&gt; &lt;span class="n"&gt;se&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yobriefca&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yammer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dropwizard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Configuration&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;TodoConfiguration&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Configuration&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Service&lt;/h3&gt;

&lt;p&gt;The service is the core class in our solution.  It&amp;#39;s the thing that has the &lt;code&gt;main&lt;/code&gt; as an entry point.  The thing that &amp;ldquo;set us up the resouces&amp;rdquo; and registers healthchecks and controls our service lifecycle.  You&amp;#39;d think there would be loads of code here?  Right?  Wrong!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;package&lt;/span&gt; &lt;span class="nx"&gt;se.yobriefca&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;com.yammer.dropwizard.Service&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;com.yammer.dropwizard.bundles.AssetsBundle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;com.yammer.dropwizard.config.Environment&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;se.yobriefca.resources.TodoResource&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;TodoService&lt;/span&gt; &lt;span class="nx"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Service&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;TodoConfiguration&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;static&lt;/span&gt; &lt;span class="bp"&gt;void&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt; args) throws Exception {
        new TodoService().run(args);
    }

    private TodoService() {
        super(&amp;quot;todo&amp;quot;);

        addBundle(new AssetsBundle(&amp;quot;/assets&amp;quot;, &amp;quot;/&amp;quot;));
        addBundle(new AssetsBundle(&amp;quot;/public&amp;quot;, &amp;quot;/public/&amp;quot;));
    }

    @Override
    protected void initialize(TodoConfiguration configuration, Environment environment) {
        environment.addResource(new TodoResource());
    }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So all services extend &lt;code&gt;Service&lt;/code&gt; and have a &lt;code&gt;Configuration&lt;/code&gt; type (FYI these config types can be nested so its not as restrictive as I first thought).  Basically what we have is a &lt;code&gt;main&lt;/code&gt; method that create an instance of our service and runs it.  Upon creation we add two bundles to the service.  A bundle is bascially a bit of functionality and in this case we create two &lt;code&gt;AssetBundles&lt;/code&gt; which can be used to serve static content (embedded resources) upon request to a specific URL (think things like CSS, JavaScript, HTML etc.)  You&amp;#39;ll notice I am mapping 2 things bundles here and this is because I need to map to the WebJars directroy as well.  So when I got to &lt;code&gt;localhost/index.html&lt;/code&gt; it will match the url pattern in the first AssetsBundle and look for a file &lt;code&gt;src/main/resources/assets/index.html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally we have the &lt;code&gt;initialize&lt;/code&gt; method that allows us to decare mutliple resources and healthchecks against our environment.  We also get handed our configuration class we decalred in advance.&lt;/p&gt;

&lt;h3&gt;A bit about healthchecks&lt;/h3&gt;

&lt;p&gt;Healthchecks are little classes that perform some sort of test on a part of your solution.  For example we could have a database connectivity check.  These healthchecks are made available on the &lt;a href="http://dropwizard.codahale.com/manual/core/#health-checks"&gt;admin section that is bound to another port&lt;/a&gt; when your app starts.  &lt;/p&gt;

&lt;p&gt;Now I didn&amp;#39;t define any for this example and for that I feel absolutely terrible.  Seriously I kind of feel sick thinkging about it.  And whats worse Dropwizard kindly reminds me everytime I start the app - using LOTS of exclamantion marks and CAPS!!!  IRL you should really not follow my example here.&lt;/p&gt;

&lt;h3&gt;Resources&lt;/h3&gt;

&lt;p&gt;Resources are resources as they are identified in ReSTy things.  For example a &lt;code&gt;User&lt;/code&gt; is a resource or an &lt;code&gt;Order&lt;/code&gt; etc.  These things will respond to HTTP requests matched against the URL and the HTTP Method used.  In my example I have defined a resource &lt;code&gt;Todo&lt;/code&gt; that can be used to list, create and delete (I didn&amp;#39;t need anything else for this).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/todos&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;Produces&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MediaType.APPLICATION_JSON&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;TodoResource&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;final&lt;/span&gt; &lt;span class="nx"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;todos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Lists.newArrayList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;GET&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Collection&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;POST&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Todo&lt;/span&gt; &lt;span class="nb"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nb"&gt;Valid&lt;/span&gt; &lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;todos.add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;DELETE&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/{id}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Todo&lt;/span&gt; &lt;span class="nb"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nx"&gt;PathParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;final&lt;/span&gt; &lt;span class="nx"&gt;LongParam&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="n"&gt;todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nb"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;todoCopy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Lists.newArrayList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nx"&gt;todos.clear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;// loop past all items in the list and replace the changed one&lt;/span&gt;
        &lt;span class="nb"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="nb"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;todoCopy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;element.getId&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nx"&gt;id.get&lt;/span&gt;&lt;span class="p"&gt;()){&lt;/span&gt;
                &lt;span class="nx"&gt;todos.add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;element&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;element&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again not a great deal of code and what code that is there is fairly straightforward - some would say boilerplate.  We use annotations to map our HTTP Methods &lt;code&gt;@GET&lt;/code&gt;, &lt;code&gt;@POST&lt;/code&gt; and &lt;code&gt;@DELETE&lt;/code&gt; as well as a &lt;code&gt;@Path(...)&lt;/code&gt; annotation to specify what url this resource resonds to.  Another nice feature we can see annotated here is we get both validation (via the @Valid annotation which is based on Hibernates Validation framework) and JSON model binding via Jackson and model annotations (get to that in a minute).&lt;/p&gt;

&lt;p&gt;For this simple demo I am storing a list of Todos in an ArrayList in memory (top of the class).&lt;/p&gt;

&lt;h3&gt;Model&lt;/h3&gt;

&lt;p&gt;The model is, bar all the annotations to enable serialisation, fairly POJO-like,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;Todo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// Not So Universally Unique!&lt;/span&gt;
    &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;final&lt;/span&gt; &lt;span class="n"&gt;AtomicLong&lt;/span&gt; &lt;span class="n"&gt;NSUUID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;AtomicLong&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;JsonProperty&lt;/span&gt;
    &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;final&lt;/span&gt; &lt;span class="n"&gt;Long&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;NotEmpty&lt;/span&gt;
    &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;JsonProperty&lt;/span&gt;
    &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;final&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;JsonCreator&lt;/span&gt;
    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;JsonProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;content&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NSUUID&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;incrementAndGet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;getContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Long&lt;/span&gt; &lt;span class="n"&gt;getId&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I&amp;#39;ve put this in more for completeness as there is little involved in this.&lt;/p&gt;

&lt;h3&gt;index.html&lt;/h3&gt;

&lt;p&gt;I am not going to create some elaborate over architected front end here - just a few lines of JavaScript (ignoring the rather large jQuery library included of course) and not styling.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Demo&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;task&amp;quot;&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;addTask&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add Task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;todos&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;text/javascript&amp;#39;&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;/public/jquery.min.js&amp;#39;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
      $(function(){
        // load and replace the list
        $.getJSON(&amp;quot;/app/todos&amp;quot;, function(todos){
          for(var i = 0; i &lt;span class="nt"&gt;&amp;lt; todos.length&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt; &lt;span class="err"&gt;i++){&lt;/span&gt;
            &lt;span class="err"&gt;$(&amp;quot;#todos&amp;quot;).append(&lt;/span&gt;
              &lt;span class="err"&gt;&amp;quot;&amp;lt;li&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;checkbox&amp;#39;&lt;/span&gt; &lt;span class="na"&gt;data-id=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&amp;quot; + todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="s"&gt;.id +&amp;quot;&amp;#39;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;&amp;quot; +
                todos&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;.content +
              &amp;quot;&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;&amp;quot;
            )
          }
        });

        // manage adding a new task
        $(&amp;quot;#addTask&amp;quot;).click(function(){
          $.ajax({
            url:         &amp;quot;/app/todos&amp;quot;,
            type:        &amp;quot;POST&amp;quot;,
            data:        JSON.stringify({ content: $(&amp;quot;#task&amp;quot;).val() }),
            contentType: &amp;quot;application/json; charset=utf-8&amp;quot;,
            dataType:    &amp;quot;json&amp;quot;,
            success:     function(data, textStatus, jqXHR){
              $(&amp;quot;#todos&amp;quot;).append(
                &amp;quot;&lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;checkbox&amp;#39;&lt;/span&gt; &lt;span class="na"&gt;data-id=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&amp;quot; + data.id +&amp;quot;&amp;#39;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;&amp;quot; +
                  data.content +
                &amp;quot;&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;&amp;quot;
              )
            }
          })
        })

        $(&amp;quot;#todos&amp;quot;).delegate(&amp;quot;input&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;checkbox&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&amp;quot;, &amp;quot;click&amp;quot;, function(){
          var chk  = $(this),
          item = chk.parent(&amp;quot;li&amp;quot;),
          id   = chk.data(&amp;quot;id&amp;quot;);

          $.ajax({
            url:         &amp;quot;/app/todos/&amp;quot; + id,
            type:        &amp;quot;DELETE&amp;quot;,
            contentType: &amp;quot;application/json; charset=utf-8&amp;quot;,
            dataType:    &amp;quot;json&amp;quot;,
            success:     function(data, textStatus, jqXHR){
              if(data.id === id){
                item.css({&amp;quot;text-decoration&amp;quot;: &amp;quot;line-through&amp;quot;});
                chk.remove();
              }
            }
          })
        })
      })
    &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And thats it.  Oh wait I also added a boot command that peforms the maven packing and starts the jar.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;mvn&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="n"&gt;java&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;jar&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;todo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jar&lt;/span&gt; &lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="n"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yml&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Just run &lt;code&gt;./boot&lt;/code&gt; (assuming you&amp;#39;ve chmod&amp;#39;d the file to be executable) and you&amp;#39;ll have, assuming I (or you) haven&amp;#39;t made any mistakes, a Todo service running on port 8080 (with admin/diagnostics stuff on port 8081).&lt;/p&gt;

&lt;p&gt;As always the &lt;a href="https://github.com/kouphax/dropwizard-todo"&gt;example code is available on Github&lt;/a&gt;.  Sorry for the rushed nature of this post, I&amp;#39;ll hopefully keep tweaking the example on Github till it&amp;#39;s a bit nicer - perhaps even with tests and comments (YEAH RIGHT!!!!)&lt;/p&gt;

&lt;p&gt;In short - Dropwizard - simple ReST services, very little config, very nice.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;So once again I&amp;#39;m writing Java without a gun to my head, and once again I&amp;#39;m finding it enjoyable.  Don&amp;#39;t get me wrong Java as a language feels very long winded, old and cumbersome but the frameworks and stuff that exist around it actually make those issues, less prominent, so much so I think I could easily live with the noise that Java brings.&lt;/p&gt;

&lt;p&gt;Anywho.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://dropwizard.codahale.com/"&gt;Dropwizard&lt;/a&gt; is a framework for creating very simple ReSTful Web Services in Java.  Not just that but it also bundles some nice best practise in with it as well.  Things like pluggable health checks, logging, configuration, content negotiation etc.  And, because it&amp;#39;s fairly lightweight its fast.  Very fast.&lt;/p&gt;

&lt;p&gt;In fact you can think of Dropwizard as a collection of pre-existing tools glued together with some simple features to create a cohesive stack for HTTP+JSON web services.  You&amp;#39;ve got &lt;a href="http://www.eclipse.org/jetty/"&gt;Jetty&lt;/a&gt;, &lt;a href="http://jersey.java.net/"&gt;Jersey&lt;/a&gt;, &lt;a href="http://jackson.codehaus.org/"&gt;Jackson&lt;/a&gt;, &lt;a href="http://metrics.codahale.com/"&gt;Metrics&lt;/a&gt;, &lt;a href="http://logback.qos.ch/"&gt;Logback&lt;/a&gt;, &lt;a href="http://www.jdbi.org/"&gt;JDBI&lt;/a&gt; and more.  Dropwizard give you the glue that binds these along with a simple pipeline that makes use of these technologies.&lt;/p&gt;

&lt;h2&gt;Simple Todo&lt;/h2&gt;

&lt;p&gt;I had intended to do something a little more substantial but I am about to make a small annoucemnet that has kind of effectivley stopped me expanding this app much further.  So lets create a simple Todo App.&lt;/p&gt;

&lt;h3&gt;pom.xml&lt;/h3&gt;

&lt;p&gt;As with most Java projects lets start with the &lt;code&gt;pom.xml&lt;/code&gt; which is effectively our project definition.  I&amp;#39;ll not show you my entire POM, at least not on the first date, but let me reveal the important parts.&lt;/p&gt;

&lt;p&gt;Beause it&amp;#39;s awesome I want to include WebJars so I add my repository,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="nt"&gt;&amp;lt;repositories&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;repository&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;id&amp;gt;&lt;/span&gt;webjars&lt;span class="nt"&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;url&amp;gt;&lt;/span&gt;http://webjars.github.com/m2&lt;span class="nt"&gt;&amp;lt;/url&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/repository&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/repositories&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next I add my dependencies,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Dropwizard Core which has everything you&amp;#39;ll need for this&lt;/li&gt;
&lt;li&gt;jQuery from the WebJar repository&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="nt"&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;com.yammer.dropwizard&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;dropwizard-core&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.4.2&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;com.jquery&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;jquery&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.7.2-1&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I also add the &lt;a href="http://maven.apache.org/plugins/maven-shade-plugin/"&gt;shade plugin&lt;/a&gt; which will let me build a Fat Jar (a jar with all my dependencies and what not in it).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="nt"&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.apache.maven.plugins&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;maven-shade-plugin&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.6&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;createDependencyReducedPom&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/createDependencyReducedPom&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;filters&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;filter&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;artifact&amp;gt;&lt;/span&gt;*:*&lt;span class="nt"&gt;&amp;lt;/artifact&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;excludes&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;exclude&amp;gt;&lt;/span&gt;META-INF/*.SF&lt;span class="nt"&gt;&amp;lt;/exclude&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;exclude&amp;gt;&lt;/span&gt;META-INF/*.DSA&lt;span class="nt"&gt;&amp;lt;/exclude&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;exclude&amp;gt;&lt;/span&gt;META-INF/*.RSA&lt;span class="nt"&gt;&amp;lt;/exclude&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;/excludes&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/filter&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/filters&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;executions&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;phase&amp;gt;&lt;/span&gt;package&lt;span class="nt"&gt;&amp;lt;/phase&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;shade&lt;span class="nt"&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;transformers&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;transformer&lt;/span&gt; &lt;span class="na"&gt;implementation=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;org.apache.maven.plugins.shade.resource.ServicesResourceTransformer&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;transformer&lt;/span&gt; &lt;span class="na"&gt;implementation=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;org.apache.maven.plugins.shade.resource.ManifestResourceTransformer&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class="nt"&gt;&amp;lt;mainClass&amp;gt;&lt;/span&gt;se.yobriefca.TodoService&lt;span class="nt"&gt;&amp;lt;/mainClass&amp;gt;&lt;/span&gt;
                        &lt;span class="nt"&gt;&amp;lt;/transformer&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;/transformers&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/executions&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Configuration&lt;/h3&gt;

&lt;p&gt;Dropwizard has the ability to map configuration options (from a YML or JSON file) into concrete classes that can be accessed by your services.  So first I created a todo.yml at the root of the project (beside the pom.xml) with some basic configuration&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;rootPath&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/app/*&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This configuration tells Dropwizard that my services are located at a url starting with  &lt;code&gt;/app&lt;/code&gt; - eg &lt;code&gt;/app/todo&lt;/code&gt;.  This is necessary as I want to create an asset later that maps to the root url &lt;code&gt;/&lt;/code&gt; that is the default of Dropwizard.  At this point I haven&amp;#39;t needed any of my own configuration but if I did I could create a POJO that maps to proeprties in this file.  The &lt;a href="http://dropwizard.codahale.com/getting-started/#creating-a-configuration-class"&gt;official guide&lt;/a&gt; has more on this.  For now I will create an empty &lt;code&gt;Configuration&lt;/code&gt; class in case I want to extend it later (yeah I know YAGNI YAGNI KISS YAGNI - shutuppayourface!)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;package&lt;/span&gt; &lt;span class="n"&gt;se&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yobriefca&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yammer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dropwizard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Configuration&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;TodoConfiguration&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Configuration&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Service&lt;/h3&gt;

&lt;p&gt;The service is the core class in our solution.  It&amp;#39;s the thing that has the &lt;code&gt;main&lt;/code&gt; as an entry point.  The thing that &amp;ldquo;set us up the resouces&amp;rdquo; and registers healthchecks and controls our service lifecycle.  You&amp;#39;d think there would be loads of code here?  Right?  Wrong!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;package&lt;/span&gt; &lt;span class="nx"&gt;se.yobriefca&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;com.yammer.dropwizard.Service&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;com.yammer.dropwizard.bundles.AssetsBundle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;com.yammer.dropwizard.config.Environment&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;se.yobriefca.resources.TodoResource&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;TodoService&lt;/span&gt; &lt;span class="nx"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Service&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;TodoConfiguration&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;static&lt;/span&gt; &lt;span class="bp"&gt;void&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt; args) throws Exception {
        new TodoService().run(args);
    }

    private TodoService() {
        super(&amp;quot;todo&amp;quot;);

        addBundle(new AssetsBundle(&amp;quot;/assets&amp;quot;, &amp;quot;/&amp;quot;));
        addBundle(new AssetsBundle(&amp;quot;/public&amp;quot;, &amp;quot;/public/&amp;quot;));
    }

    @Override
    protected void initialize(TodoConfiguration configuration, Environment environment) {
        environment.addResource(new TodoResource());
    }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So all services extend &lt;code&gt;Service&lt;/code&gt; and have a &lt;code&gt;Configuration&lt;/code&gt; type (FYI these config types can be nested so its not as restrictive as I first thought).  Basically what we have is a &lt;code&gt;main&lt;/code&gt; method that create an instance of our service and runs it.  Upon creation we add two bundles to the service.  A bundle is bascially a bit of functionality and in this case we create two &lt;code&gt;AssetBundles&lt;/code&gt; which can be used to serve static content (embedded resources) upon request to a specific URL (think things like CSS, JavaScript, HTML etc.)  You&amp;#39;ll notice I am mapping 2 things bundles here and this is because I need to map to the WebJars directroy as well.  So when I got to &lt;code&gt;localhost/index.html&lt;/code&gt; it will match the url pattern in the first AssetsBundle and look for a file &lt;code&gt;src/main/resources/assets/index.html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally we have the &lt;code&gt;initialize&lt;/code&gt; method that allows us to decare mutliple resources and healthchecks against our environment.  We also get handed our configuration class we decalred in advance.&lt;/p&gt;

&lt;h3&gt;A bit about healthchecks&lt;/h3&gt;

&lt;p&gt;Healthchecks are little classes that perform some sort of test on a part of your solution.  For example we could have a database connectivity check.  These healthchecks are made available on the &lt;a href="http://dropwizard.codahale.com/manual/core/#health-checks"&gt;admin section that is bound to another port&lt;/a&gt; when your app starts.  &lt;/p&gt;

&lt;p&gt;Now I didn&amp;#39;t define any for this example and for that I feel absolutely terrible.  Seriously I kind of feel sick thinkging about it.  And whats worse Dropwizard kindly reminds me everytime I start the app - using LOTS of exclamantion marks and CAPS!!!  IRL you should really not follow my example here.&lt;/p&gt;

&lt;h3&gt;Resources&lt;/h3&gt;

&lt;p&gt;Resources are resources as they are identified in ReSTy things.  For example a &lt;code&gt;User&lt;/code&gt; is a resource or an &lt;code&gt;Order&lt;/code&gt; etc.  These things will respond to HTTP requests matched against the URL and the HTTP Method used.  In my example I have defined a resource &lt;code&gt;Todo&lt;/code&gt; that can be used to list, create and delete (I didn&amp;#39;t need anything else for this).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/todos&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;Produces&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MediaType.APPLICATION_JSON&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;TodoResource&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;final&lt;/span&gt; &lt;span class="nx"&gt;ArrayList&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;todos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Lists.newArrayList&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;GET&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Collection&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;POST&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Todo&lt;/span&gt; &lt;span class="nb"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nb"&gt;Valid&lt;/span&gt; &lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;todos.add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;DELETE&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/{id}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Todo&lt;/span&gt; &lt;span class="nb"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nx"&gt;PathParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;final&lt;/span&gt; &lt;span class="nx"&gt;LongParam&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="n"&gt;todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nb"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;todoCopy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Lists.newArrayList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nx"&gt;todos.clear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;// loop past all items in the list and replace the changed one&lt;/span&gt;
        &lt;span class="nb"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="nb"&gt;element&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;todoCopy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;element.getId&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nx"&gt;id.get&lt;/span&gt;&lt;span class="p"&gt;()){&lt;/span&gt;
                &lt;span class="nx"&gt;todos.add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;element&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;element&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again not a great deal of code and what code that is there is fairly straightforward - some would say boilerplate.  We use annotations to map our HTTP Methods &lt;code&gt;@GET&lt;/code&gt;, &lt;code&gt;@POST&lt;/code&gt; and &lt;code&gt;@DELETE&lt;/code&gt; as well as a &lt;code&gt;@Path(...)&lt;/code&gt; annotation to specify what url this resource resonds to.  Another nice feature we can see annotated here is we get both validation (via the @Valid annotation which is based on Hibernates Validation framework) and JSON model binding via Jackson and model annotations (get to that in a minute).&lt;/p&gt;

&lt;p&gt;For this simple demo I am storing a list of Todos in an ArrayList in memory (top of the class).&lt;/p&gt;

&lt;h3&gt;Model&lt;/h3&gt;

&lt;p&gt;The model is, bar all the annotations to enable serialisation, fairly POJO-like,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;Todo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// Not So Universally Unique!&lt;/span&gt;
    &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;final&lt;/span&gt; &lt;span class="n"&gt;AtomicLong&lt;/span&gt; &lt;span class="n"&gt;NSUUID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;AtomicLong&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;JsonProperty&lt;/span&gt;
    &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;final&lt;/span&gt; &lt;span class="n"&gt;Long&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;NotEmpty&lt;/span&gt;
    &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;JsonProperty&lt;/span&gt;
    &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;final&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;JsonCreator&lt;/span&gt;
    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;JsonProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;content&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NSUUID&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;incrementAndGet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;getContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Long&lt;/span&gt; &lt;span class="n"&gt;getId&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I&amp;#39;ve put this in more for completeness as there is little involved in this.&lt;/p&gt;

&lt;h3&gt;index.html&lt;/h3&gt;

&lt;p&gt;I am not going to create some elaborate over architected front end here - just a few lines of JavaScript (ignoring the rather large jQuery library included of course) and not styling.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Demo&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;task&amp;quot;&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;addTask&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add Task&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;todos&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;text/javascript&amp;#39;&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;/public/jquery.min.js&amp;#39;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
      $(function(){
        // load and replace the list
        $.getJSON(&amp;quot;/app/todos&amp;quot;, function(todos){
          for(var i = 0; i &lt;span class="nt"&gt;&amp;lt; todos.length&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt; &lt;span class="err"&gt;i++){&lt;/span&gt;
            &lt;span class="err"&gt;$(&amp;quot;#todos&amp;quot;).append(&lt;/span&gt;
              &lt;span class="err"&gt;&amp;quot;&amp;lt;li&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;checkbox&amp;#39;&lt;/span&gt; &lt;span class="na"&gt;data-id=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&amp;quot; + todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="s"&gt;.id +&amp;quot;&amp;#39;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;&amp;quot; +
                todos&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;.content +
              &amp;quot;&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;&amp;quot;
            )
          }
        });

        // manage adding a new task
        $(&amp;quot;#addTask&amp;quot;).click(function(){
          $.ajax({
            url:         &amp;quot;/app/todos&amp;quot;,
            type:        &amp;quot;POST&amp;quot;,
            data:        JSON.stringify({ content: $(&amp;quot;#task&amp;quot;).val() }),
            contentType: &amp;quot;application/json; charset=utf-8&amp;quot;,
            dataType:    &amp;quot;json&amp;quot;,
            success:     function(data, textStatus, jqXHR){
              $(&amp;quot;#todos&amp;quot;).append(
                &amp;quot;&lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;checkbox&amp;#39;&lt;/span&gt; &lt;span class="na"&gt;data-id=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&amp;quot; + data.id +&amp;quot;&amp;#39;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;&amp;quot; +
                  data.content +
                &amp;quot;&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;&amp;quot;
              )
            }
          })
        })

        $(&amp;quot;#todos&amp;quot;).delegate(&amp;quot;input&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;checkbox&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&amp;quot;, &amp;quot;click&amp;quot;, function(){
          var chk  = $(this),
          item = chk.parent(&amp;quot;li&amp;quot;),
          id   = chk.data(&amp;quot;id&amp;quot;);

          $.ajax({
            url:         &amp;quot;/app/todos/&amp;quot; + id,
            type:        &amp;quot;DELETE&amp;quot;,
            contentType: &amp;quot;application/json; charset=utf-8&amp;quot;,
            dataType:    &amp;quot;json&amp;quot;,
            success:     function(data, textStatus, jqXHR){
              if(data.id === id){
                item.css({&amp;quot;text-decoration&amp;quot;: &amp;quot;line-through&amp;quot;});
                chk.remove();
              }
            }
          })
        })
      })
    &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And thats it.  Oh wait I also added a boot command that peforms the maven packing and starts the jar.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;mvn&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="n"&gt;java&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;jar&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;todo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jar&lt;/span&gt; &lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="n"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;yml&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Just run &lt;code&gt;./boot&lt;/code&gt; (assuming you&amp;#39;ve chmod&amp;#39;d the file to be executable) and you&amp;#39;ll have, assuming I (or you) haven&amp;#39;t made any mistakes, a Todo service running on port 8080 (with admin/diagnostics stuff on port 8081).&lt;/p&gt;

&lt;p&gt;As always the &lt;a href="https://github.com/kouphax/dropwizard-todo"&gt;example code is available on Github&lt;/a&gt;.  Sorry for the rushed nature of this post, I&amp;#39;ll hopefully keep tweaking the example on Github till it&amp;#39;s a bit nicer - perhaps even with tests and comments (YEAH RIGHT!!!!)&lt;/p&gt;

&lt;p&gt;In short - Dropwizard - simple ReST services, very little config, very nice.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Super Basic Trello API Wrapper for Scala and Play</title>
    <link rel="alternate" href="/blog/2012/06/25/super-basic-trello-api-wrapper-for-scala-and-play"/>
    <id>/blog/2012/06/25/super-basic-trello-api-wrapper-for-scala-and-play</id>
    <published>2012-06-25T00:00:00+01:00</published>
    <updated>2012-06-25T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;So I am currently doing a bit of work with using Trello as a kind of data store and decided to write a litle app in &lt;a href="http://playframework.org"&gt;Play!&lt;/a&gt; (the Scala variety of course).  There didn&amp;#39;t appear to be a library out there to handle some of the basic Trello stuff so over the past 20 minutes I put one together.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;play&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;libs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WS&lt;/span&gt;

&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;Trello&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;: &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;https://api.trello.com&amp;quot;&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;WS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt;
    &lt;span class="p"&gt;})).&lt;/span&gt;&lt;span class="n"&gt;withQueryString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;key&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;token&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yep it&amp;#39;s very basic and all but the &lt;code&gt;get&lt;/code&gt; is untested (it&amp;#39;s all I&amp;#39;ve needed so far).  But in the spirit of shipping early this is a good start.  The class makes use of Play!s uberflexible &lt;code&gt;WS&lt;/code&gt; class and returns &lt;code&gt;Promise[Request]&lt;/code&gt; so you can use it like so (just an example)&lt;/p&gt;

&lt;p&gt;A simple API object to wrap the Trello class instance to load cards and map them into my expected objects&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Api&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Trello&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TOKEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;implicit&lt;/span&gt; &lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;CardFormat&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;reads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;JsValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Card&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;as&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;due&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;as&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;writes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;JsValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;throw&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;NotImplementedException&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getPastTalks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/1/lists/_____&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;cards&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;open&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;card_fields&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;desc,name,due&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;cards&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;JsArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And calling this bad boy from a controller.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;Api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getPastTalks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;talks&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
        &lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;talks&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So - lots of work to do around this - I want to move away from a thin wrapper to something a bit more robust with strong classes for the different entites.  &lt;/p&gt;

&lt;p&gt;Also if you want to find out where to get the API keys etc. go read the decent &lt;a href="https://trello.com/docs/"&gt;API docs from Trello&lt;/a&gt;.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;So I am currently doing a bit of work with using Trello as a kind of data store and decided to write a litle app in &lt;a href="http://playframework.org"&gt;Play!&lt;/a&gt; (the Scala variety of course).  There didn&amp;#39;t appear to be a library out there to handle some of the basic Trello stuff so over the past 20 minutes I put one together.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;play&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;libs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ws&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WS&lt;/span&gt;

&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;Trello&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;: &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;https://api.trello.com&amp;quot;&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;WS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;uri&lt;/span&gt;
    &lt;span class="p"&gt;})).&lt;/span&gt;&lt;span class="n"&gt;withQueryString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;key&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;token&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yep it&amp;#39;s very basic and all but the &lt;code&gt;get&lt;/code&gt; is untested (it&amp;#39;s all I&amp;#39;ve needed so far).  But in the spirit of shipping early this is a good start.  The class makes use of Play!s uberflexible &lt;code&gt;WS&lt;/code&gt; class and returns &lt;code&gt;Promise[Request]&lt;/code&gt; so you can use it like so (just an example)&lt;/p&gt;

&lt;p&gt;A simple API object to wrap the Trello class instance to load cards and map them into my expected objects&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Api&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Trello&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TOKEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;implicit&lt;/span&gt; &lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;CardFormat&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;reads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;JsValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Card&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;as&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;due&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;as&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;writes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;card&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;JsValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;throw&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;NotImplementedException&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;getPastTalks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/1/lists/_____&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;cards&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;open&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;card_fields&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;desc,name,due&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;cards&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;JsArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cards&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Card&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And calling this bad boy from a controller.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;Api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getPastTalks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;talks&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
        &lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;talks&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So - lots of work to do around this - I want to move away from a thin wrapper to something a bit more robust with strong classes for the different entites.  &lt;/p&gt;

&lt;p&gt;Also if you want to find out where to get the API keys etc. go read the decent &lt;a href="https://trello.com/docs/"&gt;API docs from Trello&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Two Hidden Gems in Play 2's Template Engine</title>
    <link rel="alternate" href="/blog/2012/06/17/two-hidden-gems-in-play-2-s-template-engine"/>
    <id>/blog/2012/06/17/two-hidden-gems-in-play-2-s-template-engine</id>
    <published>2012-06-17T00:00:00+01:00</published>
    <updated>2012-06-17T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Poking around some &lt;a href="http://www.playframework.org/"&gt;Play 2&lt;/a&gt; &lt;a href="http://www.playframework.org/documentation/2.0.1/Samples"&gt;samples&lt;/a&gt; today I came across some little bits of sugar.  I haven&amp;#39;t seen mention of them in other places (they must be well hidden) but they are two very common things I&amp;#39;ve implemented in less elegant ways in the past.  That was reason enough for me to throw a quick post up about them.&lt;/p&gt;

&lt;p&gt;Prepare to have your minds blown.  Well not blown - gently nudged probably.&lt;/p&gt;

&lt;h2&gt;String.when&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;&amp;quot;somestring&amp;quot;.when(predicate: =&amp;gt; Boolean)&lt;/code&gt; allows you conditionally spit out the value of the string it is called on (otherwise returning and empty string).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="s"&gt;&amp;quot;returned_string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;// returns &amp;quot;returned_string&amp;quot;&lt;/span&gt;
&lt;span class="s"&gt;&amp;quot;nonreturned_string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;// returns &amp;quot;&amp;quot; (empty string)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So in the context of views what is this good for?  Lots of things but the most clever use for this little function is conditional css.  Imagine you&amp;#39;ve got a block of HTML that represents a message area. These messages can be either good or bad and so we need to add the css class of &lt;code&gt;message-bad&lt;/code&gt; depending on an argument passed in to the view.  A very quick and dirty way of handling this would be as such&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;successful&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;div&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;message @if(!successful){ &amp;quot;message-bad&amp;quot; }&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nb"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Grand, fine.  It&amp;#39;s a bit noisy but it works. &lt;code&gt;when()&lt;/code&gt; makes this a bit neater IMHO.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;successful&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;div&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;message @(&amp;quot;message-bad&amp;quot;.when(!successful))&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nb"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yep the line is the same length but it looks more like a single block of conditional code, it flows much better and, I think at least, is much more readable.&lt;/p&gt;

&lt;h2&gt;Date.format(&amp;ldquo;&amp;lt;date-format&amp;gt;&amp;rdquo;)&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;new java.util.Date().format(pattern: String)&lt;/code&gt; allows you to specify how a date should be formatted in the rendered HTML.  It&amp;#39;s essentially shorthand for the noise-fest that is &lt;code&gt;SimpleDateFormat&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SimpleDateFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the past I&amp;#39;ve added transient properties to models for displaying the date, or written my own methods on those models.  Both of those approaches should have had me taken out into a field and shot.  &lt;code&gt;format&lt;/code&gt; makes things much more straightforward,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;importantDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;java.util.Date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;importantDate.format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;dd-MM-yyyy&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And the output will be along the lines of &amp;ldquo;29-01-2013&amp;rdquo; or whatever the date was.&lt;/p&gt;

&lt;p&gt;OK so neither of these are ground breaking or earth shattering (wait they mean the same thing really dont they???) but they are neat to enough to warrant a shout-out here.  Anyone else have any little nuggets in Play 2 they want to share?&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Poking around some &lt;a href="http://www.playframework.org/"&gt;Play 2&lt;/a&gt; &lt;a href="http://www.playframework.org/documentation/2.0.1/Samples"&gt;samples&lt;/a&gt; today I came across some little bits of sugar.  I haven&amp;#39;t seen mention of them in other places (they must be well hidden) but they are two very common things I&amp;#39;ve implemented in less elegant ways in the past.  That was reason enough for me to throw a quick post up about them.&lt;/p&gt;

&lt;p&gt;Prepare to have your minds blown.  Well not blown - gently nudged probably.&lt;/p&gt;

&lt;h2&gt;String.when&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;&amp;quot;somestring&amp;quot;.when(predicate: =&amp;gt; Boolean)&lt;/code&gt; allows you conditionally spit out the value of the string it is called on (otherwise returning and empty string).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="s"&gt;&amp;quot;returned_string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;// returns &amp;quot;returned_string&amp;quot;&lt;/span&gt;
&lt;span class="s"&gt;&amp;quot;nonreturned_string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;// returns &amp;quot;&amp;quot; (empty string)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So in the context of views what is this good for?  Lots of things but the most clever use for this little function is conditional css.  Imagine you&amp;#39;ve got a block of HTML that represents a message area. These messages can be either good or bad and so we need to add the css class of &lt;code&gt;message-bad&lt;/code&gt; depending on an argument passed in to the view.  A very quick and dirty way of handling this would be as such&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;successful&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;div&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;message @if(!successful){ &amp;quot;message-bad&amp;quot; }&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nb"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Grand, fine.  It&amp;#39;s a bit noisy but it works. &lt;code&gt;when()&lt;/code&gt; makes this a bit neater IMHO.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;successful&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;div&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;message @(&amp;quot;message-bad&amp;quot;.when(!successful))&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nb"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Yep the line is the same length but it looks more like a single block of conditional code, it flows much better and, I think at least, is much more readable.&lt;/p&gt;

&lt;h2&gt;Date.format(&amp;ldquo;&amp;lt;date-format&amp;gt;&amp;rdquo;)&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;new java.util.Date().format(pattern: String)&lt;/code&gt; allows you to specify how a date should be formatted in the rendered HTML.  It&amp;#39;s essentially shorthand for the noise-fest that is &lt;code&gt;SimpleDateFormat&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SimpleDateFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the past I&amp;#39;ve added transient properties to models for displaying the date, or written my own methods on those models.  Both of those approaches should have had me taken out into a field and shot.  &lt;code&gt;format&lt;/code&gt; makes things much more straightforward,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;importantDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;java.util.Date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;importantDate.format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;dd-MM-yyyy&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And the output will be along the lines of &amp;ldquo;29-01-2013&amp;rdquo; or whatever the date was.&lt;/p&gt;

&lt;p&gt;OK so neither of these are ground breaking or earth shattering (wait they mean the same thing really dont they???) but they are neat to enough to warrant a shout-out here.  Anyone else have any little nuggets in Play 2 they want to share?&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Agile Practices</title>
    <link rel="alternate" href="https://speakerdeck.com/u/kouphax/p/agile-practices"/>
    <id>https://speakerdeck.com/u/kouphax/p/agile-practices</id>
    <published>2012-06-08T00:00:00+01:00</published>
    <updated>2012-06-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>.NET On a Diet</title>
    <link rel="alternate" href="https://speakerdeck.com/u/kouphax/p/net-on-a-diet"/>
    <id>https://speakerdeck.com/u/kouphax/p/net-on-a-diet</id>
    <published>2012-06-08T00:00:00+01:00</published>
    <updated>2012-06-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>Git Basics</title>
    <link rel="alternate" href="https://speakerdeck.com/u/kouphax/p/git-basics"/>
    <id>https://speakerdeck.com/u/kouphax/p/git-basics</id>
    <published>2012-06-08T00:00:00+01:00</published>
    <updated>2012-06-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>MongoDB</title>
    <link rel="alternate" href="https://speakerdeck.com/u/kouphax/p/mongodb"/>
    <id>https://speakerdeck.com/u/kouphax/p/mongodb</id>
    <published>2012-06-08T00:00:00+01:00</published>
    <updated>2012-06-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>MonoTouch - C# + iOS = Good Times</title>
    <link rel="alternate" href="https://github.com/kouphax/monotouch-samples-ndc2012"/>
    <id>https://github.com/kouphax/monotouch-samples-ndc2012</id>
    <published>2012-06-08T00:00:00+01:00</published>
    <updated>2012-06-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>Ruby on Rails</title>
    <link rel="alternate" href="https://speakerdeck.com/u/kouphax/p/ruby-on-rails"/>
    <id>https://speakerdeck.com/u/kouphax/p/ruby-on-rails</id>
    <published>2012-06-08T00:00:00+01:00</published>
    <updated>2012-06-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>Ruby by Example</title>
    <link rel="alternate" href="https://speakerdeck.com/u/kouphax/p/ruby-by-example"/>
    <id>https://speakerdeck.com/u/kouphax/p/ruby-by-example</id>
    <published>2012-06-08T00:00:00+01:00</published>
    <updated>2012-06-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>Mobile, How Do I Develop Thee? Let Me Count the Ways (Long Version)</title>
    <link rel="alternate" href="/blog/2012/06/07/mobile-how-do-i-develop-thee-let-me-count-the-ways-long-version"/>
    <id>/blog/2012/06/07/mobile-how-do-i-develop-thee-let-me-count-the-ways-long-version</id>
    <published>2012-06-07T00:00:00+01:00</published>
    <updated>2012-06-07T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4fcf26728a589b001f0040e8" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

&lt;h2&gt;Description&lt;/h2&gt;

&lt;p&gt;Mobile development is a bit like writing web apps back in the browser war days - full of decision anxiety, volatility and platform specific issues. There is no one true answer yet most people think there should be. This talk will cover the popular(ish) options from native all the way to web solutions (and all the mashup magic in-between). Oh yes and some opinion as well.&lt;/p&gt;

&lt;p&gt;This is the longer more up to date version of the previous talk.&lt;/p&gt;
</summary>
    <content type="html">&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4fcf26728a589b001f0040e8" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

&lt;h2&gt;Description&lt;/h2&gt;

&lt;p&gt;Mobile development is a bit like writing web apps back in the browser war days - full of decision anxiety, volatility and platform specific issues. There is no one true answer yet most people think there should be. This talk will cover the popular(ish) options from native all the way to web solutions (and all the mashup magic in-between). Oh yes and some opinion as well.&lt;/p&gt;

&lt;p&gt;This is the longer more up to date version of the previous talk.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Monotouch: C# + iOS = Good Times</title>
    <link rel="alternate" href="/blog/2012/06/07/monotouch-c-number-plus-ios-equals-good-times"/>
    <id>/blog/2012/06/07/monotouch-c-number-plus-ios-equals-good-times</id>
    <published>2012-06-07T00:00:00+01:00</published>
    <updated>2012-06-07T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4fd0fb533bb27c0022030674" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

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

&lt;p&gt;&lt;a href="https://github.com/kouphax/monotouch-samples-ndc2012"&gt;https://github.com/kouphax/monotouch-samples-ndc2012&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Description&lt;/h2&gt;

&lt;p&gt;MonoTouch allows you to harness all those C# skills and most of those handy .NET/Mono libraries to create truly native apps for iOS with a sprinkle of cross-platform support. But why not just use objective-c you cry? Choice is nice, so is C# and so is the range of libraries available for mono!&lt;/p&gt;

&lt;p&gt;In this talk I will dive in to what makes MonoTouch so compelling for .NET developers wanting to break into iOS development and even how these skills can be harnessed to create cross platform native applications for iOS, Android and WP7 through a shared codebase.&lt;/p&gt;
</summary>
    <content type="html">&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4fd0fb533bb27c0022030674" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

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

&lt;p&gt;&lt;a href="https://github.com/kouphax/monotouch-samples-ndc2012"&gt;https://github.com/kouphax/monotouch-samples-ndc2012&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Description&lt;/h2&gt;

&lt;p&gt;MonoTouch allows you to harness all those C# skills and most of those handy .NET/Mono libraries to create truly native apps for iOS with a sprinkle of cross-platform support. But why not just use objective-c you cry? Choice is nice, so is C# and so is the range of libraries available for mono!&lt;/p&gt;

&lt;p&gt;In this talk I will dive in to what makes MonoTouch so compelling for .NET developers wanting to break into iOS development and even how these skills can be harnessed to create cross platform native applications for iOS, Android and WP7 through a shared codebase.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>.NET on a Diet</title>
    <link rel="alternate" href="/blog/2012/06/07/dot-net-on-a-diet"/>
    <id>/blog/2012/06/07/dot-net-on-a-diet</id>
    <published>2012-06-07T00:00:00+01:00</published>
    <updated>2012-06-07T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4fd0fb8d3bb27c001f0309b7" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

&lt;h2&gt;Description&lt;/h2&gt;

&lt;p&gt;There are plenty of framework options in .NET. We have the big mainstream web frameworks like ASP.NET WebForms and MVC, the ORM abstractions and DataMappers in the form of Entity Framework, NHibernate and iBatis and services such as WCF requiring large amounts of careful configuration to get right. Unfortunately these frameworks can get in the way, abstractions breakdown and leak and eventually we end up fighting against the frameworks limitations.&lt;/p&gt;

&lt;p&gt;This session will take a look at the feature-fit lightweight alternatives and how they can be used to compose a technology stack that is cruft-free and fit for purpose.&lt;/p&gt;
</summary>
    <content type="html">&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4fd0fb8d3bb27c001f0309b7" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

&lt;h2&gt;Description&lt;/h2&gt;

&lt;p&gt;There are plenty of framework options in .NET. We have the big mainstream web frameworks like ASP.NET WebForms and MVC, the ORM abstractions and DataMappers in the form of Entity Framework, NHibernate and iBatis and services such as WCF requiring large amounts of careful configuration to get right. Unfortunately these frameworks can get in the way, abstractions breakdown and leak and eventually we end up fighting against the frameworks limitations.&lt;/p&gt;

&lt;p&gt;This session will take a look at the feature-fit lightweight alternatives and how they can be used to compose a technology stack that is cruft-free and fit for purpose.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Mobile, How Do I Develop Thee? Let Me Count the Ways (Long Version)</title>
    <link rel="alternate" href="https://vimeo.com/43548797"/>
    <id>https://vimeo.com/43548797</id>
    <published>2012-06-06T00:00:00+01:00</published>
    <updated>2012-06-06T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>5 Years</title>
    <link rel="alternate" href="/blog/2012/05/26/5-years"/>
    <id>/blog/2012/05/26/5-years</id>
    <published>2012-05-26T00:00:00+01:00</published>
    <updated>2012-05-26T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;So I am sitting here, here being London - 315(ish) miles away from my family, halfway through the &lt;a href="http://nhshackday.com"&gt;NHS Hack Day&lt;/a&gt; and having a bit of a personal crisis.  I often have these little episodes but this one has been languishing in my dusty old head for a good while - refusing to go away, nagging me every time I have a chance to ponder things.  It&amp;#39;s the same old thing - why am I doing any of this stuff I do?  I don&amp;#39;t generally get a great amount of opportunity in work to really stretch my creative urges.  That sort of thing happens on my own time and therefore given my other responsibilities (my wife, family and lifes associated activities) is done under a fairly tight deadline.  Add this to the fact I bore easily of things that aren&amp;#39;t really benefiting people immediately - I tend to flit, easily, between little unfinished projects.  But wait&amp;hellip;.  I did it again.  You see back there, about 2 sentences ago I just sidelined my entire life.  Thrown between two looming brackets I relegated my wife and family to a byline yet again.  Oy vey.&lt;/p&gt;

&lt;p&gt;And this brings me, neatly enough, to the point of this entire ramble.&lt;/p&gt;

&lt;p&gt;Five years ago I married my awesome wife and in that time I&amp;#39;ve done a heap of things - relocated twice, had two kids bought a house, got promoted, pissed everyone off, seen a few countries and bought/traded three cars (which get smaller every time oddly enough).  And through all this hopping around my wife has been the one true constant.  She thinks, most of the time, I don&amp;#39;t care about her - after all I&amp;#39;m in London participating in a hackathon on our 5th wedding anniversary because I stupidly didn&amp;#39;t put two and two together and notice the clash.  So yeah it may damn well seem like she comes in a close second to my hobby/career stuff (you know the stuff I already mentioned was pulling into crisis mode).  But it&amp;#39;s not true.  I can&amp;#39;t help the fact I am &amp;ldquo;emotionally retarded&amp;rdquo;, as my sister once called it, but perhaps once in a while I really should let her know that she means more than she thinks she does.  And here it is.  A little bit of emotional letting if you will.&lt;/p&gt;

&lt;p&gt;Dear Emma - happy anniversary, I hope we have plenty more, thank you for putting up with me, you&amp;#39;re aces.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;So I am sitting here, here being London - 315(ish) miles away from my family, halfway through the &lt;a href="http://nhshackday.com"&gt;NHS Hack Day&lt;/a&gt; and having a bit of a personal crisis.  I often have these little episodes but this one has been languishing in my dusty old head for a good while - refusing to go away, nagging me every time I have a chance to ponder things.  It&amp;#39;s the same old thing - why am I doing any of this stuff I do?  I don&amp;#39;t generally get a great amount of opportunity in work to really stretch my creative urges.  That sort of thing happens on my own time and therefore given my other responsibilities (my wife, family and lifes associated activities) is done under a fairly tight deadline.  Add this to the fact I bore easily of things that aren&amp;#39;t really benefiting people immediately - I tend to flit, easily, between little unfinished projects.  But wait&amp;hellip;.  I did it again.  You see back there, about 2 sentences ago I just sidelined my entire life.  Thrown between two looming brackets I relegated my wife and family to a byline yet again.  Oy vey.&lt;/p&gt;

&lt;p&gt;And this brings me, neatly enough, to the point of this entire ramble.&lt;/p&gt;

&lt;p&gt;Five years ago I married my awesome wife and in that time I&amp;#39;ve done a heap of things - relocated twice, had two kids bought a house, got promoted, pissed everyone off, seen a few countries and bought/traded three cars (which get smaller every time oddly enough).  And through all this hopping around my wife has been the one true constant.  She thinks, most of the time, I don&amp;#39;t care about her - after all I&amp;#39;m in London participating in a hackathon on our 5th wedding anniversary because I stupidly didn&amp;#39;t put two and two together and notice the clash.  So yeah it may damn well seem like she comes in a close second to my hobby/career stuff (you know the stuff I already mentioned was pulling into crisis mode).  But it&amp;#39;s not true.  I can&amp;#39;t help the fact I am &amp;ldquo;emotionally retarded&amp;rdquo;, as my sister once called it, but perhaps once in a while I really should let her know that she means more than she thinks she does.  And here it is.  A little bit of emotional letting if you will.&lt;/p&gt;

&lt;p&gt;Dear Emma - happy anniversary, I hope we have plenty more, thank you for putting up with me, you&amp;#39;re aces.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Starter for 10 - Scala, Play 2 and Mongo</title>
    <link rel="alternate" href="/blog/2012/05/08/starter-for-10-scala-play-2-and-mongo"/>
    <id>/blog/2012/05/08/starter-for-10-scala-play-2-and-mongo</id>
    <published>2012-05-08T00:00:00+01:00</published>
    <updated>2012-05-08T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;This post is going to cover the whole &amp;ldquo;getting up an running&amp;rdquo; for a simple Scala stack - namely Scala, Play 2 and Mongo.  2012 has been the year of the polyglot for me.  I&amp;#39;ve been working on projects with .NET, Node.js, Ruby and Scala in the mix.  I&amp;#39;ve seen how Rails can really boost developer productivity (compared to the likes of ASP.NET MVC or other, less opinionated, frameworks) but I must say - In terms of developer productivity, at least for me, nothing has come close to the Scala/Play/Mongo combo.  I hadn&amp;#39;t touched functional programming since SML in university but I found Scala allowed me to express myself in a very terse manner.  Combine that with Play and its straightforward, uncomplicated approach to building web apps and Mongo with its schemaless nature then its productivity++ all the way.  &lt;/p&gt;

&lt;p&gt;It&amp;#39;s worth pointing out right away that James Ward already has a &lt;a href="http://www.jamesward.com/2012/02/21/play-framework-2-with-scala-anorm-json-coffeescript-jquery-heroku"&gt;similar post&lt;/a&gt; and a &lt;a href="https://github.com/jamesward/play2torial/blob/master/JAVA.md"&gt;(currently Java only) tutorial&lt;/a&gt;.  These are  much better but they dont cover the Mongo/Caabah/Salat side of things (not that it is particularly difficult) so at least I&amp;#39;ve got a leg to stand on.&lt;/p&gt;

&lt;h2&gt;Installing&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Versions used in this post&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scala (2.9.1)&lt;/li&gt;
&lt;li&gt;Play (2.0.1)&lt;/li&gt;
&lt;li&gt;Mongo (2.0.4)&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;I&amp;#39;m going to assume that you are capable of installing software (by following basic instructions) so I won&amp;#39;t waste your time covering this.  Here are some links to kick you off,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.scala-lang.org/downloads"&gt;Scala&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.playframework.org/download"&gt;Play 2&lt;/a&gt; (it just goes on your &lt;code&gt;PATH&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.mongodb.org/downloads"&gt;Mongo&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alternatively if you are on OSX - &lt;a href="http://mxcl.github.com/homebrew/"&gt;Homebrew&lt;/a&gt; has got everything you need at the time of putting this together.&lt;/p&gt;

&lt;h2&gt;Generating your Application&lt;/h2&gt;

&lt;p&gt;Play is a command line tool and can be used to generate your basic app skeleton,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;play&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Just fill in the project name and you will be guided through the basic generation of the project, e.g.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;play&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;sampleapp&lt;/span&gt;                                              
       &lt;span class="n"&gt;_&lt;/span&gt;            &lt;span class="n"&gt;_&lt;/span&gt; 
 &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;__&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;__&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;  &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;|/&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt;  &lt;span class="n"&gt;__&lt;/span&gt;&lt;span class="o"&gt;/|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;____&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;__&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;            &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;__&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt; 

&lt;span class="n"&gt;play&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="mf"&gt;2.0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//www.playframework.org&lt;/span&gt;

&lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="n"&gt;will&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;created&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;kouphax&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Projects&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;sampleapp&lt;/span&gt;

&lt;span class="n"&gt;What&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; 
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sampleapp&lt;/span&gt;

&lt;span class="n"&gt;Which&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; 

  &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;simple&lt;/span&gt; &lt;span class="n"&gt;Scala&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;
  &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;simple&lt;/span&gt; &lt;span class="n"&gt;Java&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;
  &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt; &lt;span class="n"&gt;an&lt;/span&gt; &lt;span class="n"&gt;empty&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="n"&gt;OK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="n"&gt;sampleapp&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;created&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="n"&gt;Have&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Indeed - fun you shall have.&lt;/p&gt;

&lt;h2&gt;Dependencies&lt;/h2&gt;

&lt;p&gt;Working with Mongo directly is all well and good but it can be made a bit simpler with a few dependencies.  Namely &lt;a href="http://api.mongodb.org/scala/casbah/2.0/"&gt;Casbah&lt;/a&gt; and &lt;a href="https://github.com/novus/salat"&gt;Salat&lt;/a&gt;.  Casbah is the official Scala Toolkit for MongoDB and Salat allows you to map to and from the generic Mongo object classes into more concrete case classes.&lt;/p&gt;

&lt;p&gt;To add the dependencies you need to update the &lt;code&gt;Build.scala&lt;/code&gt; file in the generated &lt;code&gt;project&lt;/code&gt; directory.  Firstly you need to update the &lt;code&gt;appDependencies&lt;/code&gt; to create the dependency on the new two libraries,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;com.mongodb.casbah&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;casbah&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;2.1.5-1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;com.novus&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;salat-core&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;0.0.8-SNAPSHOT&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then you&amp;#39;ll need to add the &lt;code&gt;resolvers&lt;/code&gt; to the &lt;code&gt;main&lt;/code&gt; project declaration,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PlayProject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;appVersion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mainLang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SCALA&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;
   &lt;span class="n"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;++=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
     &lt;span class="s"&gt;&amp;quot;repo.novus snaps&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;http://repo.novus.com/snapshots/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;UPDATE:  Since this article is a bit old but still getting plenty of hits I have noticed that people are having issues resolving dependencies on salat and casbah - this is because of a reporsitory change.  Simple fix just add the following line to the resolvers Seq above,&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="s"&gt;&amp;quot;casbah&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;https://oss.sonatype.org/content/groups/scala-tools/&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;This should be enough to get you going with the rest of this article however there will be some major changes expected in Scala 2.10 that may well fundamentally alter the need to use Salat etc.  Be warned.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And thats the project set up with all its dependencies ready to hack on.  So lets drive a spike through this stack and see what it looks like shall we?  Yes why not, tallyho old bean!&lt;/p&gt;

&lt;h2&gt;The Model &amp;amp; Data Access&lt;/h2&gt;

&lt;p&gt;First things first lets create our model.  So we are going to write a very basic registration app.  People &amp;ldquo;register&amp;rdquo; on the site, for fun or something, I dunno as our stakeholders - I just write the code.&lt;/p&gt;

&lt;p&gt;Our model is super simple,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;username:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="n"&gt;confirm&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="n"&gt;realName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now to the interesting part.  To persist this in a Mongo data store we need to make use of the two libraries we imported previously,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;casbah&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Imports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;novus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;novus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;

&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Registrations&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;registrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MongoConnection&lt;/span&gt;&lt;span class="p"&gt;()(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;sampleapp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;registrations&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;registrations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grater&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;asObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;toList&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;registrations&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;grater&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;asDBObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;First things first we create a connection using the &lt;code&gt;MongoConnection&lt;/code&gt; class and grabs the &lt;code&gt;registrations&lt;/code&gt; collection from the &lt;code&gt;sampleapp&lt;/code&gt; store.  Now it&amp;#39;s worth noting that provided Mongo is up and running we don&amp;#39;t actually need to create either the store or the collection - the act of acting on a collection is enough to create both.&lt;/p&gt;

&lt;p&gt;Next up I defined two methods &lt;code&gt;all&lt;/code&gt; and &lt;code&gt;create&lt;/code&gt;.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;all&lt;/code&gt; simply pulls out all the collection data using Casbah, performs a map over the collection (which is a collection of &lt;code&gt;MongoDBObject&lt;/code&gt;/&lt;code&gt;DBObject&lt;/code&gt;s) and uses the &lt;code&gt;grater&lt;/code&gt; object provided by Salat to map from these generic objects to our &lt;code&gt;Registration&lt;/code&gt; case class.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;create&lt;/code&gt; simply adds an element (cast from a &lt;code&gt;Registration&lt;/code&gt; class to an acceptable &lt;code&gt;DBObject&lt;/code&gt;) to the collection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now isn&amp;#39;t that a nice terse data access layer?  Yes it is.  You want to make changes?  Go ahead - the fear of change is gone or much reduced compared to the typical approach.&lt;/p&gt;

&lt;h2&gt;Controllers&lt;/h2&gt;

&lt;p&gt;Next up we want to add a register controller and update the existing &lt;code&gt;Application&lt;/code&gt; controller.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;implicit&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Registrations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The only difference here is the &lt;code&gt;Registrations.all&lt;/code&gt; so we can list the registrations in the UI.  Lets jump over the the register controller&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Register&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;registrationForm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;mapping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;username&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;confirm&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;realName&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;
    &lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unapply&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;verifying&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Passwords must match&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;implicit&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registrationForm&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="k"&gt;register&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;implicit&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;registrationForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bindFromRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;BadRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
      &lt;span class="n"&gt;registration&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Registrations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;Redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="n"&gt;flashing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;message&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;User Registered!&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;OK thats a lot to take in so lets break it down a bit.&lt;/p&gt;

&lt;h3&gt;The Form&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;registrationForm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;mapping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;username&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;confirm&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;realName&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;
  &lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unapply&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;verifying&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Passwords must match&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Form concept in Play is a bit like a ViewModel of sorts.  It defines validation and mapping rules and allows you to pass a structured object between the controller and the view (inluding error information etc.).  In fact you aren&amp;#39;t even obliged to bind this to a class, they can exists as themselves.  My example above shows you how to bind to and from our &lt;code&gt;Registration&lt;/code&gt; class as well as some field and crossfield/global validation. &lt;/p&gt;

&lt;h3&gt;Model Binding&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;registrationForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bindFromRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;BadRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
  &lt;span class="n"&gt;registration&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Registrations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;Redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="n"&gt;flashing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;message&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;User Registered!&amp;quot;&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This little functional approach allows us to bind a request to our &lt;code&gt;registrationForm&lt;/code&gt; and react to invalid input.  In the case of an invalid bind the first argument into &lt;code&gt;fold&lt;/code&gt; is executed which returns a bad request with an instance of the form.  In the case of the happy path we simply push our &lt;code&gt;registration&lt;/code&gt; instance into the data store and redirect to the &lt;code&gt;index&lt;/code&gt; action along with a flash message.&lt;/p&gt;

&lt;h3&gt;Flash&lt;/h3&gt;

&lt;p&gt;Flash is like a carefully curated session variable that exists only for the next request.  This allows you to pass messages or some very transient data between requests.  This is also accessible in the view which is handy.&lt;/p&gt;

&lt;h2&gt;Routes&lt;/h2&gt;

&lt;p&gt;Routes in Play are written into the &lt;code&gt;config/routes&lt;/code&gt; file and this is used as a basis to generate reverse routes (this gives is us statically typed routes via the &lt;code&gt;routes&lt;/code&gt; object).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;# Routes&lt;/span&gt;
&lt;span class="cp"&gt;# This file defines all application routes (Higher priority routes first)&lt;/span&gt;
&lt;span class="cp"&gt;# ~~~~&lt;/span&gt;

&lt;span class="cp"&gt;# Home page&lt;/span&gt;
&lt;span class="n"&gt;GET&lt;/span&gt;     &lt;span class="o"&gt;/&lt;/span&gt;                           &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;
&lt;span class="n"&gt;GET&lt;/span&gt;     &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;                   &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Register&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;
&lt;span class="n"&gt;POST&lt;/span&gt;    &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;                   &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Register&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;

&lt;span class="cp"&gt;# Map static resources from the /public folder to the /assets URL path&lt;/span&gt;
&lt;span class="n"&gt;GET&lt;/span&gt;     &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;/*&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;               &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Assets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/public&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So I added two new routes for register that allows us to view and submit our registration form.&lt;/p&gt;

&lt;h2&gt;The Views&lt;/h2&gt;

&lt;p&gt;Right lets do something a little neat - remember I mentioned James Ward earlier?  Well he curates a little project called &lt;a href="http://webjars.github.com"&gt;webjars&lt;/a&gt; which allows us to add client side resources as managed dependencies to our project.  So lets prettify our UI with a bit of &lt;a href="http://twitter.github.com/bootstrap/"&gt;Twitter Bootstrap&lt;/a&gt; love.&lt;/p&gt;

&lt;p&gt;First thing we want to do is update our &lt;code&gt;Build.scala&lt;/code&gt; file with webjars resolver and our bootstrap dependency&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;com.github.twitter&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;  &lt;span class="s"&gt;&amp;quot;bootstrap&amp;quot;&lt;/span&gt;  &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;2.0.2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// other deps...&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PlayProject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;appVersion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mainLang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SCALA&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;++=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;webjars&amp;quot;&lt;/span&gt;          &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;http://webjars.github.com/m2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;// other resolvers...&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then in our &lt;code&gt;main.scala.html&lt;/code&gt; we can reference the bootstrap assets in the normal way,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt; &lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;media&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;screen&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@routes.Assets.at(&amp;quot;&lt;/span&gt;&lt;span class="n"&gt;stylesheets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;css&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Index (index.scala.html)&lt;/h3&gt;

&lt;p&gt;Here we simply list the current registered people,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;registrations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;List&lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Registration&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;)(implicit flash: Flash)
@main(&amp;quot;Super Simple Sample&amp;quot;) {
  @if(flash.data.contains(&amp;quot;message&amp;quot;)){
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;alert alert-success&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;@flash.get(&amp;quot;message&amp;quot;)&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  }
  &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@routes.Register.index&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;btn btn-primary&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Register&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;table table-bordered&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Username&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Real Name&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/thead&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
      @registrations.map { registration =&amp;gt; 
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;@registration.username&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;@registration.realName&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
      }
    &lt;span class="nt"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The interesting thing about Play 2 views is that they are just Scala.  Yep neat.  In fact any .NETters will feel quite at home as they are reminiscent of Razor views too.&lt;/p&gt;

&lt;h3&gt;Register (register.scala.html)&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;registrationForm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Form&lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;models.Registration&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;)(implicit flash: Flash)

@import play.api.i18n._
@import views.html.helper._

@input(field: Field, label: String, fieldType: Symbol = &amp;#39;text) = {
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;control-group @if(field.hasErrors) {error}&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;control-label&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@field.id&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;@label&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;controls&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@fieldType.name&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@field.value&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@field.id&amp;quot;&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      @if(field.hasErrors){
        &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;help-inline&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          @Messages(field.error.head.message)
        &lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
      }
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
}

@main(&amp;quot;Super Simple Sample&amp;quot;) {
  @form(action = routes.Register.register, &amp;#39;class -&amp;gt; &amp;quot;form-horizontal&amp;quot;) {
    &lt;span class="nt"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;legend&amp;gt;&lt;/span&gt;Registration&lt;span class="nt"&gt;&amp;lt;/legend&amp;gt;&lt;/span&gt;
      @registrationForm.globalError.map { error =&amp;gt; 
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;row&amp;#39;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;alert alert-error&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;@error.message&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
      }
      @input(registrationForm(&amp;quot;name&amp;quot;), &amp;quot;Username&amp;quot;)
      @input(registrationForm(&amp;quot;password&amp;quot;), &amp;quot;Password&amp;quot;, &amp;#39;password)
      @input(registrationForm(&amp;quot;confirm&amp;quot;), &amp;quot;Confirm Password&amp;quot;, &amp;#39;password)
      @input(registrationForm(&amp;quot;realName&amp;quot;), &amp;quot;Real Name&amp;quot;)
    &lt;span class="nt"&gt;&amp;lt;/fieldset&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;submit&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;btn&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Register&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can see from the source there that I&amp;#39;ve crafted my own helper function to keep things nice and DRY and avoid having to write out the twitter bootstrap required structure over and over.&lt;/p&gt;

&lt;h2&gt;Running and Wrap Up&lt;/h2&gt;

&lt;p&gt;Right about now the solution is done so with a simple &lt;code&gt;play run&lt;/code&gt; you should be able to register and view current registrations.  Excellent.  If you want to skip everything and just get my code you can clone the &lt;a href="https://github.com/kouphax/scala-sampleapp"&gt;Github Repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;OK so it&amp;#39;s not the most useful app in the world - that was never the intention.  But look at the code - it&amp;#39;s very terse and the time required to write this post was considerably more than the time required to implement the solution.  Joy!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;This post is going to cover the whole &amp;ldquo;getting up an running&amp;rdquo; for a simple Scala stack - namely Scala, Play 2 and Mongo.  2012 has been the year of the polyglot for me.  I&amp;#39;ve been working on projects with .NET, Node.js, Ruby and Scala in the mix.  I&amp;#39;ve seen how Rails can really boost developer productivity (compared to the likes of ASP.NET MVC or other, less opinionated, frameworks) but I must say - In terms of developer productivity, at least for me, nothing has come close to the Scala/Play/Mongo combo.  I hadn&amp;#39;t touched functional programming since SML in university but I found Scala allowed me to express myself in a very terse manner.  Combine that with Play and its straightforward, uncomplicated approach to building web apps and Mongo with its schemaless nature then its productivity++ all the way.  &lt;/p&gt;

&lt;p&gt;It&amp;#39;s worth pointing out right away that James Ward already has a &lt;a href="http://www.jamesward.com/2012/02/21/play-framework-2-with-scala-anorm-json-coffeescript-jquery-heroku"&gt;similar post&lt;/a&gt; and a &lt;a href="https://github.com/jamesward/play2torial/blob/master/JAVA.md"&gt;(currently Java only) tutorial&lt;/a&gt;.  These are  much better but they dont cover the Mongo/Caabah/Salat side of things (not that it is particularly difficult) so at least I&amp;#39;ve got a leg to stand on.&lt;/p&gt;

&lt;h2&gt;Installing&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Versions used in this post&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scala (2.9.1)&lt;/li&gt;
&lt;li&gt;Play (2.0.1)&lt;/li&gt;
&lt;li&gt;Mongo (2.0.4)&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;I&amp;#39;m going to assume that you are capable of installing software (by following basic instructions) so I won&amp;#39;t waste your time covering this.  Here are some links to kick you off,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.scala-lang.org/downloads"&gt;Scala&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.playframework.org/download"&gt;Play 2&lt;/a&gt; (it just goes on your &lt;code&gt;PATH&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.mongodb.org/downloads"&gt;Mongo&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alternatively if you are on OSX - &lt;a href="http://mxcl.github.com/homebrew/"&gt;Homebrew&lt;/a&gt; has got everything you need at the time of putting this together.&lt;/p&gt;

&lt;h2&gt;Generating your Application&lt;/h2&gt;

&lt;p&gt;Play is a command line tool and can be used to generate your basic app skeleton,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;play&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Just fill in the project name and you will be guided through the basic generation of the project, e.g.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;play&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;sampleapp&lt;/span&gt;                                              
       &lt;span class="n"&gt;_&lt;/span&gt;            &lt;span class="n"&gt;_&lt;/span&gt; 
 &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;__&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;__&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;  &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;|/&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt;  &lt;span class="n"&gt;__&lt;/span&gt;&lt;span class="o"&gt;/|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;____&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;__&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;            &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;__&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt; 

&lt;span class="n"&gt;play&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="mf"&gt;2.0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//www.playframework.org&lt;/span&gt;

&lt;span class="n"&gt;The&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="n"&gt;will&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;created&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;kouphax&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Projects&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;sampleapp&lt;/span&gt;

&lt;span class="n"&gt;What&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; 
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sampleapp&lt;/span&gt;

&lt;span class="n"&gt;Which&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;want&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; 

  &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;simple&lt;/span&gt; &lt;span class="n"&gt;Scala&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;
  &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;simple&lt;/span&gt; &lt;span class="n"&gt;Java&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;
  &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt; &lt;span class="n"&gt;an&lt;/span&gt; &lt;span class="n"&gt;empty&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="n"&gt;OK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="n"&gt;sampleapp&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;created&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="n"&gt;Have&lt;/span&gt; &lt;span class="n"&gt;fun&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Indeed - fun you shall have.&lt;/p&gt;

&lt;h2&gt;Dependencies&lt;/h2&gt;

&lt;p&gt;Working with Mongo directly is all well and good but it can be made a bit simpler with a few dependencies.  Namely &lt;a href="http://api.mongodb.org/scala/casbah/2.0/"&gt;Casbah&lt;/a&gt; and &lt;a href="https://github.com/novus/salat"&gt;Salat&lt;/a&gt;.  Casbah is the official Scala Toolkit for MongoDB and Salat allows you to map to and from the generic Mongo object classes into more concrete case classes.&lt;/p&gt;

&lt;p&gt;To add the dependencies you need to update the &lt;code&gt;Build.scala&lt;/code&gt; file in the generated &lt;code&gt;project&lt;/code&gt; directory.  Firstly you need to update the &lt;code&gt;appDependencies&lt;/code&gt; to create the dependency on the new two libraries,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;com.mongodb.casbah&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;casbah&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;2.1.5-1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;com.novus&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;salat-core&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;0.0.8-SNAPSHOT&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then you&amp;#39;ll need to add the &lt;code&gt;resolvers&lt;/code&gt; to the &lt;code&gt;main&lt;/code&gt; project declaration,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PlayProject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;appVersion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mainLang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SCALA&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;
   &lt;span class="n"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;++=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
     &lt;span class="s"&gt;&amp;quot;repo.novus snaps&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;http://repo.novus.com/snapshots/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;UPDATE:  Since this article is a bit old but still getting plenty of hits I have noticed that people are having issues resolving dependencies on salat and casbah - this is because of a reporsitory change.  Simple fix just add the following line to the resolvers Seq above,&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="s"&gt;&amp;quot;casbah&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;https://oss.sonatype.org/content/groups/scala-tools/&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;This should be enough to get you going with the rest of this article however there will be some major changes expected in Scala 2.10 that may well fundamentally alter the need to use Salat etc.  Be warned.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And thats the project set up with all its dependencies ready to hack on.  So lets drive a spike through this stack and see what it looks like shall we?  Yes why not, tallyho old bean!&lt;/p&gt;

&lt;h2&gt;The Model &amp;amp; Data Access&lt;/h2&gt;

&lt;p&gt;First things first lets create our model.  So we are going to write a very basic registration app.  People &amp;ldquo;register&amp;rdquo; on the site, for fun or something, I dunno as our stakeholders - I just write the code.&lt;/p&gt;

&lt;p&gt;Our model is super simple,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;username:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="n"&gt;confirm&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="n"&gt;realName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now to the interesting part.  To persist this in a Mongo data store we need to make use of the two libraries we imported previously,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mongodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;casbah&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Imports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;novus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;novus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;salat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;

&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Registrations&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;registrations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MongoConnection&lt;/span&gt;&lt;span class="p"&gt;()(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;sampleapp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;registrations&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;registrations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grater&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;asObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="n"&gt;toList&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;registrations&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;grater&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;asDBObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;First things first we create a connection using the &lt;code&gt;MongoConnection&lt;/code&gt; class and grabs the &lt;code&gt;registrations&lt;/code&gt; collection from the &lt;code&gt;sampleapp&lt;/code&gt; store.  Now it&amp;#39;s worth noting that provided Mongo is up and running we don&amp;#39;t actually need to create either the store or the collection - the act of acting on a collection is enough to create both.&lt;/p&gt;

&lt;p&gt;Next up I defined two methods &lt;code&gt;all&lt;/code&gt; and &lt;code&gt;create&lt;/code&gt;.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;all&lt;/code&gt; simply pulls out all the collection data using Casbah, performs a map over the collection (which is a collection of &lt;code&gt;MongoDBObject&lt;/code&gt;/&lt;code&gt;DBObject&lt;/code&gt;s) and uses the &lt;code&gt;grater&lt;/code&gt; object provided by Salat to map from these generic objects to our &lt;code&gt;Registration&lt;/code&gt; case class.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;create&lt;/code&gt; simply adds an element (cast from a &lt;code&gt;Registration&lt;/code&gt; class to an acceptable &lt;code&gt;DBObject&lt;/code&gt;) to the collection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now isn&amp;#39;t that a nice terse data access layer?  Yes it is.  You want to make changes?  Go ahead - the fear of change is gone or much reduced compared to the typical approach.&lt;/p&gt;

&lt;h2&gt;Controllers&lt;/h2&gt;

&lt;p&gt;Next up we want to add a register controller and update the existing &lt;code&gt;Application&lt;/code&gt; controller.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Application&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;implicit&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Registrations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The only difference here is the &lt;code&gt;Registrations.all&lt;/code&gt; so we can list the registrations in the UI.  Lets jump over the the register controller&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;Register&lt;/span&gt; &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;registrationForm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;mapping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;username&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;confirm&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;realName&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;
    &lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unapply&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;verifying&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Passwords must match&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;implicit&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registrationForm&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="k"&gt;register&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Action&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;implicit&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;registrationForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bindFromRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;BadRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
      &lt;span class="n"&gt;registration&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Registrations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;Redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="n"&gt;flashing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;message&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;User Registered!&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;OK thats a lot to take in so lets break it down a bit.&lt;/p&gt;

&lt;h3&gt;The Form&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;registrationForm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Form&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;mapping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;username&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;confirm&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nonEmptyText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;realName&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;
  &lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;)(&lt;/span&gt;&lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unapply&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;verifying&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Passwords must match&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="n"&gt;Registration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;confirmation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Form concept in Play is a bit like a ViewModel of sorts.  It defines validation and mapping rules and allows you to pass a structured object between the controller and the view (inluding error information etc.).  In fact you aren&amp;#39;t even obliged to bind this to a class, they can exists as themselves.  My example above shows you how to bind to and from our &lt;code&gt;Registration&lt;/code&gt; class as well as some field and crossfield/global validation. &lt;/p&gt;

&lt;h3&gt;Model Binding&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;registrationForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bindFromRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;BadRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
  &lt;span class="n"&gt;registration&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Registrations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;Redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="n"&gt;flashing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;message&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;User Registered!&amp;quot;&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This little functional approach allows us to bind a request to our &lt;code&gt;registrationForm&lt;/code&gt; and react to invalid input.  In the case of an invalid bind the first argument into &lt;code&gt;fold&lt;/code&gt; is executed which returns a bad request with an instance of the form.  In the case of the happy path we simply push our &lt;code&gt;registration&lt;/code&gt; instance into the data store and redirect to the &lt;code&gt;index&lt;/code&gt; action along with a flash message.&lt;/p&gt;

&lt;h3&gt;Flash&lt;/h3&gt;

&lt;p&gt;Flash is like a carefully curated session variable that exists only for the next request.  This allows you to pass messages or some very transient data between requests.  This is also accessible in the view which is handy.&lt;/p&gt;

&lt;h2&gt;Routes&lt;/h2&gt;

&lt;p&gt;Routes in Play are written into the &lt;code&gt;config/routes&lt;/code&gt; file and this is used as a basis to generate reverse routes (this gives is us statically typed routes via the &lt;code&gt;routes&lt;/code&gt; object).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;# Routes&lt;/span&gt;
&lt;span class="cp"&gt;# This file defines all application routes (Higher priority routes first)&lt;/span&gt;
&lt;span class="cp"&gt;# ~~~~&lt;/span&gt;

&lt;span class="cp"&gt;# Home page&lt;/span&gt;
&lt;span class="n"&gt;GET&lt;/span&gt;     &lt;span class="o"&gt;/&lt;/span&gt;                           &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;
&lt;span class="n"&gt;GET&lt;/span&gt;     &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;                   &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Register&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;
&lt;span class="n"&gt;POST&lt;/span&gt;    &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;                   &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Register&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;register&lt;/span&gt;

&lt;span class="cp"&gt;# Map static resources from the /public folder to the /assets URL path&lt;/span&gt;
&lt;span class="n"&gt;GET&lt;/span&gt;     &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;/*&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;               &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Assets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/public&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So I added two new routes for register that allows us to view and submit our registration form.&lt;/p&gt;

&lt;h2&gt;The Views&lt;/h2&gt;

&lt;p&gt;Right lets do something a little neat - remember I mentioned James Ward earlier?  Well he curates a little project called &lt;a href="http://webjars.github.com"&gt;webjars&lt;/a&gt; which allows us to add client side resources as managed dependencies to our project.  So lets prettify our UI with a bit of &lt;a href="http://twitter.github.com/bootstrap/"&gt;Twitter Bootstrap&lt;/a&gt; love.&lt;/p&gt;

&lt;p&gt;First thing we want to do is update our &lt;code&gt;Build.scala&lt;/code&gt; file with webjars resolver and our bootstrap dependency&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;com.github.twitter&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;  &lt;span class="s"&gt;&amp;quot;bootstrap&amp;quot;&lt;/span&gt;  &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;2.0.2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// other deps...&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PlayProject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;appVersion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;appDependencies&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mainLang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SCALA&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;++=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;&amp;quot;webjars&amp;quot;&lt;/span&gt;          &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;http://webjars.github.com/m2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;// other resolvers...&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then in our &lt;code&gt;main.scala.html&lt;/code&gt; we can reference the bootstrap assets in the normal way,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt; &lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;media&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;screen&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@routes.Assets.at(&amp;quot;&lt;/span&gt;&lt;span class="n"&gt;stylesheets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bootstrap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;css&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Index (index.scala.html)&lt;/h3&gt;

&lt;p&gt;Here we simply list the current registered people,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;registrations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;List&lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Registration&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;)(implicit flash: Flash)
@main(&amp;quot;Super Simple Sample&amp;quot;) {
  @if(flash.data.contains(&amp;quot;message&amp;quot;)){
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;alert alert-success&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;@flash.get(&amp;quot;message&amp;quot;)&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  }
  &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@routes.Register.index&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;btn btn-primary&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Register&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;table table-bordered&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;thead&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Username&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Real Name&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/thead&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tbody&amp;gt;&lt;/span&gt;
      @registrations.map { registration =&amp;gt; 
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;@registration.username&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;@registration.realName&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
      }
    &lt;span class="nt"&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The interesting thing about Play 2 views is that they are just Scala.  Yep neat.  In fact any .NETters will feel quite at home as they are reminiscent of Razor views too.&lt;/p&gt;

&lt;h3&gt;Register (register.scala.html)&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;@(&lt;/span&gt;&lt;span class="nx"&gt;registrationForm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Form&lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;models.Registration&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;)(implicit flash: Flash)

@import play.api.i18n._
@import views.html.helper._

@input(field: Field, label: String, fieldType: Symbol = &amp;#39;text) = {
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;control-group @if(field.hasErrors) {error}&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;control-label&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@field.id&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;@label&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;controls&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@fieldType.name&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@field.value&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@field.id&amp;quot;&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      @if(field.hasErrors){
        &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;help-inline&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          @Messages(field.error.head.message)
        &lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
      }
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
}

@main(&amp;quot;Super Simple Sample&amp;quot;) {
  @form(action = routes.Register.register, &amp;#39;class -&amp;gt; &amp;quot;form-horizontal&amp;quot;) {
    &lt;span class="nt"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;legend&amp;gt;&lt;/span&gt;Registration&lt;span class="nt"&gt;&amp;lt;/legend&amp;gt;&lt;/span&gt;
      @registrationForm.globalError.map { error =&amp;gt; 
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;row&amp;#39;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;alert alert-error&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;@error.message&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
      }
      @input(registrationForm(&amp;quot;name&amp;quot;), &amp;quot;Username&amp;quot;)
      @input(registrationForm(&amp;quot;password&amp;quot;), &amp;quot;Password&amp;quot;, &amp;#39;password)
      @input(registrationForm(&amp;quot;confirm&amp;quot;), &amp;quot;Confirm Password&amp;quot;, &amp;#39;password)
      @input(registrationForm(&amp;quot;realName&amp;quot;), &amp;quot;Real Name&amp;quot;)
    &lt;span class="nt"&gt;&amp;lt;/fieldset&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;submit&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;btn&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Register&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can see from the source there that I&amp;#39;ve crafted my own helper function to keep things nice and DRY and avoid having to write out the twitter bootstrap required structure over and over.&lt;/p&gt;

&lt;h2&gt;Running and Wrap Up&lt;/h2&gt;

&lt;p&gt;Right about now the solution is done so with a simple &lt;code&gt;play run&lt;/code&gt; you should be able to register and view current registrations.  Excellent.  If you want to skip everything and just get my code you can clone the &lt;a href="https://github.com/kouphax/scala-sampleapp"&gt;Github Repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;OK so it&amp;#39;s not the most useful app in the world - that was never the intention.  But look at the code - it&amp;#39;s very terse and the time required to write this post was considerably more than the time required to implement the solution.  Joy!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>The Little Sacrifices</title>
    <link rel="alternate" href="/blog/2012/04/29/the-little-sacrifices"/>
    <id>/blog/2012/04/29/the-little-sacrifices</id>
    <published>2012-04-29T00:00:00+01:00</published>
    <updated>2012-04-29T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Late night ramblings&amp;hellip; &lt;/p&gt;

&lt;p&gt;Productivity can plateau very quickly - especially in a technical process.  No matter how good you get at the process or approach, if you keep doing the same thing you can only get so good at it or do it so fast.  It&amp;#39;s possible, however, by sacrificing some of your precious time to go beyond that plateau.  There are things we, the developers, do as part of our development process that are so small and insignificant that we do them without thinking&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clearing down the values in LocalStorage when debugging a web app&lt;/li&gt;
&lt;li&gt;Copying assets from one folder to another (aka the macgyver deploy)&lt;/li&gt;
&lt;li&gt;Navigating to &lt;code&gt;http://localhost:8000&lt;/code&gt; or &lt;code&gt;9000&lt;/code&gt; or some other port&lt;/li&gt;
&lt;li&gt;Typing &lt;code&gt;rake generate preview&lt;/code&gt; into the terminal about 20 times an hour&lt;/li&gt;
&lt;li&gt;These are but a few things I&amp;#39;ve had to consider today alone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Generally these things are so small we&amp;#39;d just do them by hand, right?  But if you take the time to automate these processes or even just refine them in some way it can do wonders for you productivity going forward.&lt;/p&gt;

&lt;p&gt;For example the clearing of LocalStorage in Chrome - spent a few minutes writing a bookmarklet that you can execute with 1 click.  The macgyver deploy?  Write a rake/make/jake/psake/cake task for it.  Better yet use &lt;a href="https://github.com/guard/guard"&gt;Guard&lt;/a&gt; or &lt;a href="https://github.com/mynyml/watchr"&gt;Watchr&lt;/a&gt; and perform the deploy on save!  Navigatin to various different localhost ports?  Try my &lt;a href="http://yobriefca.se/blog/2012/04/03/alfred-hack-for-web-developers/"&gt;alfred script&lt;/a&gt; to minimise the keystrokes. &lt;code&gt;rake generate preview&lt;/code&gt; - alias that bad boy to &lt;code&gt;rgp&lt;/code&gt;!  Save yourself those extra keystrokes - you might need them later.&lt;/p&gt;

&lt;p&gt;Listen - specifics aren&amp;#39;t important here.  You&amp;#39;ll have your own small repetitive tasks and you&amp;#39;ll be able to find your own ways to automate, improve or refine them - but this is the point.  You probably don&amp;#39;t.  At least not as often as you should.  Losing a second here and there on one task means very little in the small.  In the large, across many of these tasks, well thats a different story.  It&amp;#39;s hard to justify spending 10 or 20 minutes on something to automate a task that takes 5 seconds to run but even if the time doesn&amp;#39;t repay for a while then the fact you have less of a cognitive shift between your primary task and this secondary one should allow you stay in the highly effective, productive mindset to get the job done.  &lt;/p&gt;

&lt;p&gt;So give it a go, even as a thought experiment - think about the habitual development tasks you do and how you could automate them - you could well suprise yourself (like I have been recently).&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Late night ramblings&amp;hellip; &lt;/p&gt;

&lt;p&gt;Productivity can plateau very quickly - especially in a technical process.  No matter how good you get at the process or approach, if you keep doing the same thing you can only get so good at it or do it so fast.  It&amp;#39;s possible, however, by sacrificing some of your precious time to go beyond that plateau.  There are things we, the developers, do as part of our development process that are so small and insignificant that we do them without thinking&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clearing down the values in LocalStorage when debugging a web app&lt;/li&gt;
&lt;li&gt;Copying assets from one folder to another (aka the macgyver deploy)&lt;/li&gt;
&lt;li&gt;Navigating to &lt;code&gt;http://localhost:8000&lt;/code&gt; or &lt;code&gt;9000&lt;/code&gt; or some other port&lt;/li&gt;
&lt;li&gt;Typing &lt;code&gt;rake generate preview&lt;/code&gt; into the terminal about 20 times an hour&lt;/li&gt;
&lt;li&gt;These are but a few things I&amp;#39;ve had to consider today alone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Generally these things are so small we&amp;#39;d just do them by hand, right?  But if you take the time to automate these processes or even just refine them in some way it can do wonders for you productivity going forward.&lt;/p&gt;

&lt;p&gt;For example the clearing of LocalStorage in Chrome - spent a few minutes writing a bookmarklet that you can execute with 1 click.  The macgyver deploy?  Write a rake/make/jake/psake/cake task for it.  Better yet use &lt;a href="https://github.com/guard/guard"&gt;Guard&lt;/a&gt; or &lt;a href="https://github.com/mynyml/watchr"&gt;Watchr&lt;/a&gt; and perform the deploy on save!  Navigatin to various different localhost ports?  Try my &lt;a href="http://yobriefca.se/blog/2012/04/03/alfred-hack-for-web-developers/"&gt;alfred script&lt;/a&gt; to minimise the keystrokes. &lt;code&gt;rake generate preview&lt;/code&gt; - alias that bad boy to &lt;code&gt;rgp&lt;/code&gt;!  Save yourself those extra keystrokes - you might need them later.&lt;/p&gt;

&lt;p&gt;Listen - specifics aren&amp;#39;t important here.  You&amp;#39;ll have your own small repetitive tasks and you&amp;#39;ll be able to find your own ways to automate, improve or refine them - but this is the point.  You probably don&amp;#39;t.  At least not as often as you should.  Losing a second here and there on one task means very little in the small.  In the large, across many of these tasks, well thats a different story.  It&amp;#39;s hard to justify spending 10 or 20 minutes on something to automate a task that takes 5 seconds to run but even if the time doesn&amp;#39;t repay for a while then the fact you have less of a cognitive shift between your primary task and this secondary one should allow you stay in the highly effective, productive mindset to get the job done.  &lt;/p&gt;

&lt;p&gt;So give it a go, even as a thought experiment - think about the habitual development tasks you do and how you could automate them - you could well suprise yourself (like I have been recently).&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Infoshare 2012 Talk</title>
    <link rel="alternate" href="/blog/2012/04/20/infoshare-2012-talk"/>
    <id>/blog/2012/04/20/infoshare-2012-talk</id>
    <published>2012-04-20T00:00:00+01:00</published>
    <updated>2012-04-20T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4f911c9791b203001f00cc2b" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

&lt;iframe src="http://player.vimeo.com/video/41132110?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="500" height="275" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;

&lt;h2&gt;Resources&lt;/h2&gt;

&lt;p&gt;I mentioned a lot of technologies during my talk so here are the ones I mentioned&lt;/p&gt;

&lt;h3&gt;Web Frameworks&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://jquerymobile.com/"&gt;jQuery Mobile&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.sencha.com/products/touch"&gt;Sencha Touch&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Design&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codiqa.com/"&gt;Codiqa&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.sencha.com/products/architect/"&gt;Sencha Architect 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Web Containers&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://phonegap.com/"&gt;Phonegap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://incubator.apache.org/cordova/"&gt;Cordova&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Cross Platform&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://xamarin.com/monotouch"&gt;Monotouch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xamarin.com/monoforandroid"&gt;Monodroid&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.anscamobile.com/corona/"&gt;Corona&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://build.phonegap.com/"&gt;Phonegap:Build&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.appcelerator.com/platform/titanium-sdk"&gt;Titanium&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Server Platforms&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://parse.com/"&gt;Parse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.kinvey.com/"&gt;Kinvey&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Cloud Services&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.flurry.com/"&gt;Flurry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://urbanairship.com/"&gt;Urban  Airship&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Testing &amp;amp; Debugging&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://pivotal.github.com/jasmine/"&gt;Jasmine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lesspainful.com/"&gt;Less Painful&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.testingwithfrank.com/"&gt;Frank&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://people.apache.org/~pmuellr/weinre/"&gt;Weinre&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Beta Testing&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://testflightapp.com/"&gt;Testflight&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.hockeyapp.net/"&gt;Hockey&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Comments&lt;/h2&gt;

&lt;p&gt;So how did it go?  From my perspective it could have been better - I&amp;#39;m not sure why started &amp;ldquo;ummmmming&amp;rdquo; all the time - I had plenty to say (and I think I talked too fast as well).  I just started in a semi-flustered state for reasons unknown.  I seen a few decent comments on twitter so I guess it was fairly well received thats what matters.  If anyone has any other observations, no matter how harsh, let me know.&lt;/p&gt;

&lt;p&gt;One more note - Gdasnk is awesome - the technical people are so engaged and enthusiastic, the place itself is really interesting and I managed try my new favourite shot - &lt;a href="http://www.drinksmixer.com/drink10324.html"&gt;Mad Dog&lt;/a&gt;.  Thanks for the opportunity Gdasnk and Infoshare.  Hopefully I can back here and spend more time in the city soon.&lt;/p&gt;

&lt;p&gt;Na zdrowie&lt;/p&gt;
</summary>
    <content type="html">&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4f911c9791b203001f00cc2b" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

&lt;iframe src="http://player.vimeo.com/video/41132110?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="500" height="275" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;

&lt;h2&gt;Resources&lt;/h2&gt;

&lt;p&gt;I mentioned a lot of technologies during my talk so here are the ones I mentioned&lt;/p&gt;

&lt;h3&gt;Web Frameworks&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://jquerymobile.com/"&gt;jQuery Mobile&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.sencha.com/products/touch"&gt;Sencha Touch&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Design&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codiqa.com/"&gt;Codiqa&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.sencha.com/products/architect/"&gt;Sencha Architect 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Web Containers&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://phonegap.com/"&gt;Phonegap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://incubator.apache.org/cordova/"&gt;Cordova&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Cross Platform&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://xamarin.com/monotouch"&gt;Monotouch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://xamarin.com/monoforandroid"&gt;Monodroid&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.anscamobile.com/corona/"&gt;Corona&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://build.phonegap.com/"&gt;Phonegap:Build&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.appcelerator.com/platform/titanium-sdk"&gt;Titanium&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Server Platforms&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://parse.com/"&gt;Parse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.kinvey.com/"&gt;Kinvey&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Cloud Services&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.flurry.com/"&gt;Flurry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://urbanairship.com/"&gt;Urban  Airship&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Testing &amp;amp; Debugging&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://pivotal.github.com/jasmine/"&gt;Jasmine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lesspainful.com/"&gt;Less Painful&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.testingwithfrank.com/"&gt;Frank&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://people.apache.org/~pmuellr/weinre/"&gt;Weinre&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Beta Testing&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://testflightapp.com/"&gt;Testflight&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.hockeyapp.net/"&gt;Hockey&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Comments&lt;/h2&gt;

&lt;p&gt;So how did it go?  From my perspective it could have been better - I&amp;#39;m not sure why started &amp;ldquo;ummmmming&amp;rdquo; all the time - I had plenty to say (and I think I talked too fast as well).  I just started in a semi-flustered state for reasons unknown.  I seen a few decent comments on twitter so I guess it was fairly well received thats what matters.  If anyone has any other observations, no matter how harsh, let me know.&lt;/p&gt;

&lt;p&gt;One more note - Gdasnk is awesome - the technical people are so engaged and enthusiastic, the place itself is really interesting and I managed try my new favourite shot - &lt;a href="http://www.drinksmixer.com/drink10324.html"&gt;Mad Dog&lt;/a&gt;.  Thanks for the opportunity Gdasnk and Infoshare.  Hopefully I can back here and spend more time in the city soon.&lt;/p&gt;

&lt;p&gt;Na zdrowie&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Mobile, How Do I Develop Thee? Let Me Count the Ways (Short Version)</title>
    <link rel="alternate" href="http://vimeo.com/41132110"/>
    <id>http://vimeo.com/41132110</id>
    <published>2012-04-20T00:00:00+01:00</published>
    <updated>2012-04-20T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>Strapping Young Lad v0.1.2 Released</title>
    <link rel="alternate" href="/blog/2012/04/20/strapping-young-lad-v0-dot-1-2-released"/>
    <id>/blog/2012/04/20/strapping-young-lad-v0-dot-1-2-released</id>
    <published>2012-04-20T00:00:00+01:00</published>
    <updated>2012-04-20T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;I have just released version 0.1.2 of &lt;a href="https://github.com/kouphax/strapping-young-lad"&gt;Strapping Young Lad&lt;/a&gt;.  Now we are getting to something that works a bit better across different platforms (now I just have to prove it to you).  This release sees the inclusion of multiple token replacement.  For example if I create a &lt;code&gt;.ladconfig&lt;/code&gt; in the source repo with an array of tokens&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nl"&gt;token:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;__NAME__&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;__NAMESPACE__&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;__AUTHOR__&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The user will be prompted to specify the values for these tokens before the engine goes off and does the replacement.  The &lt;code&gt;__NAME__&lt;/code&gt; token is a bit special - you still need to specify the project name as part of the command line call so if SYL come across this token in the the list of configured tokens it will allow you to default that value without having to type it again, e.g.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;lad&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;strapping&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;young&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;lad&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Loam&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;laddy&lt;/span&gt;

  &lt;span class="n"&gt;Cloning&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;                &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Loading&lt;/span&gt; &lt;span class="n"&gt;configuration&lt;/span&gt;                 &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Parsing&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="n"&gt;stuff&lt;/span&gt;              
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;laddy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
    &lt;span class="n"&gt;namespace&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lad&lt;/span&gt;
    &lt;span class="nl"&gt;author:&lt;/span&gt; &lt;span class="n"&gt;kouphax&lt;/span&gt;
                                        &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Processing&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;                      &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Processing&lt;/span&gt; &lt;span class="n"&gt;directories&lt;/span&gt;                &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Moving&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;                  &lt;span class="n"&gt;OK&lt;/span&gt;

  &lt;span class="n"&gt;Done&lt;/span&gt; &lt;span class="n"&gt;processing&lt;/span&gt; &lt;span class="mi"&gt;137&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;Done&lt;/span&gt; &lt;span class="n"&gt;processing&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt; &lt;span class="n"&gt;directories&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice I didn&amp;#39;t need to specify the name of the project again and then I was prompted for the second and third token values.  Simple stuff.  &lt;/p&gt;

&lt;h2&gt;Next up&lt;/h2&gt;

&lt;p&gt;So there are a few outstanding efforts to go in now.  Namely push some more templates into the SYL repo and spin up a site that lets you search said templates and document all the little features of SYL.  They will come in time.&lt;/p&gt;

&lt;p&gt;This is the life!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I have just released version 0.1.2 of &lt;a href="https://github.com/kouphax/strapping-young-lad"&gt;Strapping Young Lad&lt;/a&gt;.  Now we are getting to something that works a bit better across different platforms (now I just have to prove it to you).  This release sees the inclusion of multiple token replacement.  For example if I create a &lt;code&gt;.ladconfig&lt;/code&gt; in the source repo with an array of tokens&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nl"&gt;token:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;__NAME__&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;__NAMESPACE__&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;__AUTHOR__&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The user will be prompted to specify the values for these tokens before the engine goes off and does the replacement.  The &lt;code&gt;__NAME__&lt;/code&gt; token is a bit special - you still need to specify the project name as part of the command line call so if SYL come across this token in the the list of configured tokens it will allow you to default that value without having to type it again, e.g.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;lad&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;strapping&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;young&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;lad&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Loam&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;laddy&lt;/span&gt;

  &lt;span class="n"&gt;Cloning&lt;/span&gt; &lt;span class="n"&gt;git&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;                &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Loading&lt;/span&gt; &lt;span class="n"&gt;configuration&lt;/span&gt;                 &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Parsing&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="n"&gt;stuff&lt;/span&gt;              
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;laddy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
    &lt;span class="n"&gt;namespace&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lad&lt;/span&gt;
    &lt;span class="nl"&gt;author:&lt;/span&gt; &lt;span class="n"&gt;kouphax&lt;/span&gt;
                                        &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Processing&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;                      &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Processing&lt;/span&gt; &lt;span class="n"&gt;directories&lt;/span&gt;                &lt;span class="n"&gt;OK&lt;/span&gt;
  &lt;span class="n"&gt;Moving&lt;/span&gt; &lt;span class="n"&gt;project&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;                  &lt;span class="n"&gt;OK&lt;/span&gt;

  &lt;span class="n"&gt;Done&lt;/span&gt; &lt;span class="n"&gt;processing&lt;/span&gt; &lt;span class="mi"&gt;137&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;Done&lt;/span&gt; &lt;span class="n"&gt;processing&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt; &lt;span class="n"&gt;directories&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice I didn&amp;#39;t need to specify the name of the project again and then I was prompted for the second and third token values.  Simple stuff.  &lt;/p&gt;

&lt;h2&gt;Next up&lt;/h2&gt;

&lt;p&gt;So there are a few outstanding efforts to go in now.  Namely push some more templates into the SYL repo and spin up a site that lets you search said templates and document all the little features of SYL.  They will come in time.&lt;/p&gt;

&lt;p&gt;This is the life!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Strapping Young Lad - Project Template Token Replacer and Bootstrapper</title>
    <link rel="alternate" href="/blog/2012/04/17/strapping-young-lad-project-template-token-replacer-and-bootstrapper"/>
    <id>/blog/2012/04/17/strapping-young-lad-project-template-token-replacer-and-bootstrapper</id>
    <published>2012-04-17T00:00:00+01:00</published>
    <updated>2012-04-17T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Today I have released the super simple, rough-as-hell, barely &lt;a href="http://en.wikipedia.org/wiki/Minimum_viable_product"&gt;MVP&lt;/a&gt; &lt;a href="https://rubygems.org/gems/lad"&gt;Strapping Young Lad&lt;/a&gt;(&lt;a href="https://github.com/kouphax/strapping-young-lad"&gt;Source&lt;/a&gt;).  It&amp;#39;s fulfils a need I keep having but never really fixing.  &lt;/p&gt;

&lt;h2&gt;Evelvator Pitch&lt;/h2&gt;

&lt;p&gt;SYL, or lad for short, will take a git repo, clone it and replace a bunch of tokens in it with the values you&amp;#39;ve supplied.  &lt;/p&gt;

&lt;h2&gt;Say Wha?&lt;/h2&gt;

&lt;p&gt;This means you can create a bunch of base solution/project types for any language and SYL will simply do some basic file/folder renaming and file content replacing for a given token.  For example doing the following,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;lad&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt; &lt;span class="n"&gt;MyNewProject&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Will do the following things,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repo at &lt;code&gt;path/to/git/repo&lt;/code&gt; into a temporary folder&lt;/li&gt;
&lt;li&gt;Remove the &lt;code&gt;.git&lt;/code&gt; folder from the repo&lt;/li&gt;
&lt;li&gt;Check for the existence of a &lt;code&gt;.ladconfig&lt;/code&gt; in the freshly cloned repo

&lt;ul&gt;
&lt;li&gt;If one exists it loads the config setting&lt;/li&gt;
&lt;li&gt;Otherwise it falls back to the defaults&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Replace all instances of the configured token (eg. &lt;code&gt;__NAME__&lt;/code&gt;) in all files, directories and file contents with the project name (in our case &lt;code&gt;MyNewProject&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Copy the new folder over to your current working directory (&lt;code&gt;./MyNewProject&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What this allows you to do is have a standard project template for pretty much anything (.NET, Ruby, Scala - listen I mean anything - if it a collection of folders and files in a git repo then you set) and create a new instance with a few keystrokes - saving you time and potential RSI.&lt;/p&gt;

&lt;p&gt;SYL was inspired by &lt;a href="https://github.com/chucknorris/warmup"&gt;WarmuP&lt;/a&gt; which is itself a gem but it requires you to be running .NET which for a lot of my requirement isn&amp;#39;t going to cut it.&lt;/p&gt;

&lt;p&gt;If you want to see what a typical template project looks like try &lt;a href="https://github.com/amirrajan/Loam"&gt;Amir&amp;#39;s Loam repo&lt;/a&gt;.  This is a WarmuP project but works just fine.  With SYL you can create a &lt;code&gt;.ladconfig&lt;/code&gt; file to override some of the conventions - get the source README linked above.&lt;/p&gt;

&lt;h2&gt;Whats Next&lt;/h2&gt;

&lt;p&gt;Yep it&amp;#39;s pretty damn basic right now but it satifies most of my needs right now.  There are a few things I want to add for myself but I didn&amp;#39;t release this for ME, I am pretty sure this will be of use to someone in some community in some shape or form.  With that in mind here are some features I think would take this to the next level,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Specifiying multiple tokens e.g. &lt;code&gt;__NAME__&lt;/code&gt; and &lt;code&gt;__NAMESPACE__&lt;/code&gt; and &lt;code&gt;__YEAR__&lt;/code&gt; etc. etc.&lt;/li&gt;
&lt;li&gt;Post processing actions (e.g. &lt;code&gt;bundle install&lt;/code&gt; or &lt;code&gt;npm install&lt;/code&gt; or &lt;code&gt;sbt compile&lt;/code&gt; or something like that)&lt;/li&gt;
&lt;li&gt;A catalog - I have a &lt;a href="https://github.com/strapping-young-lad"&gt;github organisation&lt;/a&gt; with no repos setup right now but this would be a brilliant place to hold a load of templates compatible with SYL, don&amp;#39;t ya think?  Then I could roll a site like rubygems or npmjs.org and make the projects searchable etc.  If you build it, they will come.  Maybe, who knows.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So if you like it - HIGHFIVE - if not - it&amp;#39;s all good.  Now go break it and criticise me.   &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So we&amp;#39;ll criticise him, because he can take it&amp;hellip;. [The Dark Knight, Approx.]&lt;/p&gt;
&lt;/blockquote&gt;
</summary>
    <content type="html">&lt;p&gt;Today I have released the super simple, rough-as-hell, barely &lt;a href="http://en.wikipedia.org/wiki/Minimum_viable_product"&gt;MVP&lt;/a&gt; &lt;a href="https://rubygems.org/gems/lad"&gt;Strapping Young Lad&lt;/a&gt;(&lt;a href="https://github.com/kouphax/strapping-young-lad"&gt;Source&lt;/a&gt;).  It&amp;#39;s fulfils a need I keep having but never really fixing.  &lt;/p&gt;

&lt;h2&gt;Evelvator Pitch&lt;/h2&gt;

&lt;p&gt;SYL, or lad for short, will take a git repo, clone it and replace a bunch of tokens in it with the values you&amp;#39;ve supplied.  &lt;/p&gt;

&lt;h2&gt;Say Wha?&lt;/h2&gt;

&lt;p&gt;This means you can create a bunch of base solution/project types for any language and SYL will simply do some basic file/folder renaming and file content replacing for a given token.  For example doing the following,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;lad&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt; &lt;span class="n"&gt;MyNewProject&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Will do the following things,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repo at &lt;code&gt;path/to/git/repo&lt;/code&gt; into a temporary folder&lt;/li&gt;
&lt;li&gt;Remove the &lt;code&gt;.git&lt;/code&gt; folder from the repo&lt;/li&gt;
&lt;li&gt;Check for the existence of a &lt;code&gt;.ladconfig&lt;/code&gt; in the freshly cloned repo

&lt;ul&gt;
&lt;li&gt;If one exists it loads the config setting&lt;/li&gt;
&lt;li&gt;Otherwise it falls back to the defaults&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Replace all instances of the configured token (eg. &lt;code&gt;__NAME__&lt;/code&gt;) in all files, directories and file contents with the project name (in our case &lt;code&gt;MyNewProject&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Copy the new folder over to your current working directory (&lt;code&gt;./MyNewProject&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What this allows you to do is have a standard project template for pretty much anything (.NET, Ruby, Scala - listen I mean anything - if it a collection of folders and files in a git repo then you set) and create a new instance with a few keystrokes - saving you time and potential RSI.&lt;/p&gt;

&lt;p&gt;SYL was inspired by &lt;a href="https://github.com/chucknorris/warmup"&gt;WarmuP&lt;/a&gt; which is itself a gem but it requires you to be running .NET which for a lot of my requirement isn&amp;#39;t going to cut it.&lt;/p&gt;

&lt;p&gt;If you want to see what a typical template project looks like try &lt;a href="https://github.com/amirrajan/Loam"&gt;Amir&amp;#39;s Loam repo&lt;/a&gt;.  This is a WarmuP project but works just fine.  With SYL you can create a &lt;code&gt;.ladconfig&lt;/code&gt; file to override some of the conventions - get the source README linked above.&lt;/p&gt;

&lt;h2&gt;Whats Next&lt;/h2&gt;

&lt;p&gt;Yep it&amp;#39;s pretty damn basic right now but it satifies most of my needs right now.  There are a few things I want to add for myself but I didn&amp;#39;t release this for ME, I am pretty sure this will be of use to someone in some community in some shape or form.  With that in mind here are some features I think would take this to the next level,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Specifiying multiple tokens e.g. &lt;code&gt;__NAME__&lt;/code&gt; and &lt;code&gt;__NAMESPACE__&lt;/code&gt; and &lt;code&gt;__YEAR__&lt;/code&gt; etc. etc.&lt;/li&gt;
&lt;li&gt;Post processing actions (e.g. &lt;code&gt;bundle install&lt;/code&gt; or &lt;code&gt;npm install&lt;/code&gt; or &lt;code&gt;sbt compile&lt;/code&gt; or something like that)&lt;/li&gt;
&lt;li&gt;A catalog - I have a &lt;a href="https://github.com/strapping-young-lad"&gt;github organisation&lt;/a&gt; with no repos setup right now but this would be a brilliant place to hold a load of templates compatible with SYL, don&amp;#39;t ya think?  Then I could roll a site like rubygems or npmjs.org and make the projects searchable etc.  If you build it, they will come.  Maybe, who knows.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So if you like it - HIGHFIVE - if not - it&amp;#39;s all good.  Now go break it and criticise me.   &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So we&amp;#39;ll criticise him, because he can take it&amp;hellip;. [The Dark Knight, Approx.]&lt;/p&gt;
&lt;/blockquote&gt;
</content>
  </entry>
  <entry>
    <title>Scala - A Tragedy in Two Parts - Part 1</title>
    <link rel="alternate" href="/blog/2012/04/13/scala-a-tragedy-in-two-parts-part-1"/>
    <id>/blog/2012/04/13/scala-a-tragedy-in-two-parts-part-1</id>
    <published>2012-04-13T00:00:00+01:00</published>
    <updated>2012-04-13T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;The tragedy being we don&amp;#39;t use it all the time!&lt;/p&gt;

&lt;p&gt;This presentation is the first part in the 2 part series &amp;ldquo;Scala - A Tragedy in Two Parts&amp;rdquo;.  In this presentation I go fast and dive into a range of Scala code snippets pointing out some of the weird and wonderful features of the language.&lt;/p&gt;

&lt;h2&gt;Recorded Session&lt;/h2&gt;

&lt;p&gt;&lt;iframe src="http://player.vimeo.com/video/40255430?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="500" height="375" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt; &lt;p&gt;&lt;a href="http://vimeo.com/40255430"&gt;Scala - A Tragedy in Two Parts - Part 1 - The Language&lt;/a&gt; from &lt;a href="http://vimeo.com/kouphax"&gt;James Hughes&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;&lt;/p&gt;

&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4f86b1fcd1325b0022019eea" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;
</summary>
    <content type="html">&lt;p&gt;The tragedy being we don&amp;#39;t use it all the time!&lt;/p&gt;

&lt;p&gt;This presentation is the first part in the 2 part series &amp;ldquo;Scala - A Tragedy in Two Parts&amp;rdquo;.  In this presentation I go fast and dive into a range of Scala code snippets pointing out some of the weird and wonderful features of the language.&lt;/p&gt;

&lt;h2&gt;Recorded Session&lt;/h2&gt;

&lt;p&gt;&lt;iframe src="http://player.vimeo.com/video/40255430?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="500" height="375" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt; &lt;p&gt;&lt;a href="http://vimeo.com/40255430"&gt;Scala - A Tragedy in Two Parts - Part 1 - The Language&lt;/a&gt; from &lt;a href="http://vimeo.com/kouphax"&gt;James Hughes&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;&lt;/p&gt;

&lt;h2&gt;Slides&lt;/h2&gt;

&lt;script async class="speakerdeck-embed" data-id="4f86b1fcd1325b0022019eea" data-ratio="1.3333333333333333" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;
</content>
  </entry>
  <entry>
    <title>Scala - A Tragedy in Two Parts</title>
    <link rel="alternate" href="https://vimeo.com/40255430"/>
    <id>https://vimeo.com/40255430</id>
    <published>2012-04-12T00:00:00+01:00</published>
    <updated>2012-04-12T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>Alfred Hack for Web Developers</title>
    <link rel="alternate" href="/blog/2012/04/03/alfred-hack-for-web-developers"/>
    <id>/blog/2012/04/03/alfred-hack-for-web-developers</id>
    <published>2012-04-03T00:00:00+01:00</published>
    <updated>2012-04-03T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;I&amp;#39;ve been a fan of &lt;a href="http://www.alfredapp.com/"&gt;Alfred&lt;/a&gt; for some time and use it to make pretty much everything a keystroke away.  I&amp;#39;ve thrown a very small little extension that reduces the time to jump between console and newly started web app.  Generally during development we need to run our app jump to &lt;code&gt;localhost:PORT&lt;/code&gt; and make sure it&amp;#39;s working.  If, like me, you have a lot of different apps and platforms (Scala, Jekyll, Rails, Sinatra, Express to name a few) then &lt;code&gt;PORT&lt;/code&gt; becomes the one thing you always need to type and the browsers auto predict is generally not that helpful in this situation.&lt;/p&gt;

&lt;p&gt;Alfred to the rescue here, just create a script as shown below and then running alfred and typing &lt;code&gt;l 9000&lt;/code&gt; you can launch your default browser at &lt;code&gt;http://localhost:9000&lt;/code&gt;.  Very simple but saves me heaps of time at the minute.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/blog/alfredscript.png?1368558404" /&gt;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I&amp;#39;ve been a fan of &lt;a href="http://www.alfredapp.com/"&gt;Alfred&lt;/a&gt; for some time and use it to make pretty much everything a keystroke away.  I&amp;#39;ve thrown a very small little extension that reduces the time to jump between console and newly started web app.  Generally during development we need to run our app jump to &lt;code&gt;localhost:PORT&lt;/code&gt; and make sure it&amp;#39;s working.  If, like me, you have a lot of different apps and platforms (Scala, Jekyll, Rails, Sinatra, Express to name a few) then &lt;code&gt;PORT&lt;/code&gt; becomes the one thing you always need to type and the browsers auto predict is generally not that helpful in this situation.&lt;/p&gt;

&lt;p&gt;Alfred to the rescue here, just create a script as shown below and then running alfred and typing &lt;code&gt;l 9000&lt;/code&gt; you can launch your default browser at &lt;code&gt;http://localhost:9000&lt;/code&gt;.  Very simple but saves me heaps of time at the minute.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/blog/alfredscript.png?1368558404" /&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Rails is not a gateway drug</title>
    <link rel="alternate" href="/blog/2012/04/03/rails-is-not-a-gateway-drug"/>
    <id>/blog/2012/04/03/rails-is-not-a-gateway-drug</id>
    <published>2012-04-03T00:00:00+01:00</published>
    <updated>2012-04-03T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;WARNING!!! - a negative opinion on Rails lies ahead.  Everything here needs to be taken with an &lt;strong&gt;IMHO&lt;/strong&gt; and, if you feel so inclined, tell me to go mind my own business.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I know I&amp;#39;m stepping into very dangerous territory here but I&amp;#39;ve come to the very solid conclusion that &lt;a href="http://rubyonrails.org/"&gt;Rails&lt;/a&gt;, Ruby&amp;#39;s heavily opinionated web framework, is not the gateway drug people claim.  I&amp;#39;ve heard the claims that if you give &lt;a href="http://rubyonrails.org/"&gt;Rails&lt;/a&gt; a try, coming from some other web stack on any other language, you&amp;#39;ll fall in love with Ruby and Rails and write a big long blog post about how you are leaving .NET (or Java or whatever) behind.  I really dont get it&amp;hellip;. the only feeling that Rails leaves me with - having been using it in anger for about a month now - is frustration.  But before you drive rusty nails into my hands and feet let me at least explain where I am coming from.&lt;/p&gt;

&lt;h2&gt;Previous attempts&lt;/h2&gt;

&lt;p&gt;I&amp;#39;ve been binging on Ruby for the last few months but this hasn&amp;#39;t been my first time - it&amp;#39;s been my only successful time but certianly not my first.  A year previous I had given Ruby/Rails a shot and it never stuck (in fact not once but at least twice).  Coming from a predominantly .NET/ASP.NET MVC background I decided the best approach would be to cut my teeth on a medium sized web based project and therefore jumped right into Rails.  It only took a short time before the whole effort felt like a slog full of weird semi-magic behaviour.  I gave up.&lt;/p&gt;

&lt;h2&gt;Doing things differently&lt;/h2&gt;

&lt;p&gt;This time around I decided to do things a little differently - rather than run with a web project I just tinkered with the language and eventually tried porting a &lt;a href="http://yobriefca.se/blog/2012/03/12/sentamentalizer/"&gt;.NET project over to Ruby&lt;/a&gt;.  Fair bit of Ruby code and a small &lt;a href="http://sinatrarb.com"&gt;sinatra&lt;/a&gt; app later - it clicked.  I got the whole Ruby love affair, it was lovely and I was three lines into my &lt;em&gt;&amp;ldquo;F**k you .NET, you&amp;#39;re worse than Java and I hate you and you smell&amp;rdquo;&lt;/em&gt; blog post (not factual!!) when I realised I needed to give Ruby more time to bed in and, out of fairness, I had to at least experience Rails.  &lt;/p&gt;

&lt;h2&gt;Present Day&lt;/h2&gt;

&lt;p&gt;And with that I discovered that Rails had been my problem.  I find it incredibly frustrating.  I don&amp;#39;t want to dive into bashing Rails, thats not my intent, - I&amp;#39;m sure people find it really productive - but it&amp;#39;s not for me.  So here is a very high level executive summary of the problems I&amp;#39;ve had with Rails&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Command Line Interface&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The CLI stuff has just a little bit too many features and options that make it a difficult thing to approach without extensive research.  When I watched some of the &lt;a href="http://railscasts.com/"&gt;Railscasts&lt;/a&gt; I found myself going &amp;ldquo;wait, HOW did he do that?&amp;rdquo; more than once.  Choice is good but surely Rails is supposed to be easy for the beginner?  Yet I feel the default options are not the ones I would have picked.  You know what - I want to be hand-held once in a while, I&amp;#39;m proud to admit that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Too Much Magic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rails is very heavily convention based but often there is simply too much convention and I&amp;#39;ve been left baffled a few times.  Some of the convention is well documented and some of it less so.  When a convention is not obvious it becomes magic and it really feels Rails has a lot of &amp;ldquo;magic&amp;rdquo;.  Thats not something I want.  To be honest I&amp;#39;d rather write the same 2/3 lines of boilerplate if it meant that, to a new developer, they could understand the convention better.  Take this very trivial example,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;HomeController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;ApplicationController&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;
  &lt;span class="n"&gt;end&lt;/span&gt;
&lt;span class="n"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And the same in ASP.NET MVC&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;HomeController&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt; &lt;span class="n"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To me that one line &lt;code&gt;return View()&lt;/code&gt; tell me that this action will return a View, and now I can infer the convention of &lt;code&gt;home/index.cshtml&lt;/code&gt; that wee bit easier.  When you start adding in more conventions, a little bit of extra code makes all the difference.  Conventions don&amp;#39;t scale unless clearly marked IMHO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bloatyness&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you generate scaffold in a Rails app, as a typical new developer would, you end up with a awful lot of files.  If I generate a new entity for example this is what I am greeted with,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="nx"&gt;rails&lt;/span&gt; &lt;span class="nx"&gt;generate&lt;/span&gt; &lt;span class="nx"&gt;scaffold&lt;/span&gt; &lt;span class="nx"&gt;MyEntity&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;Int&lt;/span&gt;                         &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;6580&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;  &lt;span class="nx"&gt;active_record&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;    &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;migrate&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;20120403130542&lt;/span&gt;&lt;span class="nx"&gt;_create_my_entities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;models&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;test_unit&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;unit&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entity_test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;fixtures&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;yml&lt;/span&gt;
       &lt;span class="nx"&gt;route&lt;/span&gt;  &lt;span class="nx"&gt;resources&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;  &lt;span class="nx"&gt;scaffold_controller&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;controllers&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities_controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;edit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;show&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;_form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;test_unit&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;functional&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities_controller_test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;helper&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;helpers&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities_helper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;      &lt;span class="nx"&gt;test_unit&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;        &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;unit&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;helpers&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities_helper_test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;  &lt;span class="nx"&gt;assets&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;coffee&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;javascripts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;coffee&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;scss&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;stylesheets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scss&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;  &lt;span class="nx"&gt;scss&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;stylesheets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;scaffolds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scss&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Don&amp;#39;t get me wrong - it&amp;#39;s nice to be given all these things for free, but it&amp;#39;s ultimatley stuff I end up ripping out anyway.  In .NET there is a running joke that the &amp;ldquo;Empty ASP.NET MVC Project&amp;rdquo; Template is anything but.  To me this is the same issue except it&amp;#39;s something that I&amp;#39;d have to clean up everytime I use the &lt;code&gt;generate scaffold&lt;/code&gt; command.  This seems worse to me.&lt;/p&gt;

&lt;h2&gt;Current Thoughts&lt;/h2&gt;

&lt;p&gt;I&amp;#39;m not sure were Rails is supposed to stand.  I hear it&amp;#39;s great for beginners or for big sites but I couldn&amp;#39;t recommend it for either right now.  I realise I should really give it more time before rejecting it entirely but I feel that would be more time wasted.  Rails doesn&amp;#39;t make me more productive, at least not right now&amp;hellip; perhaps once I repeat the same steps over and over and they become natural I&amp;#39;ll see a greater boost in productivity (Ruby on the other hand felt natural and great right away).  Perhaps if I shun the generators and roll my own stuff then I&amp;#39;ll be more productive - but then why not use another framework that comes without all the gubbins I don&amp;#39;t need?  Sinatra is nice and simple and I can build upon it rather than breakling it apart.  &lt;a href="http://ramaze.net/"&gt;Ramaze&lt;/a&gt; seems like a great &amp;ldquo;next step up&amp;rdquo; from Sinatra but without as much (perceived) bloat as Rails.  I&amp;#39;ve also followed the recent &lt;a href="http://www.kickstarter.com/projects/1397300529/railsapp"&gt;Kickstarter debacle&lt;/a&gt; from Yehuda - and I agree with him and his mission.&lt;/p&gt;

&lt;p&gt;So what I am trying to say is - if you are a person wanting to give the Ruby world a fair shake - DONT start on Rails.  Start simpler and later, if you want, when you&amp;#39;ve been throughly sold on the Ruby way, try Rails to see what you think.  Start with Ruby, port some code, write a Sinatra app, watch the &lt;a href="http://railscasts.com/"&gt;Railscasts&lt;/a&gt; as they are amazing then consider immersing yourself in Rails.&lt;/p&gt;

&lt;h2&gt;Educate Me&lt;/h2&gt;

&lt;p&gt;Finally - educate me.  I&amp;#39;m not some sort of oracle proclaiming the death of a framework that thousands of people love.  I&amp;#39;m not going to make anyone stop and think &amp;ldquo;I&amp;#39;ve been doing wrong all my life - screw Rails&amp;rdquo;.  If I&amp;#39;m wrong - tell me.  If you think I need to give Rails another look - tell me why, tell me how.  If you care - show me what I&amp;#39;m missing.&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;WARNING!!! - a negative opinion on Rails lies ahead.  Everything here needs to be taken with an &lt;strong&gt;IMHO&lt;/strong&gt; and, if you feel so inclined, tell me to go mind my own business.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I know I&amp;#39;m stepping into very dangerous territory here but I&amp;#39;ve come to the very solid conclusion that &lt;a href="http://rubyonrails.org/"&gt;Rails&lt;/a&gt;, Ruby&amp;#39;s heavily opinionated web framework, is not the gateway drug people claim.  I&amp;#39;ve heard the claims that if you give &lt;a href="http://rubyonrails.org/"&gt;Rails&lt;/a&gt; a try, coming from some other web stack on any other language, you&amp;#39;ll fall in love with Ruby and Rails and write a big long blog post about how you are leaving .NET (or Java or whatever) behind.  I really dont get it&amp;hellip;. the only feeling that Rails leaves me with - having been using it in anger for about a month now - is frustration.  But before you drive rusty nails into my hands and feet let me at least explain where I am coming from.&lt;/p&gt;

&lt;h2&gt;Previous attempts&lt;/h2&gt;

&lt;p&gt;I&amp;#39;ve been binging on Ruby for the last few months but this hasn&amp;#39;t been my first time - it&amp;#39;s been my only successful time but certianly not my first.  A year previous I had given Ruby/Rails a shot and it never stuck (in fact not once but at least twice).  Coming from a predominantly .NET/ASP.NET MVC background I decided the best approach would be to cut my teeth on a medium sized web based project and therefore jumped right into Rails.  It only took a short time before the whole effort felt like a slog full of weird semi-magic behaviour.  I gave up.&lt;/p&gt;

&lt;h2&gt;Doing things differently&lt;/h2&gt;

&lt;p&gt;This time around I decided to do things a little differently - rather than run with a web project I just tinkered with the language and eventually tried porting a &lt;a href="http://yobriefca.se/blog/2012/03/12/sentamentalizer/"&gt;.NET project over to Ruby&lt;/a&gt;.  Fair bit of Ruby code and a small &lt;a href="http://sinatrarb.com"&gt;sinatra&lt;/a&gt; app later - it clicked.  I got the whole Ruby love affair, it was lovely and I was three lines into my &lt;em&gt;&amp;ldquo;F**k you .NET, you&amp;#39;re worse than Java and I hate you and you smell&amp;rdquo;&lt;/em&gt; blog post (not factual!!) when I realised I needed to give Ruby more time to bed in and, out of fairness, I had to at least experience Rails.  &lt;/p&gt;

&lt;h2&gt;Present Day&lt;/h2&gt;

&lt;p&gt;And with that I discovered that Rails had been my problem.  I find it incredibly frustrating.  I don&amp;#39;t want to dive into bashing Rails, thats not my intent, - I&amp;#39;m sure people find it really productive - but it&amp;#39;s not for me.  So here is a very high level executive summary of the problems I&amp;#39;ve had with Rails&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Command Line Interface&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The CLI stuff has just a little bit too many features and options that make it a difficult thing to approach without extensive research.  When I watched some of the &lt;a href="http://railscasts.com/"&gt;Railscasts&lt;/a&gt; I found myself going &amp;ldquo;wait, HOW did he do that?&amp;rdquo; more than once.  Choice is good but surely Rails is supposed to be easy for the beginner?  Yet I feel the default options are not the ones I would have picked.  You know what - I want to be hand-held once in a while, I&amp;#39;m proud to admit that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Too Much Magic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rails is very heavily convention based but often there is simply too much convention and I&amp;#39;ve been left baffled a few times.  Some of the convention is well documented and some of it less so.  When a convention is not obvious it becomes magic and it really feels Rails has a lot of &amp;ldquo;magic&amp;rdquo;.  Thats not something I want.  To be honest I&amp;#39;d rather write the same 2/3 lines of boilerplate if it meant that, to a new developer, they could understand the convention better.  Take this very trivial example,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;HomeController&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;ApplicationController&lt;/span&gt;
  &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;
  &lt;span class="n"&gt;end&lt;/span&gt;
&lt;span class="n"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And the same in ASP.NET MVC&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;HomeController&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt; &lt;span class="n"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To me that one line &lt;code&gt;return View()&lt;/code&gt; tell me that this action will return a View, and now I can infer the convention of &lt;code&gt;home/index.cshtml&lt;/code&gt; that wee bit easier.  When you start adding in more conventions, a little bit of extra code makes all the difference.  Conventions don&amp;#39;t scale unless clearly marked IMHO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bloatyness&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you generate scaffold in a Rails app, as a typical new developer would, you end up with a awful lot of files.  If I generate a new entity for example this is what I am greeted with,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="nx"&gt;rails&lt;/span&gt; &lt;span class="nx"&gt;generate&lt;/span&gt; &lt;span class="nx"&gt;scaffold&lt;/span&gt; &lt;span class="nx"&gt;MyEntity&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;Int&lt;/span&gt;                         &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="mi"&gt;6580&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;  &lt;span class="nx"&gt;active_record&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;    &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;migrate&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;20120403130542&lt;/span&gt;&lt;span class="nx"&gt;_create_my_entities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;models&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;test_unit&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;unit&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entity_test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;fixtures&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;yml&lt;/span&gt;
       &lt;span class="nx"&gt;route&lt;/span&gt;  &lt;span class="nx"&gt;resources&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;  &lt;span class="nx"&gt;scaffold_controller&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;controllers&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities_controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;edit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;show&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;_form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slim&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;test_unit&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;functional&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities_controller_test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;helper&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;helpers&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities_helper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;      &lt;span class="nx"&gt;test_unit&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;        &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;unit&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;helpers&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities_helper_test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rb&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;  &lt;span class="nx"&gt;assets&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;coffee&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;javascripts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;coffee&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;    &lt;span class="nx"&gt;scss&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;      &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;stylesheets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;my_entities&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scss&lt;/span&gt;
      &lt;span class="nx"&gt;invoke&lt;/span&gt;  &lt;span class="nx"&gt;scss&lt;/span&gt;
      &lt;span class="nx"&gt;create&lt;/span&gt;    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;stylesheets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;scaffolds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scss&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Don&amp;#39;t get me wrong - it&amp;#39;s nice to be given all these things for free, but it&amp;#39;s ultimatley stuff I end up ripping out anyway.  In .NET there is a running joke that the &amp;ldquo;Empty ASP.NET MVC Project&amp;rdquo; Template is anything but.  To me this is the same issue except it&amp;#39;s something that I&amp;#39;d have to clean up everytime I use the &lt;code&gt;generate scaffold&lt;/code&gt; command.  This seems worse to me.&lt;/p&gt;

&lt;h2&gt;Current Thoughts&lt;/h2&gt;

&lt;p&gt;I&amp;#39;m not sure were Rails is supposed to stand.  I hear it&amp;#39;s great for beginners or for big sites but I couldn&amp;#39;t recommend it for either right now.  I realise I should really give it more time before rejecting it entirely but I feel that would be more time wasted.  Rails doesn&amp;#39;t make me more productive, at least not right now&amp;hellip; perhaps once I repeat the same steps over and over and they become natural I&amp;#39;ll see a greater boost in productivity (Ruby on the other hand felt natural and great right away).  Perhaps if I shun the generators and roll my own stuff then I&amp;#39;ll be more productive - but then why not use another framework that comes without all the gubbins I don&amp;#39;t need?  Sinatra is nice and simple and I can build upon it rather than breakling it apart.  &lt;a href="http://ramaze.net/"&gt;Ramaze&lt;/a&gt; seems like a great &amp;ldquo;next step up&amp;rdquo; from Sinatra but without as much (perceived) bloat as Rails.  I&amp;#39;ve also followed the recent &lt;a href="http://www.kickstarter.com/projects/1397300529/railsapp"&gt;Kickstarter debacle&lt;/a&gt; from Yehuda - and I agree with him and his mission.&lt;/p&gt;

&lt;p&gt;So what I am trying to say is - if you are a person wanting to give the Ruby world a fair shake - DONT start on Rails.  Start simpler and later, if you want, when you&amp;#39;ve been throughly sold on the Ruby way, try Rails to see what you think.  Start with Ruby, port some code, write a Sinatra app, watch the &lt;a href="http://railscasts.com/"&gt;Railscasts&lt;/a&gt; as they are amazing then consider immersing yourself in Rails.&lt;/p&gt;

&lt;h2&gt;Educate Me&lt;/h2&gt;

&lt;p&gt;Finally - educate me.  I&amp;#39;m not some sort of oracle proclaiming the death of a framework that thousands of people love.  I&amp;#39;m not going to make anyone stop and think &amp;ldquo;I&amp;#39;ve been doing wrong all my life - screw Rails&amp;rdquo;.  If I&amp;#39;m wrong - tell me.  If you think I need to give Rails another look - tell me why, tell me how.  If you care - show me what I&amp;#39;m missing.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Setting the Selected Option in a Select with Selenium in Scala</title>
    <link rel="alternate" href="/blog/2012/04/02/setting-the-selected-option-in-a-select-with-selenium-in-scala"/>
    <id>/blog/2012/04/02/setting-the-selected-option-in-a-select-with-selenium-in-scala</id>
    <published>2012-04-02T00:00:00+01:00</published>
    <updated>2012-04-02T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Almost a perfect bit of alliteration there in that title - right?  Anyway I&amp;#39;ve been doing a bit of work with bare-metal Selenium stuff in Scala recently and one of the things that kept me stumped for a while was setting the selected &lt;code&gt;option&lt;/code&gt; for a particular &lt;code&gt;select&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;I looked around the interwebs and didn&amp;#39;t really find anything - now I&amp;#39;m not saying it isn&amp;#39;t out there, I am certain it is, but I couldn&amp;#39;t find it.  So I decided to document how I did it in case any lone sole is stuck in a similar situation&amp;hellip;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;  &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;year&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;
    &lt;span class="n"&gt;findElements&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;option&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;
    &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
    &lt;span class="n"&gt;setSelected&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So here I am simply finding the second &lt;code&gt;option&lt;/code&gt; of the &amp;ldquo;year&amp;rdquo; &lt;code&gt;select&lt;/code&gt; element and setting it selected.  I know it looks obvious now but trust me I was scratching my head for an age on this one.&lt;/p&gt;

&lt;p&gt;I hope it helps some one, eventually :)&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Almost a perfect bit of alliteration there in that title - right?  Anyway I&amp;#39;ve been doing a bit of work with bare-metal Selenium stuff in Scala recently and one of the things that kept me stumped for a while was setting the selected &lt;code&gt;option&lt;/code&gt; for a particular &lt;code&gt;select&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;I looked around the interwebs and didn&amp;#39;t really find anything - now I&amp;#39;m not saying it isn&amp;#39;t out there, I am certain it is, but I couldn&amp;#39;t find it.  So I decided to document how I did it in case any lone sole is stuck in a similar situation&amp;hellip;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;  &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;year&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;
    &lt;span class="n"&gt;findElements&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;option&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;
    &lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
    &lt;span class="n"&gt;setSelected&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So here I am simply finding the second &lt;code&gt;option&lt;/code&gt; of the &amp;ldquo;year&amp;rdquo; &lt;code&gt;select&lt;/code&gt; element and setting it selected.  I know it looks obvious now but trust me I was scratching my head for an age on this one.&lt;/p&gt;

&lt;p&gt;I hope it helps some one, eventually :)&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Done Spoked at DevWeek</title>
    <link rel="alternate" href="/blog/2012/03/28/done-spoked-at-devweek"/>
    <id>/blog/2012/03/28/done-spoked-at-devweek</id>
    <published>2012-03-28T00:00:00+01:00</published>
    <updated>2012-03-28T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;So I made it through my talk at DevWeek which might sound a little odd but it took a whole bottle of cough syrup to do it.  Not having been sick for most of the winter my body decided a day before DevWeek to go into shut down.  I spent Tuesday in bed with very little voice.  Thankfully the head colds hold on my vocal chords relented this morning and I think I managed to project as best I could.  &lt;/p&gt;

&lt;p&gt;So initial thoughts of how it went?  I honestly think I&amp;#39;m getting better at this presenting thing so that must be a good thing, unless I was TERRIBLE before.  The 2 main annoyances that have been raised thus far have been&lt;/p&gt;

&lt;h2&gt;1. Too Short&lt;/h2&gt;

&lt;p&gt;I did my usual &amp;ldquo;talk really fast and finish earlier than planned&amp;rdquo; thing I sometimes do. But there was plenty of discussion afterwards which I tought was interesting.  FWIW when I present this to myself it takes longer.  My internal monologue must be slower than the way I speak.  Apologies to anyone that felt it was &amp;ldquo;too short&amp;rdquo;.&lt;/p&gt;

&lt;h2&gt;2. Not enough Visual Studio&lt;/h2&gt;

&lt;p&gt;I opted to play it safe end embed code into my slides rather than code live - I didn&amp;#39;t go unnoticed and I had a few comments that &amp;ldquo;moar codez&amp;rdquo; would have been good.  Totally agree.  &lt;/p&gt;

&lt;h2&gt;Other Stuff&lt;/h2&gt;

&lt;p&gt;I opted to change my slide deck between submitting them for print and presenting.  I did it out of desire to devlier a better, more structured, talk (my first set being quite short as I was going for a &amp;ldquo;free-form&amp;rdquo; type of presentation).  Probably not the most professional approach to do this but at least I can say my heart was in the right place :)  Here are offending articles BTW&lt;/p&gt;

&lt;div style="max-width:500px;margin:0 auto;"&gt;
    &lt;script src="http://speakerdeck.com/embed/4f719e7aca692c002101c187.js"&gt;&lt;/script&gt;
&lt;/div&gt;

&lt;p&gt;Code that was presented is available, as always, in/on my &lt;a href="https://github.com/kouphax/bddindotnet-code"&gt;Github Repo&lt;/a&gt;.  Thanks to all who attended and any other feedback you have throw it my way so I can get better at this talking malarky.&lt;/p&gt;

&lt;p&gt;Also thanks to the folks at DevWeek for the opportunity - hopefully you&amp;#39;ll have me back at some point.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;So I made it through my talk at DevWeek which might sound a little odd but it took a whole bottle of cough syrup to do it.  Not having been sick for most of the winter my body decided a day before DevWeek to go into shut down.  I spent Tuesday in bed with very little voice.  Thankfully the head colds hold on my vocal chords relented this morning and I think I managed to project as best I could.  &lt;/p&gt;

&lt;p&gt;So initial thoughts of how it went?  I honestly think I&amp;#39;m getting better at this presenting thing so that must be a good thing, unless I was TERRIBLE before.  The 2 main annoyances that have been raised thus far have been&lt;/p&gt;

&lt;h2&gt;1. Too Short&lt;/h2&gt;

&lt;p&gt;I did my usual &amp;ldquo;talk really fast and finish earlier than planned&amp;rdquo; thing I sometimes do. But there was plenty of discussion afterwards which I tought was interesting.  FWIW when I present this to myself it takes longer.  My internal monologue must be slower than the way I speak.  Apologies to anyone that felt it was &amp;ldquo;too short&amp;rdquo;.&lt;/p&gt;

&lt;h2&gt;2. Not enough Visual Studio&lt;/h2&gt;

&lt;p&gt;I opted to play it safe end embed code into my slides rather than code live - I didn&amp;#39;t go unnoticed and I had a few comments that &amp;ldquo;moar codez&amp;rdquo; would have been good.  Totally agree.  &lt;/p&gt;

&lt;h2&gt;Other Stuff&lt;/h2&gt;

&lt;p&gt;I opted to change my slide deck between submitting them for print and presenting.  I did it out of desire to devlier a better, more structured, talk (my first set being quite short as I was going for a &amp;ldquo;free-form&amp;rdquo; type of presentation).  Probably not the most professional approach to do this but at least I can say my heart was in the right place :)  Here are offending articles BTW&lt;/p&gt;

&lt;div style="max-width:500px;margin:0 auto;"&gt;
    &lt;script src="http://speakerdeck.com/embed/4f719e7aca692c002101c187.js"&gt;&lt;/script&gt;
&lt;/div&gt;

&lt;p&gt;Code that was presented is available, as always, in/on my &lt;a href="https://github.com/kouphax/bddindotnet-code"&gt;Github Repo&lt;/a&gt;.  Thanks to all who attended and any other feedback you have throw it my way so I can get better at this talking malarky.&lt;/p&gt;

&lt;p&gt;Also thanks to the folks at DevWeek for the opportunity - hopefully you&amp;#39;ll have me back at some point.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Behaviour Driven (Development|Design) in .NET</title>
    <link rel="alternate" href="http://speakerdeck.com/u/kouphax/p/bdd-in-net"/>
    <id>http://speakerdeck.com/u/kouphax/p/bdd-in-net</id>
    <published>2012-03-28T00:00:00+01:00</published>
    <updated>2012-03-28T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>rbenv and CodeRunner</title>
    <link rel="alternate" href="/blog/2012/03/22/rbenv-and-coderunner"/>
    <id>/blog/2012/03/22/rbenv-and-coderunner</id>
    <published>2012-03-22T00:00:00+00:00</published>
    <updated>2012-03-22T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;You know &lt;a href="http://krillapps.com/coderunner/"&gt;CodeRunner&lt;/a&gt; right?  If not maybe you should go check it out.  It&amp;#39;s and aptly named little tool for running code snippets in various languages much like what &lt;a href="http://www.linqpad.net/"&gt;LinqPad&lt;/a&gt; does for the .NET folks.  I&amp;#39;ve been using it extensivley recently to test out little Ruby and Scala snippets.  Thing is though - I hit a snag.  By default CodeRunner will run the system ruby executable (1.8 in OSX) and I generally use &lt;a href="https://github.com/sstephenson/rbenv"&gt;rbenv&lt;/a&gt; along with version 1.9.whatever so some of my scripts started behaving a little&amp;hellip; odd.&lt;/p&gt;

&lt;p&gt;But hey it&amp;#39;s an easy fix,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your CodeRunner Preferences&lt;/li&gt;
&lt;li&gt;Select the Languages tab&lt;/li&gt;
&lt;li&gt;Select Ruby in the Language List&lt;/li&gt;
&lt;li&gt;Change the run command from &lt;code&gt;ruby $filename&lt;/code&gt; to &lt;code&gt;~/.rbenv/shims/ruby $filename&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Before&lt;/h2&gt;

&lt;p&gt;&lt;img src="/images/blog/coderunnerruby/before.png?1368558404" /&gt;&lt;/p&gt;

&lt;h2&gt;After&lt;/h2&gt;

&lt;p&gt;&lt;img src="/images/blog/coderunnerruby/after.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Blam - global rbenv version is now the goto version for CodeRunner.  OK so it won&amp;#39;t work with rbenv locals but I am sure you can tweak it to make it work (I haven&amp;#39;t needed it so never looked).&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;You know &lt;a href="http://krillapps.com/coderunner/"&gt;CodeRunner&lt;/a&gt; right?  If not maybe you should go check it out.  It&amp;#39;s and aptly named little tool for running code snippets in various languages much like what &lt;a href="http://www.linqpad.net/"&gt;LinqPad&lt;/a&gt; does for the .NET folks.  I&amp;#39;ve been using it extensivley recently to test out little Ruby and Scala snippets.  Thing is though - I hit a snag.  By default CodeRunner will run the system ruby executable (1.8 in OSX) and I generally use &lt;a href="https://github.com/sstephenson/rbenv"&gt;rbenv&lt;/a&gt; along with version 1.9.whatever so some of my scripts started behaving a little&amp;hellip; odd.&lt;/p&gt;

&lt;p&gt;But hey it&amp;#39;s an easy fix,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your CodeRunner Preferences&lt;/li&gt;
&lt;li&gt;Select the Languages tab&lt;/li&gt;
&lt;li&gt;Select Ruby in the Language List&lt;/li&gt;
&lt;li&gt;Change the run command from &lt;code&gt;ruby $filename&lt;/code&gt; to &lt;code&gt;~/.rbenv/shims/ruby $filename&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Before&lt;/h2&gt;

&lt;p&gt;&lt;img src="/images/blog/coderunnerruby/before.png?1368558404" /&gt;&lt;/p&gt;

&lt;h2&gt;After&lt;/h2&gt;

&lt;p&gt;&lt;img src="/images/blog/coderunnerruby/after.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Blam - global rbenv version is now the goto version for CodeRunner.  OK so it won&amp;#39;t work with rbenv locals but I am sure you can tweak it to make it work (I haven&amp;#39;t needed it so never looked).&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Slim Generator for Octopress</title>
    <link rel="alternate" href="/blog/2012/03/22/slim-generator-for-octopress"/>
    <id>/blog/2012/03/22/slim-generator-for-octopress</id>
    <published>2012-03-22T00:00:00+00:00</published>
    <updated>2012-03-22T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;So I&amp;#39;ve been overhauling my web site, which is based on &lt;a href="http://octopress.org"&gt;Octopress&lt;/a&gt;, lately and have had to jump into the working of Octopress/Jekyll.  It&amp;#39;s obviously not the most complicated system in the world but hey it was new to me.&lt;/p&gt;

&lt;p&gt;Anyway my current setup features a lot of html based pages (the default markdown approach didn&amp;#39;t fit due to styling needs) and it was getting rather noisy.  So I wrote, as there didn&amp;#39;t seem to be one out there, a &lt;a href="http://slim-lang.com/"&gt;Slim&lt;/a&gt; generator.  And here it is,  step back it&amp;#39;s VERY COMPLEX&amp;hellip;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;module&lt;/span&gt; &lt;span class="n"&gt;Jekyll&lt;/span&gt;
  &lt;span class="n"&gt;require&lt;/span&gt; &lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;slim&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;
  &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;SlimConverter&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;Converter&lt;/span&gt;
    &lt;span class="n"&gt;safe&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
    &lt;span class="n"&gt;priority&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;

    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;ext&lt;/span&gt; &lt;span class="o"&gt;=~&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;slim&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="n"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;output_ext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;.html&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;begin&lt;/span&gt;
        &lt;span class="n"&gt;Slim&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Template&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="p"&gt;}.&lt;/span&gt;&lt;span class="n"&gt;render&lt;/span&gt;
      &lt;span class="n"&gt;rescue&lt;/span&gt; &lt;span class="n"&gt;StandardError&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;
        &lt;span class="n"&gt;puts&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;!!! SLIM Error: &amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;
      &lt;span class="n"&gt;end&lt;/span&gt;
    &lt;span class="n"&gt;end&lt;/span&gt;
  &lt;span class="n"&gt;end&lt;/span&gt;
&lt;span class="n"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Just drop this file (call it anything) into your plugins folder in Jekyll/Octopress and any file with the &lt;code&gt;slim&lt;/code&gt; extension will use this converter to generate HTML.  No more noisy HTML for me!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;So I&amp;#39;ve been overhauling my web site, which is based on &lt;a href="http://octopress.org"&gt;Octopress&lt;/a&gt;, lately and have had to jump into the working of Octopress/Jekyll.  It&amp;#39;s obviously not the most complicated system in the world but hey it was new to me.&lt;/p&gt;

&lt;p&gt;Anyway my current setup features a lot of html based pages (the default markdown approach didn&amp;#39;t fit due to styling needs) and it was getting rather noisy.  So I wrote, as there didn&amp;#39;t seem to be one out there, a &lt;a href="http://slim-lang.com/"&gt;Slim&lt;/a&gt; generator.  And here it is,  step back it&amp;#39;s VERY COMPLEX&amp;hellip;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;module&lt;/span&gt; &lt;span class="n"&gt;Jekyll&lt;/span&gt;
  &lt;span class="n"&gt;require&lt;/span&gt; &lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="n"&gt;slim&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;
  &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;SlimConverter&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;Converter&lt;/span&gt;
    &lt;span class="n"&gt;safe&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
    &lt;span class="n"&gt;priority&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;

    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;ext&lt;/span&gt; &lt;span class="o"&gt;=~&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;slim&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="n"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;output_ext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="s"&gt;&amp;quot;.html&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;def&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;begin&lt;/span&gt;
        &lt;span class="n"&gt;Slim&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Template&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="p"&gt;}.&lt;/span&gt;&lt;span class="n"&gt;render&lt;/span&gt;
      &lt;span class="n"&gt;rescue&lt;/span&gt; &lt;span class="n"&gt;StandardError&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;
        &lt;span class="n"&gt;puts&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;!!! SLIM Error: &amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;
      &lt;span class="n"&gt;end&lt;/span&gt;
    &lt;span class="n"&gt;end&lt;/span&gt;
  &lt;span class="n"&gt;end&lt;/span&gt;
&lt;span class="n"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Just drop this file (call it anything) into your plugins folder in Jekyll/Octopress and any file with the &lt;code&gt;slim&lt;/code&gt; extension will use this converter to generate HTML.  No more noisy HTML for me!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Tinkering with Spark: A Micro Web Framework for Java</title>
    <link rel="alternate" href="/blog/2012/03/20/tinkering-with-spark-a-micro-web-framework-for-java"/>
    <id>/blog/2012/03/20/tinkering-with-spark-a-micro-web-framework-for-java</id>
    <published>2012-03-20T00:00:00+00:00</published>
    <updated>2012-03-20T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;div style="text-align:center;margin-bottom:20px;"&gt;
&lt;img src="/images/blog/spark_logo_blue.png" style="border:none; box-shadow:none; -webkit-box-shadow:none;" /&gt;
&lt;/div&gt;

&lt;p&gt;You can&amp;#39;t call yourself a language these days without having your own &lt;a href="http://sinatrarb.com"&gt;Sinatra&lt;/a&gt; clone.  Not even, it seems, if you are Java.  I know - it sounds odd that Java, the language that turns XML into stacktraces, has a micro web framework of it&amp;#39;s own - &lt;a href="http://sparkjava.com"&gt;Spark&lt;/a&gt;.  I&amp;#39;m well aware as of JRE 1.6 has a built in &lt;code&gt;HttpServer&lt;/code&gt; class but there is such as thing as &lt;strong&gt;too close&lt;/strong&gt; to the metal :)  Also Sparks logo is fairly epic.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://sparkjava.com"&gt;Spark&lt;/a&gt;&amp;#39;s site has a great little piece about the &amp;ldquo;why&amp;rdquo; and that is what stuck with me.  Especially this bit,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Its intention is to be used by Java developers that want or are required to develop in pure Java. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I know a few people who are &amp;ldquo;required&amp;rdquo; to develop in pure Java and anything that might make their lives easier would be welcomed.  Being completely out of loop with Java since before Maven made an appearance I had a lot of catching up to do just to get the project running.  In fact I went with SBT as it made things a lot easier for me and my mavenless brain.  I did have to tinker with the dependencies in the &lt;code&gt;ivy2&lt;/code&gt; directory due to a &lt;a href="https://github.com/perwendel/spark/pull/15"&gt;known issue&lt;/a&gt; but if I can do it anyone interested in this can to - if not give me a shout.&lt;/p&gt;

&lt;h2&gt;App.java&lt;/h2&gt;

&lt;p&gt;A Spark app simply uses &lt;code&gt;main&lt;/code&gt; as an entry point.  Within the method you can call certain methods to set up routes and filters and whatnots that your app will respond to.  For example&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;spark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Spark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;spark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;App&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Standard Java stuff here, bringing in some of the necessary &lt;code&gt;spark&lt;/code&gt; resources,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="n"&gt;before&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;Override&lt;/span&gt;
      &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;queryParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;password&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;secret&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;authenticated&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
          &lt;span class="n"&gt;halt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Incorrect password, hacker alert, hacker alert!!!!&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Spark allows us to define filters that run before and after requests.  It is also possbile to restrict them to certain routes or simply catch all routes - for example my filter only matches the &amp;ldquo;/&amp;rdquo; route.  A couple of other things are worth mentioning here,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;Request&lt;/code&gt; object gives you access to many things you would expect i.e. the query parameters.  It gives you so much more than this but I&amp;#39;ll leave the &lt;a href="http://www.sparkjava.com/readme.html#title2"&gt;docs&lt;/a&gt; to describe this.&lt;/li&gt;
&lt;li&gt;Just like in Sinatra it is possible to simply &lt;code&gt;halt&lt;/code&gt; the request chain at any time.  Here I am halting execution unless the request conforms to my very strict and highly secure authentication scheme.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="nb"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;Override&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Object&lt;/span&gt; &lt;span class="k"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Response&lt;/span&gt; &lt;span class="nb"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="c1"&gt;// extract the name from the request&lt;/span&gt;
        &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;request.queryParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// set the response type&lt;/span&gt;
        &lt;span class="nx"&gt;response.type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;text/html&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// return some html&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;&amp;lt;DOCTYPE html&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;&amp;lt;html&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;  &amp;lt;head&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;  &amp;lt;/head&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;  &amp;lt;body&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;    &amp;lt;h1&amp;gt;Hello &amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;, Spark here.  Howrya?&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;  &amp;lt;/body&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;&amp;lt;/html&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally I am defining a route (&amp;ldquo;/&amp;rdquo;) that responds to the GET verb and introspects the query parameters returning a very complex view.  Routes can also be parameterized (&lt;code&gt;/user/:name&lt;/code&gt; for example). Even given the slightly verbose nature of Java syntax this example seems clean enough (albeit a rather simple example).&lt;/p&gt;

&lt;h2&gt;SBT Build File&lt;/h2&gt;

&lt;p&gt;For the curious among you (you got this far so you must be slightly curious&amp;hellip; and rather odd) the SBT file required to get this bad boy running is nice and simple,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Spark Repository&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;http://www.sparkjava.com/nexus/content/repositories/spark/&amp;quot;&lt;/span&gt;

&lt;span class="n"&gt;libraryDependencies&lt;/span&gt; &lt;span class="o"&gt;++=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;spark&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;spark&amp;quot;&lt;/span&gt;  &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;0.9.9.3-SNAPSHOT&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;exclude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;org.apache.commons&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;commons-io&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A quick &lt;code&gt;sbt run&lt;/code&gt; command and we are running a standalone Spark app (powered by an embedded Jetty server).  Aces.&lt;/p&gt;

&lt;h2&gt;Mopping Up&lt;/h2&gt;

&lt;p&gt;OK so thats the basics of the framework but then again there really isn&amp;#39;t much other stuff besides picking a port and redirecting.  This means there is some things still missing that would really make this framework really stand out,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;View rendering.  Even if it is just plain HTML it would be a big leap forward (turns out an &lt;a href="https://github.com/perwendel/spark/issues/1"&gt;issue&lt;/a&gt; is already open too).&lt;br&gt;&lt;/li&gt;
&lt;li&gt;Static Content.  Would be nice to define a rule for serving static content without having to define a route or filter manually&lt;/li&gt;
&lt;li&gt;Session support.  Again an &lt;a href="https://github.com/perwendel/spark/pull/12"&gt;issue and pull request&lt;/a&gt; is already available for this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Good work &lt;a href="https://github.com/perwendel/"&gt;perwendel&lt;/a&gt; keep it up :)&lt;/p&gt;

&lt;p&gt;As always my code samples are available on &lt;a href="https://github.com/kouphax/spark-tinkering"&gt;Github&lt;/a&gt;.&lt;/p&gt;
</summary>
    <content type="html">&lt;div style="text-align:center;margin-bottom:20px;"&gt;
&lt;img src="/images/blog/spark_logo_blue.png" style="border:none; box-shadow:none; -webkit-box-shadow:none;" /&gt;
&lt;/div&gt;

&lt;p&gt;You can&amp;#39;t call yourself a language these days without having your own &lt;a href="http://sinatrarb.com"&gt;Sinatra&lt;/a&gt; clone.  Not even, it seems, if you are Java.  I know - it sounds odd that Java, the language that turns XML into stacktraces, has a micro web framework of it&amp;#39;s own - &lt;a href="http://sparkjava.com"&gt;Spark&lt;/a&gt;.  I&amp;#39;m well aware as of JRE 1.6 has a built in &lt;code&gt;HttpServer&lt;/code&gt; class but there is such as thing as &lt;strong&gt;too close&lt;/strong&gt; to the metal :)  Also Sparks logo is fairly epic.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://sparkjava.com"&gt;Spark&lt;/a&gt;&amp;#39;s site has a great little piece about the &amp;ldquo;why&amp;rdquo; and that is what stuck with me.  Especially this bit,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Its intention is to be used by Java developers that want or are required to develop in pure Java. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I know a few people who are &amp;ldquo;required&amp;rdquo; to develop in pure Java and anything that might make their lives easier would be welcomed.  Being completely out of loop with Java since before Maven made an appearance I had a lot of catching up to do just to get the project running.  In fact I went with SBT as it made things a lot easier for me and my mavenless brain.  I did have to tinker with the dependencies in the &lt;code&gt;ivy2&lt;/code&gt; directory due to a &lt;a href="https://github.com/perwendel/spark/pull/15"&gt;known issue&lt;/a&gt; but if I can do it anyone interested in this can to - if not give me a shout.&lt;/p&gt;

&lt;h2&gt;App.java&lt;/h2&gt;

&lt;p&gt;A Spark app simply uses &lt;code&gt;main&lt;/code&gt; as an entry point.  Within the method you can call certain methods to set up routes and filters and whatnots that your app will respond to.  For example&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;spark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Spark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;spark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;App&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Standard Java stuff here, bringing in some of the necessary &lt;code&gt;spark&lt;/code&gt; resources,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="n"&gt;before&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="n"&gt;Override&lt;/span&gt;
      &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;authenticated&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;queryParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;password&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;secret&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;authenticated&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
          &lt;span class="n"&gt;halt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;403&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Incorrect password, hacker alert, hacker alert!!!!&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Spark allows us to define filters that run before and after requests.  It is also possbile to restrict them to certain routes or simply catch all routes - for example my filter only matches the &amp;ldquo;/&amp;rdquo; route.  A couple of other things are worth mentioning here,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;Request&lt;/code&gt; object gives you access to many things you would expect i.e. the query parameters.  It gives you so much more than this but I&amp;#39;ll leave the &lt;a href="http://www.sparkjava.com/readme.html#title2"&gt;docs&lt;/a&gt; to describe this.&lt;/li&gt;
&lt;li&gt;Just like in Sinatra it is possible to simply &lt;code&gt;halt&lt;/code&gt; the request chain at any time.  Here I am halting execution unless the request conforms to my very strict and highly secure authentication scheme.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="nb"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nx"&gt;Override&lt;/span&gt;
      &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Object&lt;/span&gt; &lt;span class="k"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Response&lt;/span&gt; &lt;span class="nb"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="c1"&gt;// extract the name from the request&lt;/span&gt;
        &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;request.queryParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// set the response type&lt;/span&gt;
        &lt;span class="nx"&gt;response.type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;text/html&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// return some html&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;&amp;lt;DOCTYPE html&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;&amp;lt;html&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;  &amp;lt;head&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;  &amp;lt;/head&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;  &amp;lt;body&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;    &amp;lt;h1&amp;gt;Hello &amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;, Spark here.  Howrya?&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;  &amp;lt;/body&amp;gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
          &lt;span class="s2"&gt;&amp;quot;&amp;lt;/html&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally I am defining a route (&amp;ldquo;/&amp;rdquo;) that responds to the GET verb and introspects the query parameters returning a very complex view.  Routes can also be parameterized (&lt;code&gt;/user/:name&lt;/code&gt; for example). Even given the slightly verbose nature of Java syntax this example seems clean enough (albeit a rather simple example).&lt;/p&gt;

&lt;h2&gt;SBT Build File&lt;/h2&gt;

&lt;p&gt;For the curious among you (you got this far so you must be slightly curious&amp;hellip; and rather odd) the SBT file required to get this bad boy running is nice and simple,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;resolvers&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Spark Repository&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;http://www.sparkjava.com/nexus/content/repositories/spark/&amp;quot;&lt;/span&gt;

&lt;span class="n"&gt;libraryDependencies&lt;/span&gt; &lt;span class="o"&gt;++=&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;spark&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;spark&amp;quot;&lt;/span&gt;  &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;0.9.9.3-SNAPSHOT&amp;quot;&lt;/span&gt; &lt;span class="n"&gt;exclude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;org.apache.commons&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;commons-io&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A quick &lt;code&gt;sbt run&lt;/code&gt; command and we are running a standalone Spark app (powered by an embedded Jetty server).  Aces.&lt;/p&gt;

&lt;h2&gt;Mopping Up&lt;/h2&gt;

&lt;p&gt;OK so thats the basics of the framework but then again there really isn&amp;#39;t much other stuff besides picking a port and redirecting.  This means there is some things still missing that would really make this framework really stand out,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;View rendering.  Even if it is just plain HTML it would be a big leap forward (turns out an &lt;a href="https://github.com/perwendel/spark/issues/1"&gt;issue&lt;/a&gt; is already open too).&lt;br&gt;&lt;/li&gt;
&lt;li&gt;Static Content.  Would be nice to define a rule for serving static content without having to define a route or filter manually&lt;/li&gt;
&lt;li&gt;Session support.  Again an &lt;a href="https://github.com/perwendel/spark/pull/12"&gt;issue and pull request&lt;/a&gt; is already available for this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Good work &lt;a href="https://github.com/perwendel/"&gt;perwendel&lt;/a&gt; keep it up :)&lt;/p&gt;

&lt;p&gt;As always my code samples are available on &lt;a href="https://github.com/kouphax/spark-tinkering"&gt;Github&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Speaking at NDC Oslo</title>
    <link rel="alternate" href="/blog/2012/03/19/speaking-at-ndc-oslo"/>
    <id>/blog/2012/03/19/speaking-at-ndc-oslo</id>
    <published>2012-03-19T00:00:00+00:00</published>
    <updated>2012-03-19T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;img src="/images/blog/ndc.png" style="border:none; box-shadow:none; -webkit-box-shadow:none; width:100%;" /&gt;&lt;/p&gt;

&lt;p&gt;Mike Cohn, Dan North, Robert C. Martin, Udi Dahan, Gojko Adzic, Billy Hollis, Laurent Bugnion, Venkat Subramaniam, Brad Wilson, Phil Haack, Rob Conery, Greg Young, Zach Holman&amp;hellip;.. and then me.  So someone was drinking when deciding the line up for NDC Oslo right?&lt;/p&gt;

&lt;p&gt;Seriously though I&amp;#39;ve been given one of the best opportunites of my career to talk alongside some of the shining lights of our industry at NDC Oslo so I better not drop the ball.  Thank you to whoever gave me the opportunity.  But hey if I mess up I&amp;#39;ve got another 2 shots at it&amp;hellip; thats right I&amp;#39;m speaking not once, not twice but thrice.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://ndcoslo.oktaset.com/t-4960"&gt;.NET On a Diet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ndcoslo.oktaset.com/t-4961"&gt;MonoTouch - C# + iOS = Good Times&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ndcoslo.oktaset.com/t-4872"&gt;Mobile, How Do I Develop Thee? Let Me Count the Ways&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Still blown away by this, if you can&amp;#39;t tell - given the calibre of people talking this is going to be a highlight of the year for sure.  Also it couldn&amp;#39;t have come at a better time - there is so much I&amp;#39;ve wanted to say about things like the OSS world in .NET, Mono and mobile development. Now I&amp;#39;ve got the perfect opportunity.&lt;/p&gt;

&lt;p&gt;Now whats this .NET thing I keep hearing about :)&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;img src="/images/blog/ndc.png" style="border:none; box-shadow:none; -webkit-box-shadow:none; width:100%;" /&gt;&lt;/p&gt;

&lt;p&gt;Mike Cohn, Dan North, Robert C. Martin, Udi Dahan, Gojko Adzic, Billy Hollis, Laurent Bugnion, Venkat Subramaniam, Brad Wilson, Phil Haack, Rob Conery, Greg Young, Zach Holman&amp;hellip;.. and then me.  So someone was drinking when deciding the line up for NDC Oslo right?&lt;/p&gt;

&lt;p&gt;Seriously though I&amp;#39;ve been given one of the best opportunites of my career to talk alongside some of the shining lights of our industry at NDC Oslo so I better not drop the ball.  Thank you to whoever gave me the opportunity.  But hey if I mess up I&amp;#39;ve got another 2 shots at it&amp;hellip; thats right I&amp;#39;m speaking not once, not twice but thrice.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://ndcoslo.oktaset.com/t-4960"&gt;.NET On a Diet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ndcoslo.oktaset.com/t-4961"&gt;MonoTouch - C# + iOS = Good Times&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ndcoslo.oktaset.com/t-4872"&gt;Mobile, How Do I Develop Thee? Let Me Count the Ways&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Still blown away by this, if you can&amp;#39;t tell - given the calibre of people talking this is going to be a highlight of the year for sure.  Also it couldn&amp;#39;t have come at a better time - there is so much I&amp;#39;ve wanted to say about things like the OSS world in .NET, Mono and mobile development. Now I&amp;#39;ve got the perfect opportunity.&lt;/p&gt;

&lt;p&gt;Now whats this .NET thing I keep hearing about :)&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>sentimentalizer: A Ruby port of Sentan</title>
    <link rel="alternate" href="/blog/2012/03/12/sentimentalizer-a-ruby-port-of-sentan"/>
    <id>/blog/2012/03/12/sentimentalizer-a-ruby-port-of-sentan</id>
    <published>2012-03-12T00:00:00+00:00</published>
    <updated>2012-03-12T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;In a bid to be at least 1% less stupid I decided to jump into Ruby.  Properly this time, no tinkering with Rails or watching a few videos.  So the first thing I did was take &lt;a href="https://twitter.com/#!/martinrue"&gt;@martinrue&lt;/a&gt;&amp;#39;s &lt;a href="https://github.com/martinrue/Sentan"&gt;Sentan&lt;/a&gt; project, fork it, made it run on mono (just because), ported it over to Ruby and renamed it &lt;a href="https://github.com/kouphax/sentimentalizer/"&gt;sentimentalizer&lt;/a&gt; (but keeping all necessary attribution to Martins work in the README of course).&amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt;  I did this for two reasons,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I wanted something fairly meaty to actually port over to Ruby in an effort to get a more-than-superficial feel for the language&lt;/li&gt;
&lt;li&gt;I might have a need for such a service in an upcoming hackathon (though the original .NET version would have been fine too)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is in no way some sort of new project or intended for some production environment.&lt;/p&gt;

&lt;p&gt;So what is it?  &lt;a href="https://github.com/kouphax/sentimentalizer/"&gt;sentamentalizer&lt;/a&gt; is a quick and dirty &lt;a href="http://en.wikipedia.org/wiki/Sentiment_analysis"&gt;sentiment analysis&lt;/a&gt; tool.  With it you can loosley class statements as either positive or negative (and get a breakdown of how that classification was derived).  You &amp;ldquo;train&amp;rdquo; it with datasets for both negative and positive control statements and then feed it sentences you want analysed.  At the minute the engine sits behind a super super super, did I say super already?, simple sinatra app that you submit statements to and it returns a simple JSON response with the sentiment result (negative, positive, neutral) and probability.  If you want to train the bitch you&amp;#39;ve got to change the &lt;code&gt;api.rb&lt;/code&gt; file or update the files in the &lt;code&gt;data\positive&lt;/code&gt; and &lt;code&gt;data\negative&lt;/code&gt; folders.&lt;/p&gt;

&lt;p&gt;Plans? Yeah I might poke around some more, make into more of a standalone learning service or something (again another feature I might need soon anyway).  But for now - feel free to review my shitey code Rubyists (I assume there are better ways to do things, standard appraoches that I&amp;#39;m not using etc.) and offer suggestions.&lt;/p&gt;

&lt;p&gt;Once again thanks to &lt;a href="https://twitter.com/#!/martinrue"&gt;@martinrue&lt;/a&gt; for doing all the hard-work on &lt;a href="https://github.com/martinrue/Sentan"&gt;Sentan&lt;/a&gt; &lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;In a bid to be at least 1% less stupid I decided to jump into Ruby.  Properly this time, no tinkering with Rails or watching a few videos.  So the first thing I did was take &lt;a href="https://twitter.com/#!/martinrue"&gt;@martinrue&lt;/a&gt;&amp;#39;s &lt;a href="https://github.com/martinrue/Sentan"&gt;Sentan&lt;/a&gt; project, fork it, made it run on mono (just because), ported it over to Ruby and renamed it &lt;a href="https://github.com/kouphax/sentimentalizer/"&gt;sentimentalizer&lt;/a&gt; (but keeping all necessary attribution to Martins work in the README of course).&amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt;  I did this for two reasons,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I wanted something fairly meaty to actually port over to Ruby in an effort to get a more-than-superficial feel for the language&lt;/li&gt;
&lt;li&gt;I might have a need for such a service in an upcoming hackathon (though the original .NET version would have been fine too)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is in no way some sort of new project or intended for some production environment.&lt;/p&gt;

&lt;p&gt;So what is it?  &lt;a href="https://github.com/kouphax/sentimentalizer/"&gt;sentamentalizer&lt;/a&gt; is a quick and dirty &lt;a href="http://en.wikipedia.org/wiki/Sentiment_analysis"&gt;sentiment analysis&lt;/a&gt; tool.  With it you can loosley class statements as either positive or negative (and get a breakdown of how that classification was derived).  You &amp;ldquo;train&amp;rdquo; it with datasets for both negative and positive control statements and then feed it sentences you want analysed.  At the minute the engine sits behind a super super super, did I say super already?, simple sinatra app that you submit statements to and it returns a simple JSON response with the sentiment result (negative, positive, neutral) and probability.  If you want to train the bitch you&amp;#39;ve got to change the &lt;code&gt;api.rb&lt;/code&gt; file or update the files in the &lt;code&gt;data\positive&lt;/code&gt; and &lt;code&gt;data\negative&lt;/code&gt; folders.&lt;/p&gt;

&lt;p&gt;Plans? Yeah I might poke around some more, make into more of a standalone learning service or something (again another feature I might need soon anyway).  But for now - feel free to review my shitey code Rubyists (I assume there are better ways to do things, standard appraoches that I&amp;#39;m not using etc.) and offer suggestions.&lt;/p&gt;

&lt;p&gt;Once again thanks to &lt;a href="https://twitter.com/#!/martinrue"&gt;@martinrue&lt;/a&gt; for doing all the hard-work on &lt;a href="https://github.com/martinrue/Sentan"&gt;Sentan&lt;/a&gt; &lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Tinkering with minion.js</title>
    <link rel="alternate" href="/blog/2012/03/08/tinkering-with-minion-dot-js"/>
    <id>/blog/2012/03/08/tinkering-with-minion-dot-js</id>
    <published>2012-03-08T00:00:00+00:00</published>
    <updated>2012-03-08T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Yay a technical post&amp;hellip;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/gigafied/minion"&gt;minion.js&lt;/a&gt; is a micro framework providing classical inheritance strategy for JavaScript plus many other goodies.  It can be used in both browsers and &lt;a href="http://nodejs.org"&gt;node.js&lt;/a&gt;.&amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt;  Now I don&amp;#39;t want to get caught up in any of this classical inheritance for JavaScript is an anti-pattern stuff so just take this framework for what it is - a decent way to define both client and server side models for you JavaScripts!&lt;/p&gt;

&lt;p&gt;I&amp;#39;ve already said it has a host of goodies that can be useful for creating a nice flexible set of models and associated helpers.  This includes,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Class and inheritance support&lt;/li&gt;
&lt;li&gt;Modularity&lt;/li&gt;
&lt;li&gt;A cross model pub/sub mechanism&lt;/li&gt;
&lt;li&gt;Statics, Singletons, static methods and properties&lt;/li&gt;
&lt;li&gt;Dependency management&lt;/li&gt;
&lt;li&gt;Some other stuff I&amp;#39;ve yet to touch upon&amp;hellip;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code will more or less speak for itself here so lets dive in (the full suite of tests and sample node.js/express implementation can be found on my &lt;a href="https://github.com/kouphax/minion-tinkering"&gt;GitHub thingy&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;Classes&lt;/h2&gt;

&lt;p&gt;One of the first things I did was try out the whole inheritence thing.  I create a Fruit base class and provided a Strawberry implementation on top of it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Fruit&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;minion.Class&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nx"&gt;isInSeason&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;inSeason&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;Strawberry:&lt;/span&gt; &lt;span class="n"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;fruit.Fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;inSeason:&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using the Strawberry class is pretty damn simple.  First thing you need to do is a one off simple configuration of minion,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="n"&gt;classPath&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;js&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This just tells minions dependency manager where to start looking for your class implementations.  We can then start using the Strawberry class easily using minions &lt;code&gt;require&lt;/code&gt; method&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fruit.Strawberry&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Strawberry&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Strawberry&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;not&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;be&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Static Objects&lt;/h2&gt;

&lt;p&gt;Static objects are pre-initialised Singletons in minion.js and that makes a lot of sense.  I created a Grocer static by simply extending another minion type &lt;code&gt;Static&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Grocer&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;minion.Static&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;purchase&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buy&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="nx"&gt;sell&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="nx"&gt;buy&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="nx"&gt;checkLevels&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pretty unsuprising but minion will new up a shared instance of this class the first time it is called.  You&amp;#39;ll see a little hint of the pub/sub mechanism in the &lt;code&gt;init&lt;/code&gt; method as well so lets jump on that.&lt;/p&gt;

&lt;h2&gt;Pub/Sub&lt;/h2&gt;

&lt;p&gt;So minion has a nice little pub/sub mechanism built right into the classes as well.  So lets say a customer buys stuff from the grocer by publishing his/her request - sure beats just taking it without asking!!!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Customer&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;minion.Class&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;buy&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;publish&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;purchase&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Minion once again handles all the internal wiring up of this stuff and it just works.  Nice.&lt;/p&gt;

&lt;h2&gt;The Rest&lt;/h2&gt;

&lt;p&gt;There is more to minion.js, I&amp;#39;ve just given you a very high level view but you should dive a bit deeper by looking at the &lt;a href="https://github.com/gigafied/minion/blob/master/docs/getting_started.md"&gt;official docs&lt;/a&gt;.  There is a few bits of handy sugar sprinkled on the minion types (proxy, scoped setTimeout and setInterval).  The pub/sub also goes a bit further provinding &lt;code&gt;Notifications&lt;/code&gt; that allow a sort of async callback/response mechanism which can be handy.&lt;/p&gt;

&lt;p&gt;Now I&amp;#39;ve never been a fan of these sorts of Class frameworks - I&amp;#39;ve never really seen the need but I must admit minion appeared at about the right time.  I&amp;#39;ve been playing with a nice way of structuring &lt;a href="mongoosejs.com"&gt;mongoose&lt;/a&gt; Schemas/Classes and I think minion here might be a nice fit.&lt;/p&gt;

&lt;p&gt;Anyway check it out.  Yay a technical blog with more to come!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/gigafied/minion"&gt;minion.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/kouphax/minion-tinkering"&gt;Sample Code&lt;/a&gt;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Yay a technical post&amp;hellip;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/gigafied/minion"&gt;minion.js&lt;/a&gt; is a micro framework providing classical inheritance strategy for JavaScript plus many other goodies.  It can be used in both browsers and &lt;a href="http://nodejs.org"&gt;node.js&lt;/a&gt;.&amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt;  Now I don&amp;#39;t want to get caught up in any of this classical inheritance for JavaScript is an anti-pattern stuff so just take this framework for what it is - a decent way to define both client and server side models for you JavaScripts!&lt;/p&gt;

&lt;p&gt;I&amp;#39;ve already said it has a host of goodies that can be useful for creating a nice flexible set of models and associated helpers.  This includes,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Class and inheritance support&lt;/li&gt;
&lt;li&gt;Modularity&lt;/li&gt;
&lt;li&gt;A cross model pub/sub mechanism&lt;/li&gt;
&lt;li&gt;Statics, Singletons, static methods and properties&lt;/li&gt;
&lt;li&gt;Dependency management&lt;/li&gt;
&lt;li&gt;Some other stuff I&amp;#39;ve yet to touch upon&amp;hellip;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code will more or less speak for itself here so lets dive in (the full suite of tests and sample node.js/express implementation can be found on my &lt;a href="https://github.com/kouphax/minion-tinkering"&gt;GitHub thingy&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;Classes&lt;/h2&gt;

&lt;p&gt;One of the first things I did was try out the whole inheritence thing.  I create a Fruit base class and provided a Strawberry implementation on top of it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Fruit&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;minion.Class&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nx"&gt;isInSeason&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;inSeason&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;Strawberry:&lt;/span&gt; &lt;span class="n"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;fruit.Fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;inSeason:&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using the Strawberry class is pretty damn simple.  First thing you need to do is a one off simple configuration of minion,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="n"&gt;classPath&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;js&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This just tells minions dependency manager where to start looking for your class implementations.  We can then start using the Strawberry class easily using minions &lt;code&gt;require&lt;/code&gt; method&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fruit.Strawberry&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Strawberry&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Strawberry&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;not&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;be&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Static Objects&lt;/h2&gt;

&lt;p&gt;Static objects are pre-initialised Singletons in minion.js and that makes a lot of sense.  I created a Grocer static by simply extending another minion type &lt;code&gt;Static&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Grocer&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;minion.Static&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;purchase&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buy&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="nx"&gt;sell&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="nx"&gt;buy&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="nx"&gt;checkLevels&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pretty unsuprising but minion will new up a shared instance of this class the first time it is called.  You&amp;#39;ll see a little hint of the pub/sub mechanism in the &lt;code&gt;init&lt;/code&gt; method as well so lets jump on that.&lt;/p&gt;

&lt;h2&gt;Pub/Sub&lt;/h2&gt;

&lt;p&gt;So minion has a nice little pub/sub mechanism built right into the classes as well.  So lets say a customer buys stuff from the grocer by publishing his/her request - sure beats just taking it without asking!!!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fruit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Customer&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;minion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;minion.Class&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;buy&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;publish&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;purchase&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Minion once again handles all the internal wiring up of this stuff and it just works.  Nice.&lt;/p&gt;

&lt;h2&gt;The Rest&lt;/h2&gt;

&lt;p&gt;There is more to minion.js, I&amp;#39;ve just given you a very high level view but you should dive a bit deeper by looking at the &lt;a href="https://github.com/gigafied/minion/blob/master/docs/getting_started.md"&gt;official docs&lt;/a&gt;.  There is a few bits of handy sugar sprinkled on the minion types (proxy, scoped setTimeout and setInterval).  The pub/sub also goes a bit further provinding &lt;code&gt;Notifications&lt;/code&gt; that allow a sort of async callback/response mechanism which can be handy.&lt;/p&gt;

&lt;p&gt;Now I&amp;#39;ve never been a fan of these sorts of Class frameworks - I&amp;#39;ve never really seen the need but I must admit minion appeared at about the right time.  I&amp;#39;ve been playing with a nice way of structuring &lt;a href="mongoosejs.com"&gt;mongoose&lt;/a&gt; Schemas/Classes and I think minion here might be a nice fit.&lt;/p&gt;

&lt;p&gt;Anyway check it out.  Yay a technical blog with more to come!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/gigafied/minion"&gt;minion.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/kouphax/minion-tinkering"&gt;Sample Code&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Taking the Stairs</title>
    <link rel="alternate" href="/blog/2012/03/06/taking-the-stairs"/>
    <id>/blog/2012/03/06/taking-the-stairs</id>
    <published>2012-03-06T00:00:00+00:00</published>
    <updated>2012-03-06T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Ya&amp;#39;ll about ready for another silly analogy?  I sure am&amp;hellip;.&lt;/p&gt;

&lt;p&gt;I work on the 6th floor and recently decided to start taking the stairs.  Mostly because I&amp;#39;ve let myself go and I really need to drop a few pounds and those stairs are a bit of a hard slog.  But it&amp;#39;s worth it.  &amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt; It&amp;#39;s funny how much of a better understanding of the building layout I get by just putting in the extra effort and going up the stairs.  The stairwell itself is pretty bland but I see extra doors, and I now know were many of doors could lead.&lt;/p&gt;

&lt;p&gt;So the analogy&amp;hellip; Taking the stairs is a bit like the whole software craftsmanship thing.  Sure I could just take the prescribed route, the default stack so to speak, and as with the stairs I&amp;#39;d probably get where I was going for a lot of the time.  But you know what?  I&amp;#39;d not know much more than the average person.  What if that lift was over capacity, out of order or just smelling of urine - I&amp;#39;d be able to manage just fine without getting stranded on a random floor wondering what to do next, if that door I never tried went were I wanted.  Imagine the stress involved if I was already late for a meeting.  Crickey!&lt;/p&gt;

&lt;p&gt;So I put the extra effort in to understand things, and it&amp;#39;s already given me a better perspective on things.  It&amp;#39;s shown me other options, the ability to decide if the what I am doing is a good approach or perhaps there is a quicker, better, healthier route.&lt;/p&gt;

&lt;p&gt;How does that grab you?&lt;/p&gt;

&lt;p&gt;I really need to get off this analogy trip I&amp;#39;m on FFS!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Ya&amp;#39;ll about ready for another silly analogy?  I sure am&amp;hellip;.&lt;/p&gt;

&lt;p&gt;I work on the 6th floor and recently decided to start taking the stairs.  Mostly because I&amp;#39;ve let myself go and I really need to drop a few pounds and those stairs are a bit of a hard slog.  But it&amp;#39;s worth it.  &amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt; It&amp;#39;s funny how much of a better understanding of the building layout I get by just putting in the extra effort and going up the stairs.  The stairwell itself is pretty bland but I see extra doors, and I now know were many of doors could lead.&lt;/p&gt;

&lt;p&gt;So the analogy&amp;hellip; Taking the stairs is a bit like the whole software craftsmanship thing.  Sure I could just take the prescribed route, the default stack so to speak, and as with the stairs I&amp;#39;d probably get where I was going for a lot of the time.  But you know what?  I&amp;#39;d not know much more than the average person.  What if that lift was over capacity, out of order or just smelling of urine - I&amp;#39;d be able to manage just fine without getting stranded on a random floor wondering what to do next, if that door I never tried went were I wanted.  Imagine the stress involved if I was already late for a meeting.  Crickey!&lt;/p&gt;

&lt;p&gt;So I put the extra effort in to understand things, and it&amp;#39;s already given me a better perspective on things.  It&amp;#39;s shown me other options, the ability to decide if the what I am doing is a good approach or perhaps there is a quicker, better, healthier route.&lt;/p&gt;

&lt;p&gt;How does that grab you?&lt;/p&gt;

&lt;p&gt;I really need to get off this analogy trip I&amp;#39;m on FFS!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>The Estimation 4x4</title>
    <link rel="alternate" href="/blog/2012/02/12/the-estimation-4x4"/>
    <id>/blog/2012/02/12/the-estimation-4x4</id>
    <published>2012-02-12T00:00:00+00:00</published>
    <updated>2012-02-12T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;This post is dedicated to one of the most influential managers I&amp;#39;ve ever had the pleasure to work with.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I&amp;#39;m of the opinion that the moment you start trying to apply complex mathematical rigour and time to estimation you&amp;#39;ve entered into a broken system. &amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt; You&amp;#39;re wasting time trying to protect yourself from finger pointing managers or getting a kicking from old school &amp;ldquo;us or them&amp;rdquo; lawyer types. None of that adds anything to the project except a big stick to beat people with and make sure they work themselves to death based a a random stab in the dark that is somehow made more realistic by the application if science. Ultimately though if the initial guesswork is wrong, and it&amp;#39;s seldom on the nose, the science means sweet FA. So why bother? You&amp;#39;re pleasing the wrong people. But then those people hold a lot of power.  So as long as we can keep them happy with the minimum of effort life should be sweet.&lt;/p&gt;

&lt;h2&gt;The Answer&lt;/h2&gt;

&lt;p&gt;Ladies and gentlemen I bring you the &lt;strong&gt;Estimation 4x4&lt;/strong&gt; - guaranteed to knock those super science estimation techniques out of the park.&lt;/p&gt;

&lt;h2&gt;The Science Bit&lt;/h2&gt;

&lt;p&gt;Got a project to estimate?  I&amp;#39;ve done your homework for you - &lt;strong&gt;4 people, 4 weeks&lt;/strong&gt;.  BOOM!  Mind Blown!  Now get on with delivering that project bro.  Oh wait it&amp;#39;s a big ass project - 4 people, 4 months.  Oh wait you&amp;#39;re limited by deadlines and/or resourcing - adjust as needed (3 people, 5 weeks or 5 people, 3 weeks).&lt;/p&gt;

&lt;h2&gt;Balancing Act&lt;/h2&gt;

&lt;p&gt;Careful now, 9 women dont make a baby in 1 month so don&amp;#39;t assume that scaling one side up to cater for the other will get the same results.  Theres a balance that needs addressed.  This is real science after all - repsect the rule and the rule will respect you.&lt;/p&gt;

&lt;h2&gt;You Gotta Be Kidding Me&lt;/h2&gt;

&lt;p&gt;Dont believe me?  Try it out next time.  Do your pseudo-scientific enterprise-ready finger in the air analysis.  But hey see when that project is finished see how close the 4x4 would have brought you to the real result.  I bet 9 times out of 10 it was as accurate as your real estimate, except you could have started much sooner&amp;hellip;.&lt;/p&gt;

&lt;p&gt;#winning&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;This post is dedicated to one of the most influential managers I&amp;#39;ve ever had the pleasure to work with.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I&amp;#39;m of the opinion that the moment you start trying to apply complex mathematical rigour and time to estimation you&amp;#39;ve entered into a broken system. &amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt; You&amp;#39;re wasting time trying to protect yourself from finger pointing managers or getting a kicking from old school &amp;ldquo;us or them&amp;rdquo; lawyer types. None of that adds anything to the project except a big stick to beat people with and make sure they work themselves to death based a a random stab in the dark that is somehow made more realistic by the application if science. Ultimately though if the initial guesswork is wrong, and it&amp;#39;s seldom on the nose, the science means sweet FA. So why bother? You&amp;#39;re pleasing the wrong people. But then those people hold a lot of power.  So as long as we can keep them happy with the minimum of effort life should be sweet.&lt;/p&gt;

&lt;h2&gt;The Answer&lt;/h2&gt;

&lt;p&gt;Ladies and gentlemen I bring you the &lt;strong&gt;Estimation 4x4&lt;/strong&gt; - guaranteed to knock those super science estimation techniques out of the park.&lt;/p&gt;

&lt;h2&gt;The Science Bit&lt;/h2&gt;

&lt;p&gt;Got a project to estimate?  I&amp;#39;ve done your homework for you - &lt;strong&gt;4 people, 4 weeks&lt;/strong&gt;.  BOOM!  Mind Blown!  Now get on with delivering that project bro.  Oh wait it&amp;#39;s a big ass project - 4 people, 4 months.  Oh wait you&amp;#39;re limited by deadlines and/or resourcing - adjust as needed (3 people, 5 weeks or 5 people, 3 weeks).&lt;/p&gt;

&lt;h2&gt;Balancing Act&lt;/h2&gt;

&lt;p&gt;Careful now, 9 women dont make a baby in 1 month so don&amp;#39;t assume that scaling one side up to cater for the other will get the same results.  Theres a balance that needs addressed.  This is real science after all - repsect the rule and the rule will respect you.&lt;/p&gt;

&lt;h2&gt;You Gotta Be Kidding Me&lt;/h2&gt;

&lt;p&gt;Dont believe me?  Try it out next time.  Do your pseudo-scientific enterprise-ready finger in the air analysis.  But hey see when that project is finished see how close the 4x4 would have brought you to the real result.  I bet 9 times out of 10 it was as accurate as your real estimate, except you could have started much sooner&amp;hellip;.&lt;/p&gt;

&lt;p&gt;#winning&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Caveat Abstractor</title>
    <link rel="alternate" href="/blog/2012/02/09/caveat-abstractor"/>
    <id>/blog/2012/02/09/caveat-abstractor</id>
    <published>2012-02-09T00:00:00+00:00</published>
    <updated>2012-02-09T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;em&gt;Ramblings from 30,000ft.  The word abstraction is starting to sound odd.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every time you create an abstraction there is a very good chance you&amp;#39;ve introduced unnecessary complexity into a solution.  It should never be done alone - it should be a team decision.  The goal of an abstraction is to simplify but in its untamed natural form an abstraction will only add complexity.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;As programmers it&amp;#39;s easy to fall into the trap whereby we want the code that we write to be the last time anyone ever has to write that code again.  We dream of creating reusable works of art that ever other developer will use and never be concerned with the low level implementation ever again.&lt;/p&gt;

&lt;p&gt;This is wrong and impossible.  An anti-pattern even!&lt;/p&gt;

&lt;p&gt;It baffles me that anyone would create an abstraction that they didn&amp;#39;t have a need for at the time. It&amp;#39;s wasteful and degrades the readability, grokability and all those other good &amp;ldquo;ilities&amp;rdquo; we use.  Of course I say this like i don&amp;#39;t do it myself but I&amp;#39;d be lying to you and myself.&lt;/p&gt;

&lt;p&gt;An abstraction, by definition, is an intentional hiding of implementation and knowledge but surely understanding of these things will lead to a higher chance of success in a project?  The person that created the abstraction has that understanding but it&amp;#39;s like they dont want anyone else to know how it works.  They&amp;#39;re ready to take that secret to their grave.&lt;/p&gt;

&lt;p&gt;When you start to abstract you need to remind yourself you are building a specific solution and not a framework (unless you are of course).  Abstractions should be done only within the scope of the project and you should have a strong case to back up its creation (make the decision a team effort).  This may sound like overhead but if you find it difficult to justify the creation odds are the abstraction is unnecessary.&lt;/p&gt;

&lt;p&gt;Abstractions should not be grand, they should be light and convey their intent clearly by other people (pair programming and peer review will help weed out any verbose abstractions).&lt;/p&gt;

&lt;p&gt;If you are creating an abstraction for anything other than DRY, odds are youre probably creating it for YAGNI.  You&amp;#39;ll start considering irrelevant use cases and having to cater for insane edge cases.  This will happen even if you are taking a strong test driven approach - you&amp;#39;ll concern youself with the workings of the abstraction rather then the problem you are solving and begin creating endless &amp;ldquo;what if&amp;rdquo; tests to cater for all those &amp;ldquo;0.00000001% chance of happening&amp;rdquo; edge cases. When this happens youre going to end up in mediocrity.  Mediocre abstractions attract more abstraction.  Even in a shared codebase bad abstractions create a certain amount of implied ownership to the person that created it. Inevitably someone will come along and create an abstraction around your abstraction (even if they have access to the original source).  This in turn will likely become YAMA (Yet Another Mediocre Abstraction) attracting yet more abstraction&amp;hellip;. You can guess where I am going with that one&amp;hellip; Its abstractions all the way down and everytime you abstract you&amp;#39;ve decreased system comphension and likely destroyed another future developers soul.&lt;/p&gt;

&lt;p&gt;In the same way guns dont kill people, people do - Abstraction dont kill projects, developers do.  You&amp;#39;ve only got yourself to blame (been there done that, will be again).  A nice simple abstraction, at the right time (e.g. When needed) can be expressive and helpful but too often we put the abstraction before the need.&lt;/p&gt;

&lt;p&gt;So consider abstractions as “guilty until proven innocent” not the other way around.  Solve YOUR problem - not every other problem, not until you need to.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;Ramblings from 30,000ft.  The word abstraction is starting to sound odd.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Every time you create an abstraction there is a very good chance you&amp;#39;ve introduced unnecessary complexity into a solution.  It should never be done alone - it should be a team decision.  The goal of an abstraction is to simplify but in its untamed natural form an abstraction will only add complexity.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;As programmers it&amp;#39;s easy to fall into the trap whereby we want the code that we write to be the last time anyone ever has to write that code again.  We dream of creating reusable works of art that ever other developer will use and never be concerned with the low level implementation ever again.&lt;/p&gt;

&lt;p&gt;This is wrong and impossible.  An anti-pattern even!&lt;/p&gt;

&lt;p&gt;It baffles me that anyone would create an abstraction that they didn&amp;#39;t have a need for at the time. It&amp;#39;s wasteful and degrades the readability, grokability and all those other good &amp;ldquo;ilities&amp;rdquo; we use.  Of course I say this like i don&amp;#39;t do it myself but I&amp;#39;d be lying to you and myself.&lt;/p&gt;

&lt;p&gt;An abstraction, by definition, is an intentional hiding of implementation and knowledge but surely understanding of these things will lead to a higher chance of success in a project?  The person that created the abstraction has that understanding but it&amp;#39;s like they dont want anyone else to know how it works.  They&amp;#39;re ready to take that secret to their grave.&lt;/p&gt;

&lt;p&gt;When you start to abstract you need to remind yourself you are building a specific solution and not a framework (unless you are of course).  Abstractions should be done only within the scope of the project and you should have a strong case to back up its creation (make the decision a team effort).  This may sound like overhead but if you find it difficult to justify the creation odds are the abstraction is unnecessary.&lt;/p&gt;

&lt;p&gt;Abstractions should not be grand, they should be light and convey their intent clearly by other people (pair programming and peer review will help weed out any verbose abstractions).&lt;/p&gt;

&lt;p&gt;If you are creating an abstraction for anything other than DRY, odds are youre probably creating it for YAGNI.  You&amp;#39;ll start considering irrelevant use cases and having to cater for insane edge cases.  This will happen even if you are taking a strong test driven approach - you&amp;#39;ll concern youself with the workings of the abstraction rather then the problem you are solving and begin creating endless &amp;ldquo;what if&amp;rdquo; tests to cater for all those &amp;ldquo;0.00000001% chance of happening&amp;rdquo; edge cases. When this happens youre going to end up in mediocrity.  Mediocre abstractions attract more abstraction.  Even in a shared codebase bad abstractions create a certain amount of implied ownership to the person that created it. Inevitably someone will come along and create an abstraction around your abstraction (even if they have access to the original source).  This in turn will likely become YAMA (Yet Another Mediocre Abstraction) attracting yet more abstraction&amp;hellip;. You can guess where I am going with that one&amp;hellip; Its abstractions all the way down and everytime you abstract you&amp;#39;ve decreased system comphension and likely destroyed another future developers soul.&lt;/p&gt;

&lt;p&gt;In the same way guns dont kill people, people do - Abstraction dont kill projects, developers do.  You&amp;#39;ve only got yourself to blame (been there done that, will be again).  A nice simple abstraction, at the right time (e.g. When needed) can be expressive and helpful but too often we put the abstraction before the need.&lt;/p&gt;

&lt;p&gt;So consider abstractions as “guilty until proven innocent” not the other way around.  Solve YOUR problem - not every other problem, not until you need to.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>On Craftmanship and Understanding, I Guess</title>
    <link rel="alternate" href="/blog/2012/01/31/on-craftmanship-and-understanding-i-guess"/>
    <id>/blog/2012/01/31/on-craftmanship-and-understanding-i-guess</id>
    <published>2012-01-31T00:00:00+00:00</published>
    <updated>2012-01-31T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;You can stand at the station and wait for the train.  You know the one. It&amp;#39;s the one that&amp;#39;s always late, always packed with people, head down staring at the ground.  Or, you can walk the tracks with your own two feet. When you walk the tracks you take in your surroundings, you understand the route and you see the alternatives.  You wont beat the train everytime but when you walk the tracks you&amp;#39;ll have better stories to tell when you get there.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;You can stand at the station and wait for the train.  You know the one. It&amp;#39;s the one that&amp;#39;s always late, always packed with people, head down staring at the ground.  Or, you can walk the tracks with your own two feet. When you walk the tracks you take in your surroundings, you understand the route and you see the alternatives.  You wont beat the train everytime but when you walk the tracks you&amp;#39;ll have better stories to tell when you get there.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Enterprise Scale</title>
    <link rel="alternate" href="/blog/2012/01/26/enterprise-scale"/>
    <id>/blog/2012/01/26/enterprise-scale</id>
    <published>2012-01-26T00:00:00+00:00</published>
    <updated>2012-01-26T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Enterprise.  What a broken, misued term.  Its meant to sound big, huge even. I guess many years ago it used to mean big, huge, big business serious work.&lt;/p&gt;

&lt;p&gt;But when you think about it, its none of those things really, not any more. &amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt; Even the biggest multi-nationals entire enterprise backbone throughput is probably a small fraction of Lady Gagas Twitter feed. Enterprise is just that - one enterprise. Social is global, its all of us at anytime and that is so much bigger than some old enterprise. So if you try and pimp out your CV by using the term enterprise - the only people who are probably going to care are the managers and execs that think their little boring legacy system is unique and special&amp;hellip; Do you really want to be sold that sort of job?  All bytes are equal, some are more equal than others - Pah!  Some are more mired in unnecessary abstraction, contracts and unread, out-of-date doucmentation but they are still bytes.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Enterprise.  What a broken, misued term.  Its meant to sound big, huge even. I guess many years ago it used to mean big, huge, big business serious work.&lt;/p&gt;

&lt;p&gt;But when you think about it, its none of those things really, not any more. &amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt; Even the biggest multi-nationals entire enterprise backbone throughput is probably a small fraction of Lady Gagas Twitter feed. Enterprise is just that - one enterprise. Social is global, its all of us at anytime and that is so much bigger than some old enterprise. So if you try and pimp out your CV by using the term enterprise - the only people who are probably going to care are the managers and execs that think their little boring legacy system is unique and special&amp;hellip; Do you really want to be sold that sort of job?  All bytes are equal, some are more equal than others - Pah!  Some are more mired in unnecessary abstraction, contracts and unread, out-of-date doucmentation but they are still bytes.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Using Parse in .NET and WP7</title>
    <link rel="alternate" href="/blog/2012/01/05/using-parse-in-net-and-wp7"/>
    <id>/blog/2012/01/05/using-parse-in-net-and-wp7</id>
    <published>2012-01-05T00:00:00+00:00</published>
    <updated>2012-01-05T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;UPDATE: Being completely wrong in assuming WP7 supports &lt;code&gt;dynamic&lt;/code&gt; which apparently it doesn&amp;#39;t the current build wont run in WP7.  So another item on the list is a version that doesn&amp;#39;t rely on &lt;code&gt;dynamic&lt;/code&gt; I guess.  Sorry for misleading anyone on that front - I did say it was rough and mostly untested right?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.parse.com/"&gt;Parse&lt;/a&gt; is a site aimed at providing a simple service for pushing and pulling data on mobile devices.  You can create applications and store your mobile data there, create users, provide logon/off mechanisms and even achieve push notifications.  There are 2 ways to access &lt;a href="https://www.parse.com/"&gt;Parse&lt;/a&gt;&lt;/p&gt;

&lt;!-- more --&gt;

&lt;ol&gt;
&lt;li&gt;Via its natively compiled binaries (on iOS and Android)&lt;/li&gt;
&lt;li&gt;Via a its Rest API (for all non iOS/Android devices and desktops)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now I wanted to try and create bindings for the iOS library so I could use it for a Monotouch application I&amp;#39;ve been playing with but truth be told the whole process confused the hell out of me.  Thing was the REST API gave me everything I needed so I started recently to write a dynamic wrapper around the API.  Currently built on .NET in Visual Studio (Mono on my list) with a few sanity tests it works well enough to put it out there incase anyone was wanting to do something similar and could extract value from it.&lt;/p&gt;

&lt;p&gt;It&amp;#39;s pretty early at the minute - in fact all you can do with this first spike is basic object CRUD.  No querying yet, no special user management features etc.  But they will come.  So what could you use it for?  Well a number of things,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WP7 Cloud Storage&lt;/li&gt;
&lt;li&gt;Monotouch (and Monodroid) storage until someone smarter than me creates proper bindings to the actual iOS frameworks&lt;/li&gt;
&lt;li&gt;It&amp;#39;s an object store so why not use it to store data on any web app?&lt;/li&gt;
&lt;li&gt;Just for tinkering.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It makes use of &lt;code&gt;dynamic&lt;/code&gt; from .NET 4 so you can kind of pass it arbitrary stuff and get arbitrary stuff back (Parse is schemaless so this makes sense for me).  It also means you wont have to create concrete classes for every single thing you want to store.&lt;/p&gt;

&lt;p&gt;If you want to run the tests you&amp;#39;ll need to sign up for Parse, create an app and update the &lt;code&gt;consts&lt;/code&gt; in &lt;code&gt;describe_Parsely&lt;/code&gt; to point to your new app (and authenticate).&lt;/p&gt;

&lt;h2&gt;Sample Uses&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;// create your parsley API&lt;/span&gt;
&lt;span class="n"&gt;Parsley&lt;/span&gt; &lt;span class="n"&gt;parsley&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Parsley&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;applicationId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;masterKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// create new class&lt;/span&gt;
&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parsley&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;MyClass&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoolProperty&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;1&lt;/span&gt;  &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// do other cool stuff&lt;/span&gt;
&lt;span class="n"&gt;parsley&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;MyClass&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objectId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoolProperty&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;4&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="n"&gt;dyanmic&lt;/span&gt; &lt;span class="n"&gt;myObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parsley&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Retrieve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;MyClass&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objectId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;parsley&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myObject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objectId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Outstanding Tasks&lt;/h2&gt;

&lt;p&gt;Lots.  But here is the main ones I see right now.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compile on Mono and show MonoTouch some Parse love.&lt;/li&gt;
&lt;li&gt;Samples (for WP7, Monotouch, possibly Monodroid)&lt;/li&gt;
&lt;li&gt;Add Queries&lt;/li&gt;
&lt;li&gt;Add User Management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It&amp;#39;s probably fairly rough right now and could do with some TLC if anyone wants to pitch in?  I&amp;#39;ve given it a name (Parsley) but that in no way implies this is going to be a long running project or anything.  I just like naming things.  Get it while it&amp;#39;s hot, the code is in my &lt;a href="https://bitbucket.org/kouphax/parsley"&gt;usual place&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Pre-Post Update&lt;/h2&gt;

&lt;p&gt;Rather than update this blog post I decided to tack this on here.  With BitBucket experiencing some issues at present I spent about 10 minutes hacking in the user management features.  No tests written yet (oh no I have broken all the rules and must be beaten with oversized crayons) so lets just say that it&amp;#39;s very edge, very experimental at the minute.  Also bonus - returning a collection of objects is implemented as &lt;code&gt;Query&lt;/code&gt; but again totally untested (fast and loose - it&amp;#39;s how I roll son).  There be dragons there therebe!&lt;/p&gt;

&lt;p&gt;Happy hacking.&lt;/p&gt;

&lt;p&gt;Can I have my WP7 MVP now please?  &lt;strong&gt;Kidding&lt;/strong&gt;&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;UPDATE: Being completely wrong in assuming WP7 supports &lt;code&gt;dynamic&lt;/code&gt; which apparently it doesn&amp;#39;t the current build wont run in WP7.  So another item on the list is a version that doesn&amp;#39;t rely on &lt;code&gt;dynamic&lt;/code&gt; I guess.  Sorry for misleading anyone on that front - I did say it was rough and mostly untested right?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.parse.com/"&gt;Parse&lt;/a&gt; is a site aimed at providing a simple service for pushing and pulling data on mobile devices.  You can create applications and store your mobile data there, create users, provide logon/off mechanisms and even achieve push notifications.  There are 2 ways to access &lt;a href="https://www.parse.com/"&gt;Parse&lt;/a&gt;&lt;/p&gt;

&lt;!-- more --&gt;

&lt;ol&gt;
&lt;li&gt;Via its natively compiled binaries (on iOS and Android)&lt;/li&gt;
&lt;li&gt;Via a its Rest API (for all non iOS/Android devices and desktops)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now I wanted to try and create bindings for the iOS library so I could use it for a Monotouch application I&amp;#39;ve been playing with but truth be told the whole process confused the hell out of me.  Thing was the REST API gave me everything I needed so I started recently to write a dynamic wrapper around the API.  Currently built on .NET in Visual Studio (Mono on my list) with a few sanity tests it works well enough to put it out there incase anyone was wanting to do something similar and could extract value from it.&lt;/p&gt;

&lt;p&gt;It&amp;#39;s pretty early at the minute - in fact all you can do with this first spike is basic object CRUD.  No querying yet, no special user management features etc.  But they will come.  So what could you use it for?  Well a number of things,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WP7 Cloud Storage&lt;/li&gt;
&lt;li&gt;Monotouch (and Monodroid) storage until someone smarter than me creates proper bindings to the actual iOS frameworks&lt;/li&gt;
&lt;li&gt;It&amp;#39;s an object store so why not use it to store data on any web app?&lt;/li&gt;
&lt;li&gt;Just for tinkering.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It makes use of &lt;code&gt;dynamic&lt;/code&gt; from .NET 4 so you can kind of pass it arbitrary stuff and get arbitrary stuff back (Parse is schemaless so this makes sense for me).  It also means you wont have to create concrete classes for every single thing you want to store.&lt;/p&gt;

&lt;p&gt;If you want to run the tests you&amp;#39;ll need to sign up for Parse, create an app and update the &lt;code&gt;consts&lt;/code&gt; in &lt;code&gt;describe_Parsely&lt;/code&gt; to point to your new app (and authenticate).&lt;/p&gt;

&lt;h2&gt;Sample Uses&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;// create your parsley API&lt;/span&gt;
&lt;span class="n"&gt;Parsley&lt;/span&gt; &lt;span class="n"&gt;parsley&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Parsley&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;applicationId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;masterKey&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// create new class&lt;/span&gt;
&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parsley&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;MyClass&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoolProperty&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;1&lt;/span&gt;  &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// do other cool stuff&lt;/span&gt;
&lt;span class="n"&gt;parsley&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;MyClass&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objectId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoolProperty&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;4&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="n"&gt;dyanmic&lt;/span&gt; &lt;span class="n"&gt;myObject&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parsley&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Retrieve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;MyClass&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objectId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;parsley&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myObject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objectId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Outstanding Tasks&lt;/h2&gt;

&lt;p&gt;Lots.  But here is the main ones I see right now.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compile on Mono and show MonoTouch some Parse love.&lt;/li&gt;
&lt;li&gt;Samples (for WP7, Monotouch, possibly Monodroid)&lt;/li&gt;
&lt;li&gt;Add Queries&lt;/li&gt;
&lt;li&gt;Add User Management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It&amp;#39;s probably fairly rough right now and could do with some TLC if anyone wants to pitch in?  I&amp;#39;ve given it a name (Parsley) but that in no way implies this is going to be a long running project or anything.  I just like naming things.  Get it while it&amp;#39;s hot, the code is in my &lt;a href="https://bitbucket.org/kouphax/parsley"&gt;usual place&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Pre-Post Update&lt;/h2&gt;

&lt;p&gt;Rather than update this blog post I decided to tack this on here.  With BitBucket experiencing some issues at present I spent about 10 minutes hacking in the user management features.  No tests written yet (oh no I have broken all the rules and must be beaten with oversized crayons) so lets just say that it&amp;#39;s very edge, very experimental at the minute.  Also bonus - returning a collection of objects is implemented as &lt;code&gt;Query&lt;/code&gt; but again totally untested (fast and loose - it&amp;#39;s how I roll son).  There be dragons there therebe!&lt;/p&gt;

&lt;p&gt;Happy hacking.&lt;/p&gt;

&lt;p&gt;Can I have my WP7 MVP now please?  &lt;strong&gt;Kidding&lt;/strong&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Standing at the cusp of 2011... WTF?</title>
    <link rel="alternate" href="/blog/2011/12/30/standing-at-the-cusp-of-2011-dot-dot-dot-wtf"/>
    <id>/blog/2011/12/30/standing-at-the-cusp-of-2011-dot-dot-dot-wtf</id>
    <published>2011-12-30T00:00:00+00:00</published>
    <updated>2011-12-30T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;I&amp;#39;m not sure where this post is going to go in terms of content.  I&amp;#39;m thinking a bit of full disclosure might be quite cathartic but at the same time do you really want to know the ins and out of my somewhat awful 2011?  Compromise - I&amp;#39;ll keep it short.  Possibly.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h2&gt;2011 (The Bad Parts)&lt;/h2&gt;

&lt;p&gt;2011 was a pretty terrible year if I&amp;#39;m honest.  It was the year my wife suffered two miscarriages, I got into my first car accident, stuff kept breaking and I totally dropped the ball in work when I burnt out (I&amp;#39;m certain I&amp;#39;m still feeling the effects of that).  Oh and yes on top of all that I was diagnosed with severe depression for which I am now fully medicated.  But you know what?  I&amp;#39;m not alone - I know a ton of people for whom (look at me I said whom - how posh) 2011 was grim.&lt;/p&gt;

&lt;p&gt;So lets cast aside all the personal stuff, we&amp;#39;ve all had our problems, and let me talk about the burn out.  Long and short of it was that I took too much work on and eventually delivered unacceptable results for them all.  I have something akin to ADD when it comes to work and unless I am suitably challenged or stimulated my productivity drops to pretty much nil.  2011 was full of time consuming mundane boring work for me and as I tried desperately to pull personal value from the work (or hobbies) I started making mistakes, over committing and generally under achieving.  Lesson learned - I need to learn to say no and sometimes I just need to suck up the fact that we can&amp;#39;t all be doing the best part of our jobs ALL THE TIME.  Sometimes we need to just knuckle down and get on with it.  Just not for a full year&amp;hellip;&lt;/p&gt;

&lt;p&gt;Anyway I became somewhat disillusioned with my employer and, truthfully, Northern Ireland.  I like other people to be excited about the stuff I preach but I felt there was a lot of disinterest and empty words.  This annoyed me and I guess I just started pushing harder, which I guess made me look quite angry and pushy.  This obviously wouldn&amp;#39;t help.  When I looked outside of my company - Northern Ireland didn&amp;#39;t seem that much better.  So I felt a bit out of place and I had 2 choices ahead of me.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Up sticks and go somewhere that I felt would be more receptive to my extreme nerdyness and desire to share it.&lt;/li&gt;
&lt;li&gt;Stick around, my company and Northern Ireland and try and make a difference.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I chose the second, not being to be hero or anything but for more pragmatic reasons,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;My wife got pregnant again (due soon yay!), the economy is terrible and it would be too much of a risk right now&lt;/li&gt;
&lt;li&gt;If I stayed in Northern Ireland, or even Ireland, I don&amp;#39;t believe there is any other company that would support me (aka let me get away with) the things I do.  I&amp;#39;m not the most predictable of sorts.  I work weird hours and do strange things.  &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; have always been there for me and supported me.  Having done interviews with people from various levels from various other companies the state of other IT firms makes me seethe with anger. &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;It is better to invest in people and risk them leaving than to not invest in them and risk them staying&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So I start 2012 with a big challenge set for myself.  That sounds about right.  The more I think about &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt;, my employer, deserves more credit than I give it.  We have been in a space thats been all about big business types with big enterprisey solutions and delivered well.  It&amp;#39;s not an area that exactly screams enthusiasm and I think it will take a while to draw people out of that kind of insular thinking. &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; certainly seems to be better than most in this area.  Now enough gushing about &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; (who are hiring BTW)&lt;/p&gt;

&lt;h2&gt;2011 (The Good Parts)&lt;/h2&gt;

&lt;p&gt;OK OK 2011 wasn&amp;#39;t all sob stories and dullness some really cool things happened.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;My CodeSlice initiative in work (meet at least once a month, talk nerdy things, get &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; to pay for free pizza) didn&amp;#39;t die.  In fact in the hands of one of my colleagues, Jonny Holmes, it flourished.  Attendence was never HUGE but it was consistent and varied.  May long this tradition continue and hopefully we can expand it..&lt;/li&gt;
&lt;li&gt;I organised and participated in not one but two hackathons (internally).  Once again &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; covered the costs for our weekend long hack sessions.  Turnout was decent (about 8-12 people) with all types turning up - managers, placement students, technical architects etc.  The experience was enough for me - which is a clever way of saying the end products weren&amp;#39;t as good as envisaged.  But we drew so many valuable lessons that the second one was infinitely more successful that the first - live and learn!  And, oh lord, the plans I have for the first half of 2012 around hackathons are going to be legendary!&lt;/li&gt;
&lt;li&gt;I talked, and not just to myself but to real people, real people who were not paid to be there!  I talked, outside of work, a total of three times.  I know the number isn&amp;#39;t huge but it was late on in the year before I decided to get out there.  Already topped that number for 2012 and the year hasn&amp;#39;t started.  Double figures would be good next year thank you.&lt;/li&gt;
&lt;li&gt;I attended &lt;a href="http://gotocon.com/amsterdam-2011/"&gt;GOTO Amsterdam&lt;/a&gt; were I got to meet a lot of people I have deemed awesome (because they are).  Being in rooms with like minded people (who are generally much smarter than me) saying things that make you realise you are not insane for thinking things could be better really strengthens your beliefs!&lt;/li&gt;
&lt;li&gt;Shared more.  All the stuff above I did because I wanted to get my thoughts out there - I wanted to be educated as well as educate.  I was happy to look like a fool if it meant I didn&amp;#39;t look like a fool later.  Thats hard for an introvert but damn it I gave it my best shot.  I know people, the one who only know me through my writing on &lt;a href="http://yammer.com"&gt;Yammer&lt;/a&gt; or half-read blog post, think I am a purist (I&amp;#39;m not - perfect is the enemy of better), or angry (not me, frustrated at times but never angry), or opinionated (openly opinionated perhaps) or even annoyed that everyone isn&amp;#39;t dancing the happy geek dance like myself (as long as I&amp;#39;m not dancing alone on the dance floor like a sleazy old man stalking girls half his age I&amp;#39;m happy).  Thats fine.  People reckon I risk detracting from the message I am trying to communicate.  Fair enough.  Perhaps I need to tone it down sometimes - but I can&amp;#39;t see that happening - it&amp;#39;s no in my nature.  I think it&amp;#39;s better that people see me as a purist and take some of my ideas away rather than being half-assed and them not taking anything on board!  It&amp;#39;s inevitable that when I try and challenge peoples conceptions of technical things, especially in the open, it&amp;#39;s going to leave a sour taste in some peoples mouths.  But thats how I roll and thats how it should be.  Sorry but there is more on the way.  But I take as good as I give so come at me bros!&lt;/li&gt;
&lt;li&gt;Won a years to subscription to &lt;a href="http://tekpub.com"&gt;Tekpub&lt;/a&gt; on Christmas Day thanks Rob &amp;#39;Santa Clause&amp;#39; Conrey.&lt;/li&gt;
&lt;li&gt;Put my foot in it a few times.  Yeah sounds odd I am classing this as a good thing but Scott Hanselman gave me permission, and I &lt;a href="http://www.hanselman.com/blog/BestPracticesForIndividualContribution.aspx"&gt;quote&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Chris Sells told me once, If you’re not getting in trouble with your boss at least twice a year, you’re likely not pushing the envelope hard enough. Two slaps a year might be the cost for 10 successes. If you’re not moving forward, well, you’re not moving forward.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;2012 (More like 20AWESOME! AMIRITE!)&lt;/h2&gt;

&lt;p&gt;So enough dwelling in the past - how am I going to make 2012 be the awesomest?  Well thats easy - &lt;strong&gt;set some real fecking goals&lt;/strong&gt;.  I failed to do that last year (outside of my typical career goals during my annual reviews of course) and ended up coasting in parts.  Not next year - hells no.  I got me a bucket list (stuff to do before the year dies - not me - unless that comes first - oh god I never thought of that).  TO THE LIST!&lt;/p&gt;

&lt;h3&gt;2012 Bucket List (In No Particular Order)&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Release a screencast&lt;/li&gt;
&lt;li&gt;Release a game&lt;/li&gt;
&lt;li&gt;Appalachian Trail&lt;/li&gt;
&lt;li&gt;&lt;a href="http://givecampni.org.uk"&gt;GiveCamp NI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Talk/Present as often as possible&lt;/li&gt;
&lt;li&gt;Learn a new language&lt;/li&gt;
&lt;li&gt;Contribute more to OSS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So let me explain some of these, as I am sure they mean sweet FA to some of you.&lt;/p&gt;

&lt;h3&gt;Release a Screencast&lt;/h3&gt;

&lt;p&gt;A lot of my blog posts last year were a kind of &amp;ldquo;Introduction to Technology X&amp;rdquo; and I think that sort of knowledge can be better shared via video and real coding.  Coupled with my desire to go a bit deeper in my technical posts but always getting distracted with other blog posts I think 2012 is the year I try my hand at producing a real life proper screencast (or perhaps a series).  With decent production values and what not.  The topic?  Well I am currently thinking &lt;a href="http://nancyfx.org"&gt;Nancy&lt;/a&gt; but I need to really get my head around it a lot than I already do - but thats fine.  Time will tell on that one.&lt;/p&gt;

&lt;h3&gt;Release a Game&lt;/h3&gt;

&lt;p&gt;Game programming is an area I&amp;#39;ve failed to venture into and I feel it is about time.  I wan&amp;#39;t to do something really simple, something mobiley possibly using &lt;a href="http://impactjs.com/"&gt;ImpactJS&lt;/a&gt; because it interests me.  I&amp;#39;d like to release said game into an app store as well - just to watch it get flamed and to say &amp;ldquo;I&amp;#39;ve done it&amp;rdquo;&lt;/p&gt;

&lt;h3&gt;Appalachian Trail&lt;/h3&gt;

&lt;p&gt;This is a codename for a current unfunded project of mine.  The goal is to get a more fuller understanding of the spectrum of mobile development approaches, platforms and technologies.  So simply put generate a bunch of super simple (though still useful) app ideas and using every conceivable type of technology from native to web and all in-between deliver decent quality apps across all the major platforms through hackathons, team challenges, school and university outreach, app camps etc..&lt;/p&gt;

&lt;p&gt;Sounds awesome doesn&amp;#39;t it?&lt;/p&gt;

&lt;h3&gt;GiveCamp NI&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;GiveCamp was founded by Microsoft Developer Evangelist, Chris Koenig, in Dallas, Texas in 2007. His vision was to bring together passionate developers and local charitable organisations for an entire weekend, and see what would happen.&lt;/p&gt;

&lt;p&gt;In late 2012 GiveCamp is coming to Northern Ireland.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thats what the &lt;a href="http://givecampni.org.uk/"&gt;official site&lt;/a&gt; says (I should know I put it there).  So late next year we will run GiveCamp for the first time in Northern Ireland.  A weekend long charity focused public hackathon.  It&amp;#39;s going to be a belter!&lt;/p&gt;

&lt;h3&gt;Talk/Present as often as possible&lt;/h3&gt;

&lt;p&gt;I enjoy talking about nerdy things.  I got a taste for it last year when I went public (having been talking internally to &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; staff for years) and in 2012 I really want to get out there as much as possible.  I find it an amazing way for me to learn as well as understand whats going on in the industry.  So far I am speaking in &lt;a href="http://dublinalt.net/2011/12/14/january-meetup-calling-all-mobile-devs/"&gt;Dublin in January&lt;/a&gt;, &lt;a href="http://www.devweek.com/"&gt;Devweek in London&lt;/a&gt; and a few other un-announced venues.&lt;/p&gt;

&lt;p&gt;BTW if anyone can recommend conferences I should pitch for, or want me to come over and talk about anything in the .NET/JavaScript/Mobie world(s) (see my blog for the kind of thing I know about) - let me know!&lt;/p&gt;

&lt;h3&gt;Learn a new language&lt;/h3&gt;

&lt;p&gt;Everyone says this one right?  Yeah so I spent last year looking at node.js and Ruby and I think it&amp;#39;s time to get out of my safe - I&amp;#39;m thinking F# - yeah that sounds sweet!&lt;/p&gt;

&lt;h3&gt;Contribute more to OSS&lt;/h3&gt;

&lt;p&gt;I head-dived into OSS .NET last year and loved it.  Many people see .NET as a very restricted, Microsoft led platform were every modern web-app is MVC3 with Entity Framework and WCF rules the web service world.  Thats total bull.  .NET has a very vibrant, very active OSS community.  There is almost no need to use any MS technology ever.  But lets not forget MS have really started to embrace and support OSS in a big way.  Lets hope that trend continues!&lt;/p&gt;

&lt;h2&gt;In Summary&lt;/h2&gt;

&lt;p&gt;Boooo to 2011, Yay to 2012.  See you around the same time next year when I have another failful year and promising myself a better one in 2013 :-P&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I&amp;#39;m not sure where this post is going to go in terms of content.  I&amp;#39;m thinking a bit of full disclosure might be quite cathartic but at the same time do you really want to know the ins and out of my somewhat awful 2011?  Compromise - I&amp;#39;ll keep it short.  Possibly.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;h2&gt;2011 (The Bad Parts)&lt;/h2&gt;

&lt;p&gt;2011 was a pretty terrible year if I&amp;#39;m honest.  It was the year my wife suffered two miscarriages, I got into my first car accident, stuff kept breaking and I totally dropped the ball in work when I burnt out (I&amp;#39;m certain I&amp;#39;m still feeling the effects of that).  Oh and yes on top of all that I was diagnosed with severe depression for which I am now fully medicated.  But you know what?  I&amp;#39;m not alone - I know a ton of people for whom (look at me I said whom - how posh) 2011 was grim.&lt;/p&gt;

&lt;p&gt;So lets cast aside all the personal stuff, we&amp;#39;ve all had our problems, and let me talk about the burn out.  Long and short of it was that I took too much work on and eventually delivered unacceptable results for them all.  I have something akin to ADD when it comes to work and unless I am suitably challenged or stimulated my productivity drops to pretty much nil.  2011 was full of time consuming mundane boring work for me and as I tried desperately to pull personal value from the work (or hobbies) I started making mistakes, over committing and generally under achieving.  Lesson learned - I need to learn to say no and sometimes I just need to suck up the fact that we can&amp;#39;t all be doing the best part of our jobs ALL THE TIME.  Sometimes we need to just knuckle down and get on with it.  Just not for a full year&amp;hellip;&lt;/p&gt;

&lt;p&gt;Anyway I became somewhat disillusioned with my employer and, truthfully, Northern Ireland.  I like other people to be excited about the stuff I preach but I felt there was a lot of disinterest and empty words.  This annoyed me and I guess I just started pushing harder, which I guess made me look quite angry and pushy.  This obviously wouldn&amp;#39;t help.  When I looked outside of my company - Northern Ireland didn&amp;#39;t seem that much better.  So I felt a bit out of place and I had 2 choices ahead of me.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Up sticks and go somewhere that I felt would be more receptive to my extreme nerdyness and desire to share it.&lt;/li&gt;
&lt;li&gt;Stick around, my company and Northern Ireland and try and make a difference.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I chose the second, not being to be hero or anything but for more pragmatic reasons,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;My wife got pregnant again (due soon yay!), the economy is terrible and it would be too much of a risk right now&lt;/li&gt;
&lt;li&gt;If I stayed in Northern Ireland, or even Ireland, I don&amp;#39;t believe there is any other company that would support me (aka let me get away with) the things I do.  I&amp;#39;m not the most predictable of sorts.  I work weird hours and do strange things.  &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; have always been there for me and supported me.  Having done interviews with people from various levels from various other companies the state of other IT firms makes me seethe with anger. &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;It is better to invest in people and risk them leaving than to not invest in them and risk them staying&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So I start 2012 with a big challenge set for myself.  That sounds about right.  The more I think about &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt;, my employer, deserves more credit than I give it.  We have been in a space thats been all about big business types with big enterprisey solutions and delivered well.  It&amp;#39;s not an area that exactly screams enthusiasm and I think it will take a while to draw people out of that kind of insular thinking. &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; certainly seems to be better than most in this area.  Now enough gushing about &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; (who are hiring BTW)&lt;/p&gt;

&lt;h2&gt;2011 (The Good Parts)&lt;/h2&gt;

&lt;p&gt;OK OK 2011 wasn&amp;#39;t all sob stories and dullness some really cool things happened.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;My CodeSlice initiative in work (meet at least once a month, talk nerdy things, get &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; to pay for free pizza) didn&amp;#39;t die.  In fact in the hands of one of my colleagues, Jonny Holmes, it flourished.  Attendence was never HUGE but it was consistent and varied.  May long this tradition continue and hopefully we can expand it..&lt;/li&gt;
&lt;li&gt;I organised and participated in not one but two hackathons (internally).  Once again &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; covered the costs for our weekend long hack sessions.  Turnout was decent (about 8-12 people) with all types turning up - managers, placement students, technical architects etc.  The experience was enough for me - which is a clever way of saying the end products weren&amp;#39;t as good as envisaged.  But we drew so many valuable lessons that the second one was infinitely more successful that the first - live and learn!  And, oh lord, the plans I have for the first half of 2012 around hackathons are going to be legendary!&lt;/li&gt;
&lt;li&gt;I talked, and not just to myself but to real people, real people who were not paid to be there!  I talked, outside of work, a total of three times.  I know the number isn&amp;#39;t huge but it was late on in the year before I decided to get out there.  Already topped that number for 2012 and the year hasn&amp;#39;t started.  Double figures would be good next year thank you.&lt;/li&gt;
&lt;li&gt;I attended &lt;a href="http://gotocon.com/amsterdam-2011/"&gt;GOTO Amsterdam&lt;/a&gt; were I got to meet a lot of people I have deemed awesome (because they are).  Being in rooms with like minded people (who are generally much smarter than me) saying things that make you realise you are not insane for thinking things could be better really strengthens your beliefs!&lt;/li&gt;
&lt;li&gt;Shared more.  All the stuff above I did because I wanted to get my thoughts out there - I wanted to be educated as well as educate.  I was happy to look like a fool if it meant I didn&amp;#39;t look like a fool later.  Thats hard for an introvert but damn it I gave it my best shot.  I know people, the one who only know me through my writing on &lt;a href="http://yammer.com"&gt;Yammer&lt;/a&gt; or half-read blog post, think I am a purist (I&amp;#39;m not - perfect is the enemy of better), or angry (not me, frustrated at times but never angry), or opinionated (openly opinionated perhaps) or even annoyed that everyone isn&amp;#39;t dancing the happy geek dance like myself (as long as I&amp;#39;m not dancing alone on the dance floor like a sleazy old man stalking girls half his age I&amp;#39;m happy).  Thats fine.  People reckon I risk detracting from the message I am trying to communicate.  Fair enough.  Perhaps I need to tone it down sometimes - but I can&amp;#39;t see that happening - it&amp;#39;s no in my nature.  I think it&amp;#39;s better that people see me as a purist and take some of my ideas away rather than being half-assed and them not taking anything on board!  It&amp;#39;s inevitable that when I try and challenge peoples conceptions of technical things, especially in the open, it&amp;#39;s going to leave a sour taste in some peoples mouths.  But thats how I roll and thats how it should be.  Sorry but there is more on the way.  But I take as good as I give so come at me bros!&lt;/li&gt;
&lt;li&gt;Won a years to subscription to &lt;a href="http://tekpub.com"&gt;Tekpub&lt;/a&gt; on Christmas Day thanks Rob &amp;#39;Santa Clause&amp;#39; Conrey.&lt;/li&gt;
&lt;li&gt;Put my foot in it a few times.  Yeah sounds odd I am classing this as a good thing but Scott Hanselman gave me permission, and I &lt;a href="http://www.hanselman.com/blog/BestPracticesForIndividualContribution.aspx"&gt;quote&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Chris Sells told me once, If you’re not getting in trouble with your boss at least twice a year, you’re likely not pushing the envelope hard enough. Two slaps a year might be the cost for 10 successes. If you’re not moving forward, well, you’re not moving forward.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;2012 (More like 20AWESOME! AMIRITE!)&lt;/h2&gt;

&lt;p&gt;So enough dwelling in the past - how am I going to make 2012 be the awesomest?  Well thats easy - &lt;strong&gt;set some real fecking goals&lt;/strong&gt;.  I failed to do that last year (outside of my typical career goals during my annual reviews of course) and ended up coasting in parts.  Not next year - hells no.  I got me a bucket list (stuff to do before the year dies - not me - unless that comes first - oh god I never thought of that).  TO THE LIST!&lt;/p&gt;

&lt;h3&gt;2012 Bucket List (In No Particular Order)&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Release a screencast&lt;/li&gt;
&lt;li&gt;Release a game&lt;/li&gt;
&lt;li&gt;Appalachian Trail&lt;/li&gt;
&lt;li&gt;&lt;a href="http://givecampni.org.uk"&gt;GiveCamp NI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Talk/Present as often as possible&lt;/li&gt;
&lt;li&gt;Learn a new language&lt;/li&gt;
&lt;li&gt;Contribute more to OSS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So let me explain some of these, as I am sure they mean sweet FA to some of you.&lt;/p&gt;

&lt;h3&gt;Release a Screencast&lt;/h3&gt;

&lt;p&gt;A lot of my blog posts last year were a kind of &amp;ldquo;Introduction to Technology X&amp;rdquo; and I think that sort of knowledge can be better shared via video and real coding.  Coupled with my desire to go a bit deeper in my technical posts but always getting distracted with other blog posts I think 2012 is the year I try my hand at producing a real life proper screencast (or perhaps a series).  With decent production values and what not.  The topic?  Well I am currently thinking &lt;a href="http://nancyfx.org"&gt;Nancy&lt;/a&gt; but I need to really get my head around it a lot than I already do - but thats fine.  Time will tell on that one.&lt;/p&gt;

&lt;h3&gt;Release a Game&lt;/h3&gt;

&lt;p&gt;Game programming is an area I&amp;#39;ve failed to venture into and I feel it is about time.  I wan&amp;#39;t to do something really simple, something mobiley possibly using &lt;a href="http://impactjs.com/"&gt;ImpactJS&lt;/a&gt; because it interests me.  I&amp;#39;d like to release said game into an app store as well - just to watch it get flamed and to say &amp;ldquo;I&amp;#39;ve done it&amp;rdquo;&lt;/p&gt;

&lt;h3&gt;Appalachian Trail&lt;/h3&gt;

&lt;p&gt;This is a codename for a current unfunded project of mine.  The goal is to get a more fuller understanding of the spectrum of mobile development approaches, platforms and technologies.  So simply put generate a bunch of super simple (though still useful) app ideas and using every conceivable type of technology from native to web and all in-between deliver decent quality apps across all the major platforms through hackathons, team challenges, school and university outreach, app camps etc..&lt;/p&gt;

&lt;p&gt;Sounds awesome doesn&amp;#39;t it?&lt;/p&gt;

&lt;h3&gt;GiveCamp NI&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;GiveCamp was founded by Microsoft Developer Evangelist, Chris Koenig, in Dallas, Texas in 2007. His vision was to bring together passionate developers and local charitable organisations for an entire weekend, and see what would happen.&lt;/p&gt;

&lt;p&gt;In late 2012 GiveCamp is coming to Northern Ireland.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thats what the &lt;a href="http://givecampni.org.uk/"&gt;official site&lt;/a&gt; says (I should know I put it there).  So late next year we will run GiveCamp for the first time in Northern Ireland.  A weekend long charity focused public hackathon.  It&amp;#39;s going to be a belter!&lt;/p&gt;

&lt;h3&gt;Talk/Present as often as possible&lt;/h3&gt;

&lt;p&gt;I enjoy talking about nerdy things.  I got a taste for it last year when I went public (having been talking internally to &lt;a href="http://www.kainos.com"&gt;Kainos&lt;/a&gt; staff for years) and in 2012 I really want to get out there as much as possible.  I find it an amazing way for me to learn as well as understand whats going on in the industry.  So far I am speaking in &lt;a href="http://dublinalt.net/2011/12/14/january-meetup-calling-all-mobile-devs/"&gt;Dublin in January&lt;/a&gt;, &lt;a href="http://www.devweek.com/"&gt;Devweek in London&lt;/a&gt; and a few other un-announced venues.&lt;/p&gt;

&lt;p&gt;BTW if anyone can recommend conferences I should pitch for, or want me to come over and talk about anything in the .NET/JavaScript/Mobie world(s) (see my blog for the kind of thing I know about) - let me know!&lt;/p&gt;

&lt;h3&gt;Learn a new language&lt;/h3&gt;

&lt;p&gt;Everyone says this one right?  Yeah so I spent last year looking at node.js and Ruby and I think it&amp;#39;s time to get out of my safe - I&amp;#39;m thinking F# - yeah that sounds sweet!&lt;/p&gt;

&lt;h3&gt;Contribute more to OSS&lt;/h3&gt;

&lt;p&gt;I head-dived into OSS .NET last year and loved it.  Many people see .NET as a very restricted, Microsoft led platform were every modern web-app is MVC3 with Entity Framework and WCF rules the web service world.  Thats total bull.  .NET has a very vibrant, very active OSS community.  There is almost no need to use any MS technology ever.  But lets not forget MS have really started to embrace and support OSS in a big way.  Lets hope that trend continues!&lt;/p&gt;

&lt;h2&gt;In Summary&lt;/h2&gt;

&lt;p&gt;Boooo to 2011, Yay to 2012.  See you around the same time next year when I have another failful year and promising myself a better one in 2013 :-P&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>A Nancy Module that Behaves like a Rails Controller... Mother of God</title>
    <link rel="alternate" href="/blog/2011/12/30/a-nancy-module-that-behaves-like-a-rails-controller-dot-dot-dot-mother-of-god"/>
    <id>/blog/2011/12/30/a-nancy-module-that-behaves-like-a-rails-controller-dot-dot-dot-mother-of-god</id>
    <published>2011-12-30T00:00:00+00:00</published>
    <updated>2011-12-30T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;If &lt;a href="http://nancyfx.org"&gt;Nancy&lt;/a&gt; is inspired by Sinatra I thought I&amp;#39;d have a little fun a create an abstract class that created modules that kind of mimic the behaviour of Rails controllers.  Code first, ask questions later&amp;hellip;&lt;/p&gt;

&lt;!-- more --&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;RailslikeControllerFor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;TEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;NancyModule&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;TEntity&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;RailslikeControllerFor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TEntity&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/new&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/(?&amp;lt;id&amp;gt;[\d])&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Show&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/(?&amp;lt;id&amp;gt;[\d])/edit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Edit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Put&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/(?&amp;lt;id&amp;gt;[\d])&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Delete&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/(?&amp;lt;id&amp;gt;[\d])&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Destroy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Edit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Destroy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;AsView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;StackTrace&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;GetFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;GetMethod&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;entity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TEntity&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;{0}/{1}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To use it you just subclass the class and override the necessary methods.  Like so.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;QuestionModule&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;RailslikeControllerFor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Question&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;IQuestionsRepository&lt;/span&gt; &lt;span class="nx"&gt;questions&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;QuestionModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;IQuestionsRepository&lt;/span&gt; &lt;span class="nx"&gt;questions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;this.questions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;questions&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nf"&gt;override&lt;/span&gt; &lt;span class="nb"&gt;Response&lt;/span&gt; &lt;span class="nb"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dynamic&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;AsView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;questions.GetAll&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What the base class does is create the necessary CRUDdy urls with a base route starting with the name of the entity you pass in, pluralised in the easiest way possible.  In this case &lt;code&gt;/questions&lt;/code&gt;.  The rules match what you wold get for a controller in Rails.&lt;/p&gt;

&lt;table style="width:100%" border="1"&gt;
    &lt;tbody&gt;
        &lt;tr style="background-color: #666;color:#fff;"&gt;
            &lt;th style="padding:4px;font-weight:bold;"&gt;Verb &lt;/th&gt;
            &lt;th style="padding:4px;font-weight:bold;"&gt;Path&lt;/th&gt;
            &lt;th style="padding:4px;font-weight:bold;"&gt;Action &lt;/th&gt;
            &lt;th style="padding:4px;font-weight:bold;"&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;GET&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions           &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;index    &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;display a list of all questions&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr style="background-color: #fff;"&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;GET&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/new       &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;new      &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;return an &lt;span class="caps"&gt;HTML&lt;/span&gt; form for creating a new question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;POST&lt;/span&gt;    &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions           &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;create   &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;create a new question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr style="background-color: #fff;"&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;GET&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/:id       &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;show     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;display a specific question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;GET&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/:id/edit  &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;edit     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;return an &lt;span class="caps"&gt;HTML&lt;/span&gt; form for editing a question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr style="background-color: #fff;"&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;PUT&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/:id       &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;update   &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;update a specific question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;DELETE&lt;/span&gt;  &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/:id       &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;destroy  &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;delete a specific question&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br/&gt;&lt;/p&gt;

&lt;p&gt;There is a teeny-tiny bit of sugar in the &lt;code&gt;AsView&lt;/code&gt; method that will look up the corresponding view.  So the module above would resolve its &lt;code&gt;Index&lt;/code&gt; method to &lt;code&gt;questions/index&lt;/code&gt; and the view engine would find the correct file (eg. for Razor - &lt;code&gt;questions/index.cshtml&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;I&amp;#39;ve already said it&amp;#39;s a bit of fun but I have actually used this at least once - there is probably more that could be added but it&amp;#39;ll do for a first spike at least.  Any use to anyone?&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;If &lt;a href="http://nancyfx.org"&gt;Nancy&lt;/a&gt; is inspired by Sinatra I thought I&amp;#39;d have a little fun a create an abstract class that created modules that kind of mimic the behaviour of Rails controllers.  Code first, ask questions later&amp;hellip;&lt;/p&gt;

&lt;!-- more --&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;abstract&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt; &lt;span class="n"&gt;RailslikeControllerFor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;TEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;NancyModule&lt;/span&gt; &lt;span class="n"&gt;where&lt;/span&gt; &lt;span class="n"&gt;TEntity&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;class&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;RailslikeControllerFor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TEntity&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/new&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/(?&amp;lt;id&amp;gt;[\d])&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Show&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/(?&amp;lt;id&amp;gt;[\d])/edit&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Edit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Put&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/(?&amp;lt;id&amp;gt;[\d])&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Delete&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;@&amp;quot;/(?&amp;lt;id&amp;gt;[\d])&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Destroy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Edit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;Destroy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dynamic&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;Nancy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt; &lt;span class="n"&gt;AsView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;object&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;StackTrace&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;GetFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;GetMethod&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;entity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TEntity&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;{0}/{1}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To use it you just subclass the class and override the necessary methods.  Like so.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;QuestionModule&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;RailslikeControllerFor&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Question&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;IQuestionsRepository&lt;/span&gt; &lt;span class="nx"&gt;questions&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;QuestionModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;IQuestionsRepository&lt;/span&gt; &lt;span class="nx"&gt;questions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;this.questions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;questions&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nf"&gt;override&lt;/span&gt; &lt;span class="nb"&gt;Response&lt;/span&gt; &lt;span class="nb"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dynamic&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;AsView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;questions.GetAll&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What the base class does is create the necessary CRUDdy urls with a base route starting with the name of the entity you pass in, pluralised in the easiest way possible.  In this case &lt;code&gt;/questions&lt;/code&gt;.  The rules match what you wold get for a controller in Rails.&lt;/p&gt;

&lt;table style="width:100%" border="1"&gt;
    &lt;tbody&gt;
        &lt;tr style="background-color: #666;color:#fff;"&gt;
            &lt;th style="padding:4px;font-weight:bold;"&gt;Verb &lt;/th&gt;
            &lt;th style="padding:4px;font-weight:bold;"&gt;Path&lt;/th&gt;
            &lt;th style="padding:4px;font-weight:bold;"&gt;Action &lt;/th&gt;
            &lt;th style="padding:4px;font-weight:bold;"&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;GET&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions           &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;index    &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;display a list of all questions&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr style="background-color: #fff;"&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;GET&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/new       &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;new      &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;return an &lt;span class="caps"&gt;HTML&lt;/span&gt; form for creating a new question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;POST&lt;/span&gt;    &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions           &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;create   &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;create a new question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr style="background-color: #fff;"&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;GET&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/:id       &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;show     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;display a specific question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;GET&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/:id/edit  &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;edit     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;return an &lt;span class="caps"&gt;HTML&lt;/span&gt; form for editing a question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr style="background-color: #fff;"&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;PUT&lt;/span&gt;     &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/:id       &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;update   &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;update a specific question&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="padding:4px;"&gt;&lt;span class="caps"&gt;DELETE&lt;/span&gt;  &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;/questions/:id       &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;destroy  &lt;/td&gt;
            &lt;td style="padding:4px;"&gt;delete a specific question&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br/&gt;&lt;/p&gt;

&lt;p&gt;There is a teeny-tiny bit of sugar in the &lt;code&gt;AsView&lt;/code&gt; method that will look up the corresponding view.  So the module above would resolve its &lt;code&gt;Index&lt;/code&gt; method to &lt;code&gt;questions/index&lt;/code&gt; and the view engine would find the correct file (eg. for Razor - &lt;code&gt;questions/index.cshtml&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;I&amp;#39;ve already said it&amp;#39;s a bit of fun but I have actually used this at least once - there is probably more that could be added but it&amp;#39;ll do for a first spike at least.  Any use to anyone?&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Code Coverage and the Forces of Good</title>
    <link rel="alternate" href="/blog/2011/12/27/code-coverage-and-the-forces-of-good"/>
    <id>/blog/2011/12/27/code-coverage-and-the-forces-of-good</id>
    <published>2011-12-27T00:00:00+00:00</published>
    <updated>2011-12-27T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Code coverage often does more harm than good.  It removes the focus from testing the expected behaviour of the code to just writing tests to make sure all your code is hit (gamifiying the process to its own detriment).  People will bend tests, often in a way that no typical use case could, just to make them run as they want.  This is unrealistic and paints a false picture of the behaviour of your code.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;That being said - code coverage is a tool and it shouldn&amp;#39;t be blamed for enabling bad habits (a bad workman always blames hi&amp;hellip; well, you know the rest).  So can code coverage be applied in a less obvious way?  Indeed it can.&lt;/p&gt;

&lt;p&gt;Business users invariably end up using things like &lt;a href="http://google.com/analytics"&gt;Google Analytics&lt;/a&gt;, &lt;a href="http://gaug.es"&gt;Gauges&lt;/a&gt; or &lt;a href="http://flurry.com"&gt;Flurry&lt;/a&gt; to discover the most valuable areas of the solution and tailor accordingly.  Makes perfect sense, right?  So why not use code coverage, during development, as a mechanism to identify redundant areas of code, or discover feature hotspots that could benefit from refactoring or performance tweaking?  Why not indeed?&lt;/p&gt;

&lt;p&gt;As any system evolves there will be behaviours that simply don&amp;#39;t need to exist to satisfy the overall behaviour of the system.  Some code and it&amp;#39;s related tests will still hang around.  It happens and with the right tools you&amp;#39;ll be able to see those areas - MightyMoose will show you hit counts for lines of code for example.  So by ensuring tests are reviewed as part of your code review process (or refactored during pairing) you&amp;#39;ll also get reporting of redundant code or feature hotspots for free.&lt;/p&gt;

&lt;p&gt;So if your project is already reporting on code coverage thanks to some great architectural mandate why not at least use it for something more positive?&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Code coverage often does more harm than good.  It removes the focus from testing the expected behaviour of the code to just writing tests to make sure all your code is hit (gamifiying the process to its own detriment).  People will bend tests, often in a way that no typical use case could, just to make them run as they want.  This is unrealistic and paints a false picture of the behaviour of your code.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;That being said - code coverage is a tool and it shouldn&amp;#39;t be blamed for enabling bad habits (a bad workman always blames hi&amp;hellip; well, you know the rest).  So can code coverage be applied in a less obvious way?  Indeed it can.&lt;/p&gt;

&lt;p&gt;Business users invariably end up using things like &lt;a href="http://google.com/analytics"&gt;Google Analytics&lt;/a&gt;, &lt;a href="http://gaug.es"&gt;Gauges&lt;/a&gt; or &lt;a href="http://flurry.com"&gt;Flurry&lt;/a&gt; to discover the most valuable areas of the solution and tailor accordingly.  Makes perfect sense, right?  So why not use code coverage, during development, as a mechanism to identify redundant areas of code, or discover feature hotspots that could benefit from refactoring or performance tweaking?  Why not indeed?&lt;/p&gt;

&lt;p&gt;As any system evolves there will be behaviours that simply don&amp;#39;t need to exist to satisfy the overall behaviour of the system.  Some code and it&amp;#39;s related tests will still hang around.  It happens and with the right tools you&amp;#39;ll be able to see those areas - MightyMoose will show you hit counts for lines of code for example.  So by ensuring tests are reviewed as part of your code review process (or refactored during pairing) you&amp;#39;ll also get reporting of redundant code or feature hotspots for free.&lt;/p&gt;

&lt;p&gt;So if your project is already reporting on code coverage thanks to some great architectural mandate why not at least use it for something more positive?&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Ugh. He's on about something mobiley again. Lord save us all!</title>
    <link rel="alternate" href="/blog/2011/12/13/ugh-hes-on-about-something-mobiley-again-lord-save-us-all"/>
    <id>/blog/2011/12/13/ugh-hes-on-about-something-mobiley-again-lord-save-us-all</id>
    <published>2011-12-13T00:00:00+00:00</published>
    <updated>2011-12-13T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Good timing right?  Fresh of the wave of my &amp;ldquo;lets have a natter about mobile&amp;rdquo; blog posts HP went and did something good (for a change, right?).  After the hash that was made of the TouchPad HP went and open sourced the webOS software. &amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt;  Bundled with this software is &lt;a href="https://developer.palm.com/content/api/dev-guide/enyo.html"&gt;Enyo&lt;/a&gt; a mobile framework for WebKit browsers.  Enyo was to be one of the main development platforms for webOS - JavaScript on the front end with node.js services for the backend.  The future was bright.  Then the TouchPad flopped.  Ack well.&lt;/p&gt;

&lt;p&gt;On the other hand Enyo is a very nice little framework and in the hands of the Open Source community could be a real winner.  I&amp;#39;ve had a chance to tinker with over the last few days and thought I&amp;#39;d help get the word out by outlining how to write the obligatory by law ToDo app.  It is currently somewhat similar to the official &lt;a href="https://developer.palm.com/content/api/dev-guide/enyo/tutorial.html"&gt;FeedReader tutorial&lt;/a&gt; but it could be easily extended to add more features.  I recommend you look at the original &lt;a href="https://developer.palm.com/content/api/dev-guide/enyo/tutorial.html"&gt;tutorial&lt;/a&gt; for more info about how the project is structured as there are certain conventions that may seem odd to your typical web framework.&lt;/p&gt;

&lt;p&gt;The entire application, which looks like this (yeah yeah it&amp;#39;s not the most beautiful thing on the planet - I suck at design).&lt;/p&gt;

&lt;p&gt;&lt;img alt="Sample Output for Web View" src="/images/blog/enyo/todo.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Was knocked together with the following bit of code&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;enyo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;TodoApp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;enyo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;VFlexBox&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;components&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;PageHeader&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;VFlexBox&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nx"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;center&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Todos&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Button&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;caption&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Clear Complete&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onclick&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;clearComplete&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;]},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;RowGroup&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nx"&gt;components&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;newTask&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Input&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;hint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Enter new ToDo here...&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Button&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;caption&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Add&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;onclick&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;addTask&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Scroller&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nx"&gt;flex&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nx"&gt;components&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;list&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;VirtualRepeater&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onSetupRow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;getTask&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Item&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;layoutKind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;HFlexLayout&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;center&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;taskStatus&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;CheckBox&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;margin-right:10px;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;completeTask&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;taskDescription&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;]}&lt;/span&gt;
      &lt;span class="p"&gt;]}&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;

  &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="cp"&gt;[]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;inherited&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;newTask&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getValue&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;done&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="nx"&gt;getTask&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;idx&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;taskDescription&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="nx"&gt;completeTask&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;evt&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;this.&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;list.fetchRowIndex&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;done&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getChecked&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="nx"&gt;clearComplete&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;buffer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="cp"&gt;[]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;done&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
      &lt;span class="nx"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Those of you with some experience in Sencha Touchwill notice that the declarative syntax is quite similar to STs except slightly simpler.  So lets break out some of the features that brought this example together.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Button&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;caption&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Clear Complete&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onclick&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;clearComplete&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is one of the component declarations that make up the suite of components that form the &amp;ldquo;kind&amp;rdquo; (Enyo speak for component or object).  This is somewhat similar to the DOM (COM anyone?  Component Object Model) except in JSON form.  You can specify a component type (kind) and apply properties (which may or may not do something depending on the kind).  Events are also declared inline (see onclick) and map to function names within the main kind declaration.  Obviously if this declaration started getting too big and bloated I could decompose it into smaller components all handling their own stuff.&lt;/p&gt;

&lt;p&gt;One other thing not highlighted in my demo is that backend service calls can also be defined within this component model and then called programatically.  While this felt alien to me initially it is pretty similar to the way inline stores are declared in Sencha - except slightly less engineered.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Scroller&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;list&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;VirtualRepeater&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onSetupRow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;getTask&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Item&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;layoutKind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;HFlexLayout&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;center&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;taskStatus&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;CheckBox&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;margin-right:10px;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;completeTask&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;taskDescription&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The scroller definition above has a few nice features.  The use of &amp;ldquo;flex&amp;rdquo; to manage different screen sizes or viewport resizes and create very nice flexible layout.  The VirtualRepeater which is a templated control that generates items from a collection based on the defined template.  The Virtual part is useful for large lists and ensures that only the minimum amount of items are rendered (just before they are needed).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;todos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;inherited&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;arguments&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Create is essentially our component constructor and allows us to set some things up in advance.  Notice the use of the &lt;code&gt;inherited()&lt;/code&gt; method - this ensures the superclasses &lt;code&gt;create&lt;/code&gt; method is also called (inheritence chaining)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;this.$&lt;/code&gt; is a handy property.  It is essentially a hash of all the named components that are direct and indirect children of the defined component.  This makes it very easy to access a certain component if you want to manipulate it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;getTask&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;todos&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;todo&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;$&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;taskDescription&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setContent&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;todo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;getTask&lt;/code&gt; is the method responsible for populating an Item template in the repeater for each row.  This is where I bind the values of the current collection to the Item kind.&lt;/p&gt;

&lt;p&gt;There you have it - yet another ToDo app spat out into the world!  Just what we needed :)&lt;/p&gt;

&lt;h2&gt;It not all Unicorns and Rainbows&lt;/h2&gt;

&lt;p&gt;Yeah Enyo isn&amp;#39;t perfect (shock horror).  There are some quite annoying and some serious bugs that I have noticed in my hacking.&lt;/p&gt;

&lt;h3&gt;Data Association&lt;/h3&gt;

&lt;p&gt;When rendering the Repeater I can&amp;#39;t see a way to easily attach data items to that item instance.  I worked it out eventually by using &lt;code&gt;this.$.list.fetchRowIndex()&lt;/code&gt; but I think you would need to then manage your own data association.  Not a big issue but it didn&amp;#39;t feel right to me at the time.&lt;/p&gt;

&lt;h3&gt;iPad/iPhone issues&lt;/h3&gt;

&lt;p&gt;The one big issue I had with the iPad was that text fields often didn&amp;#39;t bring the keyboard up (more often than not).  Obviously this could be a bit of a deal breaker but there could be a simple fix.  Some other minor quirks included scrolling issues when multiple scroll areas existed and choppy animations in the kitchen sink style demo (Sampler).&lt;/p&gt;

&lt;p&gt;The example apps display and work on the iPhone but they are super tiny.  I am not sure if this is just a lack of correct formatting within my HTML or if Enyo is purely designed for larger screens.&lt;/p&gt;

&lt;h3&gt;Events&lt;/h3&gt;

&lt;p&gt;At one point I wanted to bind to an event of a component programatically (rather than declaring it inline).  I still can;t find a way to do this and I wonder if this could be a bit of hindrence when you get into a truly dynamic application.  Thought this could be me being a bit stupid as usual.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Enyo v1.0 is still young in the hands of the OSS community but it&amp;#39;s started out strong and could well be a strong competitor to something like Sencha Touch if it keeps up this pace.  Hopefully the community embraces it and allows it to grow.  It could well be great.&lt;/p&gt;

&lt;p&gt;So yes, so far I like it but I&amp;#39;ve only been hacking a few days.  Hopefully I get to spend more time with it over the next few weeks.&lt;/p&gt;

&lt;p&gt;The sample project is available on my &lt;a href="https://bitbucket.org/kouphax/enyo-todos"&gt;BitBucket Repo&lt;/a&gt; if you want to tinker.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Good timing right?  Fresh of the wave of my &amp;ldquo;lets have a natter about mobile&amp;rdquo; blog posts HP went and did something good (for a change, right?).  After the hash that was made of the TouchPad HP went and open sourced the webOS software. &amp;lt;!&amp;ndash; more &amp;ndash;&amp;gt;  Bundled with this software is &lt;a href="https://developer.palm.com/content/api/dev-guide/enyo.html"&gt;Enyo&lt;/a&gt; a mobile framework for WebKit browsers.  Enyo was to be one of the main development platforms for webOS - JavaScript on the front end with node.js services for the backend.  The future was bright.  Then the TouchPad flopped.  Ack well.&lt;/p&gt;

&lt;p&gt;On the other hand Enyo is a very nice little framework and in the hands of the Open Source community could be a real winner.  I&amp;#39;ve had a chance to tinker with over the last few days and thought I&amp;#39;d help get the word out by outlining how to write the obligatory by law ToDo app.  It is currently somewhat similar to the official &lt;a href="https://developer.palm.com/content/api/dev-guide/enyo/tutorial.html"&gt;FeedReader tutorial&lt;/a&gt; but it could be easily extended to add more features.  I recommend you look at the original &lt;a href="https://developer.palm.com/content/api/dev-guide/enyo/tutorial.html"&gt;tutorial&lt;/a&gt; for more info about how the project is structured as there are certain conventions that may seem odd to your typical web framework.&lt;/p&gt;

&lt;p&gt;The entire application, which looks like this (yeah yeah it&amp;#39;s not the most beautiful thing on the planet - I suck at design).&lt;/p&gt;

&lt;p&gt;&lt;img alt="Sample Output for Web View" src="/images/blog/enyo/todo.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Was knocked together with the following bit of code&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nx"&gt;enyo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;TodoApp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;enyo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;VFlexBox&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;components&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;PageHeader&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;VFlexBox&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nx"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;center&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Todos&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Button&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;caption&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Clear Complete&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onclick&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;clearComplete&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;]},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;RowGroup&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nx"&gt;components&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;newTask&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Input&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;hint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Enter new ToDo here...&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Button&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;caption&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Add&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;onclick&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;addTask&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Scroller&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nx"&gt;flex&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="nx"&gt;components&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;list&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;VirtualRepeater&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onSetupRow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;getTask&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Item&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;layoutKind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;HFlexLayout&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;center&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;taskStatus&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;CheckBox&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;margin-right:10px;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;completeTask&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;taskDescription&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;]}&lt;/span&gt;
      &lt;span class="p"&gt;]}&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;

  &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="cp"&gt;[]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;inherited&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arguments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="nx"&gt;addTask&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;newTask&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getValue&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;task&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;done&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="nx"&gt;getTask&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;idx&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;taskDescription&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="nx"&gt;completeTask&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;evt&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;this.&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="bp"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;list.fetchRowIndex&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;done&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getChecked&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="nx"&gt;clearComplete&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;buffer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="cp"&gt;[]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;done&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
      &lt;span class="nx"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Those of you with some experience in Sencha Touchwill notice that the declarative syntax is quite similar to STs except slightly simpler.  So lets break out some of the features that brought this example together.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Button&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;caption&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Clear Complete&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onclick&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;clearComplete&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is one of the component declarations that make up the suite of components that form the &amp;ldquo;kind&amp;rdquo; (Enyo speak for component or object).  This is somewhat similar to the DOM (COM anyone?  Component Object Model) except in JSON form.  You can specify a component type (kind) and apply properties (which may or may not do something depending on the kind).  Events are also declared inline (see onclick) and map to function names within the main kind declaration.  Obviously if this declaration started getting too big and bloated I could decompose it into smaller components all handling their own stuff.&lt;/p&gt;

&lt;p&gt;One other thing not highlighted in my demo is that backend service calls can also be defined within this component model and then called programatically.  While this felt alien to me initially it is pretty similar to the way inline stores are declared in Sencha - except slightly less engineered.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Scroller&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="cp"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;list&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;VirtualRepeater&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onSetupRow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;getTask&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Item&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;layoutKind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;HFlexLayout&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;center&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;taskStatus&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;CheckBox&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;margin-right:10px;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;completeTask&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;taskDescription&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The scroller definition above has a few nice features.  The use of &amp;ldquo;flex&amp;rdquo; to manage different screen sizes or viewport resizes and create very nice flexible layout.  The VirtualRepeater which is a templated control that generates items from a collection based on the defined template.  The Virtual part is useful for large lists and ensures that only the minimum amount of items are rendered (just before they are needed).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;todos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;inherited&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;arguments&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Create is essentially our component constructor and allows us to set some things up in advance.  Notice the use of the &lt;code&gt;inherited()&lt;/code&gt; method - this ensures the superclasses &lt;code&gt;create&lt;/code&gt; method is also called (inheritence chaining)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;this.$&lt;/code&gt; is a handy property.  It is essentially a hash of all the named components that are direct and indirect children of the defined component.  This makes it very easy to access a certain component if you want to manipulate it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;getTask&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sender&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;todos&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;todo&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;$&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;taskDescription&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setContent&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;todo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;getTask&lt;/code&gt; is the method responsible for populating an Item template in the repeater for each row.  This is where I bind the values of the current collection to the Item kind.&lt;/p&gt;

&lt;p&gt;There you have it - yet another ToDo app spat out into the world!  Just what we needed :)&lt;/p&gt;

&lt;h2&gt;It not all Unicorns and Rainbows&lt;/h2&gt;

&lt;p&gt;Yeah Enyo isn&amp;#39;t perfect (shock horror).  There are some quite annoying and some serious bugs that I have noticed in my hacking.&lt;/p&gt;

&lt;h3&gt;Data Association&lt;/h3&gt;

&lt;p&gt;When rendering the Repeater I can&amp;#39;t see a way to easily attach data items to that item instance.  I worked it out eventually by using &lt;code&gt;this.$.list.fetchRowIndex()&lt;/code&gt; but I think you would need to then manage your own data association.  Not a big issue but it didn&amp;#39;t feel right to me at the time.&lt;/p&gt;

&lt;h3&gt;iPad/iPhone issues&lt;/h3&gt;

&lt;p&gt;The one big issue I had with the iPad was that text fields often didn&amp;#39;t bring the keyboard up (more often than not).  Obviously this could be a bit of a deal breaker but there could be a simple fix.  Some other minor quirks included scrolling issues when multiple scroll areas existed and choppy animations in the kitchen sink style demo (Sampler).&lt;/p&gt;

&lt;p&gt;The example apps display and work on the iPhone but they are super tiny.  I am not sure if this is just a lack of correct formatting within my HTML or if Enyo is purely designed for larger screens.&lt;/p&gt;

&lt;h3&gt;Events&lt;/h3&gt;

&lt;p&gt;At one point I wanted to bind to an event of a component programatically (rather than declaring it inline).  I still can;t find a way to do this and I wonder if this could be a bit of hindrence when you get into a truly dynamic application.  Thought this could be me being a bit stupid as usual.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Enyo v1.0 is still young in the hands of the OSS community but it&amp;#39;s started out strong and could well be a strong competitor to something like Sencha Touch if it keeps up this pace.  Hopefully the community embraces it and allows it to grow.  It could well be great.&lt;/p&gt;

&lt;p&gt;So yes, so far I like it but I&amp;#39;ve only been hacking a few days.  Hopefully I get to spend more time with it over the next few weeks.&lt;/p&gt;

&lt;p&gt;The sample project is available on my &lt;a href="https://bitbucket.org/kouphax/enyo-todos"&gt;BitBucket Repo&lt;/a&gt; if you want to tinker.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Rolling Your Own PhoneGap with MonoTouch</title>
    <link rel="alternate" href="/blog/2011/12/05/rolling-your-own-phonegap-with-monotouch"/>
    <id>/blog/2011/12/05/rolling-your-own-phonegap-with-monotouch</id>
    <published>2011-12-05T00:00:00+00:00</published>
    <updated>2011-12-05T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt; is a clever little idea.  Take a transparent native wrapper for a mobile platform, stretch a 100% x 100% web view and provide a JavaScript API that acts as a bridge to native methods that control the device features such as cameras, GPS and Contacts.  It brings all those lovely web people into the mobile space.  Truth be told PhoneGap isn&amp;#39;t powered by flaked unicorn and rainbow essence - it&amp;#39;s fairly simple to achieve yourself.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;So I was thinking, as I do when I am bored, that it would be super awesome if MonoTouch could do the PhoneGap.  Turns out there have been some attempts in the past to create bindings but I barely understand the posts so I felt disappointed.  Then curious.  Then I started hacking.  Then happy.  Then bored again.  The happy once more.  Then slightly frustrated.  Finally I started writing this post and I think I feel a bit tired because it&amp;#39;s late an I&amp;#39;ve had a hard day.&lt;/p&gt;

&lt;p&gt;Anyway what follows is a very primitive start to what is essentially a PhoneGap, possibly NimbleKit, for MonoTouch.  Thats cool becuase not only would you be saying &amp;ldquo;Screw You Objective-C!!&amp;rdquo; by using MonoTouch but you&amp;#39;d be sort of saying &amp;ldquo;Hey MonoTouch - HTML5 just had your mum, twice&amp;rdquo; as well.  Hey I&amp;#39;d use a NimbleKit/PhoneGap-like framework for MonoTouch if it was available and offered a clever way of mixing Native with Web but thats just me.  Hence I am writing this post.&lt;/p&gt;

&lt;h2&gt;The Recipe&lt;/h2&gt;

&lt;p&gt;There are various components that would make up a framework like this.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A fullscreen Web View (lets call it the webside)&lt;/li&gt;
&lt;li&gt;A controller that handles requests from the webside (lets call it the nativeside)&lt;/li&gt;
&lt;li&gt;A JavaScript API on the webside that talks to the nativeside&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Simple enough so lets start proving things.&lt;/p&gt;

&lt;h3&gt;The Webside&lt;/h3&gt;

&lt;p&gt;Using a simple Single View iPhone Project in MonoDevelop I added some local resources.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;www&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;AppDelegate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cs&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;MainViewController&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cs&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For now the index.html file has some basic content&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello UIWebView&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next up I created a full screen &lt;code&gt;UIWebView&lt;/code&gt; and asked it to point to the &lt;code&gt;index.html&lt;/code&gt; I just created in &lt;code&gt;wwww&lt;/code&gt; folder (which by the way should be set as &amp;ldquo;Content&amp;rdquo;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ViewDidLoad&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ViewDidLoad&lt;/span&gt; &lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UIWebView&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;UIWebView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;RectangleF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;320f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;460f&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// obtain path to actual content file&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NSBundle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MainBundle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PathForResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;www/index&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;html&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// create an address and escape whitespace&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;file:{0}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;%20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// create url and request&lt;/span&gt;
        &lt;span class="n"&gt;NSUrl&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;NSUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;NSUrlRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;NSUrlRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// load request and add to main ?view&lt;/span&gt;
        &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LoadRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddSubview&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Running this gives us what we would expect (I hope you expect this otherwise I&amp;#39;d be worried).&lt;/p&gt;

&lt;p&gt;&lt;img alt="Sample Output for Web View" src="/images/blog/monotouch-phonegap/capture1.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Webside more or less spiked for now.  Next up the nativeside.&lt;/p&gt;

&lt;h3&gt;The Nativeside&lt;/h3&gt;

&lt;p&gt;So how is the native stuff supposed to respond to requests made via the mysterious JavaScript API from the webside.  The approach that makes the most sense here is to set up an internal HttpListener that reacts to web requests.  This means we can, thanks to the lack of a Same Origin Policy in UIWebViews via the &lt;code&gt;file://&lt;/code&gt; protocol, make Ajax requests to said listener to do stuff and return appropriate responses.&lt;/p&gt;

&lt;p&gt;In the AppDelegate class I created a basic HttpListener that simply returns a simple JSON response of true if a request is made.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;HttpListener&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;HandleRequest&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IAsyncResult&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//Get the listener context&lt;/span&gt;
    &lt;span class="n"&gt;HttpListenerContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EndGetContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//Start listening for the next request&lt;/span&gt;
    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BeginGetContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;AsyncCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HandleRequest&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;responseBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Encoding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UTF8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContentType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;text/json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;HttpStatusCode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OK&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContentLength64&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;responseBytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutputStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;responseBytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;responseBytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutputStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;FinishedLaunching&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UIApplication&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;NSDictionary&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;window&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;UIWindow&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UIScreen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MainScreen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Bounds&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;viewController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;JsBridgeViewController&lt;/span&gt; &lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RootViewController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;viewController&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MakeKeyAndVisible&lt;/span&gt; &lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;listener&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;HttpListener&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Prefixes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://*:30001/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BeginGetContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;AsyncCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HandleRequest&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;The Final Step - The Bridge&lt;/h3&gt;

&lt;p&gt;So we need to talk to this &amp;ldquo;server&amp;rdquo; from our JavaScript.  Easy stuff - for now we just make a simple ajax call to our endpoint in the &lt;code&gt;index.html&lt;/code&gt; (synchronous for code simplicity).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    var request = new XMLHttpRequest();
    request.open(&amp;#39;GET&amp;#39;,&amp;#39;http://127.0.0.1:30001/&amp;#39;, false);
    request.send();

    if(request.status == 200){
        alert(JSON.parse(request.responseText));
    }
    else{
        alert(&amp;quot;Error&amp;quot;);
    }

&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Running this once again reveals that all is sweet&amp;hellip;&lt;/p&gt;

&lt;p&gt;&lt;img alt="Sample Output for Web View with Nativeside call" src="/images/blog/monotouch-phonegap/capture2.png?1368558404" /&gt;&lt;/p&gt;

&lt;h2&gt;Now What?&lt;/h2&gt;

&lt;p&gt;Well thats about as far as I&amp;#39;ve actually gotten but this is far enough to satisfy myself that it&amp;#39;s possible to talk between the web view and the native stuff.  Yeah I know it&amp;#39;s not rocket science but I needed to prove this to myself.  So whats next?  Well I want see what I can do with regards to making real calls to real things, perhaps even venture into NimbleKit territory and generate native elements such as ViewControllers and Tabs - who knows!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(MYSTERIOUS EXIT MUSIC)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(FADE TO BLACK)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To Be Continued&amp;hellip;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(EVIL CACKLE HEARD IN THE DISTANCE)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(END SCENE)&lt;/em&gt;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt; is a clever little idea.  Take a transparent native wrapper for a mobile platform, stretch a 100% x 100% web view and provide a JavaScript API that acts as a bridge to native methods that control the device features such as cameras, GPS and Contacts.  It brings all those lovely web people into the mobile space.  Truth be told PhoneGap isn&amp;#39;t powered by flaked unicorn and rainbow essence - it&amp;#39;s fairly simple to achieve yourself.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;So I was thinking, as I do when I am bored, that it would be super awesome if MonoTouch could do the PhoneGap.  Turns out there have been some attempts in the past to create bindings but I barely understand the posts so I felt disappointed.  Then curious.  Then I started hacking.  Then happy.  Then bored again.  The happy once more.  Then slightly frustrated.  Finally I started writing this post and I think I feel a bit tired because it&amp;#39;s late an I&amp;#39;ve had a hard day.&lt;/p&gt;

&lt;p&gt;Anyway what follows is a very primitive start to what is essentially a PhoneGap, possibly NimbleKit, for MonoTouch.  Thats cool becuase not only would you be saying &amp;ldquo;Screw You Objective-C!!&amp;rdquo; by using MonoTouch but you&amp;#39;d be sort of saying &amp;ldquo;Hey MonoTouch - HTML5 just had your mum, twice&amp;rdquo; as well.  Hey I&amp;#39;d use a NimbleKit/PhoneGap-like framework for MonoTouch if it was available and offered a clever way of mixing Native with Web but thats just me.  Hence I am writing this post.&lt;/p&gt;

&lt;h2&gt;The Recipe&lt;/h2&gt;

&lt;p&gt;There are various components that would make up a framework like this.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A fullscreen Web View (lets call it the webside)&lt;/li&gt;
&lt;li&gt;A controller that handles requests from the webside (lets call it the nativeside)&lt;/li&gt;
&lt;li&gt;A JavaScript API on the webside that talks to the nativeside&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Simple enough so lets start proving things.&lt;/p&gt;

&lt;h3&gt;The Webside&lt;/h3&gt;

&lt;p&gt;Using a simple Single View iPhone Project in MonoDevelop I added some local resources.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;    &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;www&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;AppDelegate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cs&lt;/span&gt;
    &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="n"&gt;MainViewController&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cs&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For now the index.html file has some basic content&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello UIWebView&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next up I created a full screen &lt;code&gt;UIWebView&lt;/code&gt; and asked it to point to the &lt;code&gt;index.html&lt;/code&gt; I just created in &lt;code&gt;wwww&lt;/code&gt; folder (which by the way should be set as &amp;ldquo;Content&amp;rdquo;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ViewDidLoad&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ViewDidLoad&lt;/span&gt; &lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UIWebView&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;UIWebView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;RectangleF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;320f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;460f&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// obtain path to actual content file&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NSBundle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MainBundle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PathForResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;www/index&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;html&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// create an address and escape whitespace&lt;/span&gt;
        &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;file:{0}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;%20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// create url and request&lt;/span&gt;
        &lt;span class="n"&gt;NSUrl&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;NSUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;NSUrlRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;NSUrlRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// load request and add to main ?view&lt;/span&gt;
        &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LoadRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddSubview&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Running this gives us what we would expect (I hope you expect this otherwise I&amp;#39;d be worried).&lt;/p&gt;

&lt;p&gt;&lt;img alt="Sample Output for Web View" src="/images/blog/monotouch-phonegap/capture1.png?1368558404" /&gt;&lt;/p&gt;

&lt;p&gt;Webside more or less spiked for now.  Next up the nativeside.&lt;/p&gt;

&lt;h3&gt;The Nativeside&lt;/h3&gt;

&lt;p&gt;So how is the native stuff supposed to respond to requests made via the mysterious JavaScript API from the webside.  The approach that makes the most sense here is to set up an internal HttpListener that reacts to web requests.  This means we can, thanks to the lack of a Same Origin Policy in UIWebViews via the &lt;code&gt;file://&lt;/code&gt; protocol, make Ajax requests to said listener to do stuff and return appropriate responses.&lt;/p&gt;

&lt;p&gt;In the AppDelegate class I created a basic HttpListener that simply returns a simple JSON response of true if a request is made.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;HttpListener&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;HandleRequest&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IAsyncResult&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//Get the listener context&lt;/span&gt;
    &lt;span class="n"&gt;HttpListenerContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EndGetContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//Start listening for the next request&lt;/span&gt;
    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BeginGetContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;AsyncCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HandleRequest&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;responseBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Encoding&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UTF8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContentType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;text/json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;HttpStatusCode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OK&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContentLength64&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;responseBytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutputStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;responseBytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;responseBytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;OutputStream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;override&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;FinishedLaunching&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UIApplication&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;NSDictionary&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;window&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;UIWindow&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UIScreen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MainScreen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Bounds&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;viewController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;JsBridgeViewController&lt;/span&gt; &lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RootViewController&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;viewController&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MakeKeyAndVisible&lt;/span&gt; &lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;listener&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;HttpListener&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Prefixes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://*:30001/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BeginGetContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;AsyncCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HandleRequest&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;The Final Step - The Bridge&lt;/h3&gt;

&lt;p&gt;So we need to talk to this &amp;ldquo;server&amp;rdquo; from our JavaScript.  Easy stuff - for now we just make a simple ajax call to our endpoint in the &lt;code&gt;index.html&lt;/code&gt; (synchronous for code simplicity).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    var request = new XMLHttpRequest();
    request.open(&amp;#39;GET&amp;#39;,&amp;#39;http://127.0.0.1:30001/&amp;#39;, false);
    request.send();

    if(request.status == 200){
        alert(JSON.parse(request.responseText));
    }
    else{
        alert(&amp;quot;Error&amp;quot;);
    }

&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Running this once again reveals that all is sweet&amp;hellip;&lt;/p&gt;

&lt;p&gt;&lt;img alt="Sample Output for Web View with Nativeside call" src="/images/blog/monotouch-phonegap/capture2.png?1368558404" /&gt;&lt;/p&gt;

&lt;h2&gt;Now What?&lt;/h2&gt;

&lt;p&gt;Well thats about as far as I&amp;#39;ve actually gotten but this is far enough to satisfy myself that it&amp;#39;s possible to talk between the web view and the native stuff.  Yeah I know it&amp;#39;s not rocket science but I needed to prove this to myself.  So whats next?  Well I want see what I can do with regards to making real calls to real things, perhaps even venture into NimbleKit territory and generate native elements such as ViewControllers and Tabs - who knows!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(MYSTERIOUS EXIT MUSIC)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(FADE TO BLACK)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To Be Continued&amp;hellip;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(EVIL CACKLE HEARD IN THE DISTANCE)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(END SCENE)&lt;/em&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>So This Mobile Stuff Then... (Techologies)</title>
    <link rel="alternate" href="/blog/2011/12/05/so-this-mobile-stuff-then-dot-dot-dot-techologies"/>
    <id>/blog/2011/12/05/so-this-mobile-stuff-then-dot-dot-dot-techologies</id>
    <published>2011-12-05T00:00:00+00:00</published>
    <updated>2011-12-05T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Do you have your mobile strategy yet?  Do you have your &amp;ldquo;one true way&amp;rdquo; to cater for every mobile application need?  If not, the world will suddenly end and you&amp;#39;ll never get anywhere in the mobile market.  Seriously.  Well not seriously.  Obviously that’s a pile of sheep.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;To be blunt the best &amp;ldquo;mobile strategy&amp;rdquo; is the obvious one.  Do whatever suits the project best.  Yeah, yeah your company or your presales guys may not like that, no prepackaged waffle to fill document with or spew out in front of customers.  The easy route is seldom the best route.  Seriously though if your playing it safe with web just in case that iOS project you&amp;#39;ve gotten involved in goes Android you&amp;#39;ll be compromising all the way.&lt;/p&gt;

&lt;h2&gt;Just In Case&lt;/h2&gt;

&lt;p&gt;Ahhhh good old &amp;ldquo;just in case&amp;rdquo;.  Nothing produces more mediocrity through compromise than &amp;ldquo;just in case&amp;rdquo;.  It&amp;#39;s up to you to use your head when it comes to deciding what is the best fit for the project but as long as all the stakeholders are aware of the constraints those choices put on the project then those &amp;ldquo;what if&amp;rdquo; scenarios can be dealt with later.  We need to stop treating &amp;ldquo;mobile&amp;rdquo; as if it was a technology decision.  Web vs Native is not the same as saying Entity Framework vs NHibernate.  It&amp;#39;s so much bigger than that.&lt;/p&gt;

&lt;h2&gt;Weighing up the options&lt;/h2&gt;

&lt;p&gt;So you got a killer mobile project and you want it to be awesome - just like all your projects.  Before we pull out the &amp;ldquo;Native, Hybrid or Web&amp;rdquo; question we need to know what is out there.  What tools, technologies or languages can we use to make the best solution we can?&lt;/p&gt;

&lt;h2&gt;Going Native&lt;/h2&gt;

&lt;p&gt;The problem with the native moniker is that people assume it means a different code base per mobile target and therefore crazy expensive, difficult to handle change, and very time consuming but that isn&amp;#39;t always the case.  It is entirely possible to produce truly native apps without having to have an expansive code base in every language possible.&lt;/p&gt;

&lt;h3&gt;Appcelerator Titanium&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.appcelerator.com/"&gt;Appcelerator&amp;#39;s Titanium&lt;/a&gt; is a good example of a platform that provides an abstract API via a common meta language (in it&amp;#39;s case JavaScript) that allows you to build directly to native apps for each target platform.  You write your code and send it off to the cloud for compilation (AFAIK there currently isn&amp;#39;t an in-house option for building but happy to be corrected).  So you&amp;#39;ve got a middleman that you have no control over. What happens if your app gets rejected due to some low level issue in the compiled code?  What if the cloud service goes down when you really really gotta build?  What if &lt;a href="http://www.appcelerator.com/"&gt;Appcelerator&lt;/a&gt; goes bust?  I dunno maybe that’s just mostly FUD but these are the questions that customers ask and they are difficult ones to answer.  I realise I&amp;#39;ve lambasted the use of too much &amp;ldquo;what if&amp;quot;s in decision making but I&amp;#39;ve come up against these ones and they directly affect the current solution rather than only the future scope.  They need addressing and that’s difficult.&lt;/p&gt;

&lt;p&gt;Having said the a brilliant example of &lt;a href="http://www.appcelerator.com/"&gt;Appcelerators&lt;/a&gt; usefulness is &lt;a href="http://www.wunderlist.com/"&gt;Wunderlist&lt;/a&gt; - available on a ton of mobile and desktop platforms and built with Titanium the whole project shares, AFAIK, a common code base.&lt;/p&gt;

&lt;h3&gt;MonoTouch, Monodroid etc.&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; and its ilk take a slightly different approach to the meta-language.  &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt;, for example, isn&amp;#39;t, as many believe, a cross-platform tool for building native apps.  No, &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; simply compiles to native code through direct bindings to Objective-C code.  You are simply using the C# and the powerful features of the Mono/.NET Base Class Library.  In fact it&amp;#39;s even possible to bind to third party Objective-C code like Flurry, Three20 etc. (and many are made available by other developers).&lt;/p&gt;

&lt;p&gt;The ability to share a common codebase comes from the fact that the same platform is available in MonoDroid (C# and Android) and Silverlight (Windows Phone 7).  So sharing comes down to architecture.  You can share code provided your code doesn&amp;#39;t touch and platform specific code.  You can create your own abstraction layer and work it into your build process or you can use MonoMobile.Extensions which gives you a common API already.&lt;/p&gt;

&lt;p&gt;So in one way the &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; stuff is simply the same as writing Objective-C but simply doing it using C#.  This is nice for a number of reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mono has some very nice features like LINQ and Parallel programming.&lt;/li&gt;
&lt;li&gt;Plenty of nice compatible frameworks - &lt;a href="http://code.google.com/p/sqlite-net/"&gt;sqlite-net&lt;/a&gt;, &lt;a href="https://github.com/timscott/catnap"&gt;catnap&lt;/a&gt;, &lt;a href="http://restsharp.org/"&gt;restsharp&lt;/a&gt; and plenty more.&lt;/li&gt;
&lt;li&gt;Syntax that is less noisy and easier to read&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are of course issues.  Assuming most people who use &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; will come from a .NET background and want to use those skills - when you start you&amp;#39;ll realise just how nice Visual Studio is.  MonoDevelop isn&amp;#39;t terrible, it&amp;#39;s just fine, but it&amp;#39;s simply not on par with Visual Studio (would you expect it to be?).  With the way &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; works your are kind of stuck with MonoDevelop too.  Your average VS2010 developer might easily get frustrated with MonoDevelop.  An aesthetic concern but one that can put people off easily.  That said XCode is equally as infuriating at times (bugs and quirks abound!).&lt;/p&gt;

&lt;p&gt;It&amp;#39;s not all roses though.  What if Xamarin, the commercial sponsor of &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt;, pull the plug?  What if Apple decide, as they tried to before, to ban the use of any intermediary language?  These are questions that people will ask but again the immediate and real advantages always trump theoretical risks.  One other thing worth thinking about - If you came from a Ruby background for example I&amp;#39;m not sure why you would use &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; over Obj-C.  Will this niche have an affect on Mono* in the long term?  Who knows.&lt;/p&gt;

&lt;h2&gt;Mixing It Up aka &lt;em&gt;(cough)&lt;/em&gt;Hybrid&lt;em&gt;(cough)&lt;/em&gt;&lt;/h2&gt;

&lt;p&gt;So maybe you&amp;#39;re a web guru/ninja/hero/wizard type person and you want to make use of those powers/skills in your mobile development but you want to get market visibility by creating a presence in the app stores.  Perhaps you want to have some sort of reuse across platforms but aren&amp;#39;t a .NET dev and Titanium isn&amp;#39;t appealing.  There a number of options in this area already.&lt;/p&gt;

&lt;h3&gt;PhoneGap/Callback&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt; is easily the most technology in the hybrid space.  It is exactly what you expect.  A fullscreen UIWebView in which resources embedded in the application package are executed.  These resources are given access to native device features such as device access etc. via a JavaScript API that hooks into native function calls.  There are wrappers for numerous platforms (iOS, Android, Bada, Blackberry, WP7 etc.) but your code calls the same adaptive API.  Things start to veer off course when you need to introduce custom plugins as these are native and so you need to target all your platforms.  Not much &lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt;  can do in that case of course but worth pointing out.&lt;/p&gt;

&lt;p&gt;With &lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt;  it is up to you to create the experience.  Even if you want a simple straight forward native look and feel you&amp;#39;ll need to simulate it.  Results may vary depending on how good you are at that sort of thing.  Of course something like Sencha Touch could be used to fake native but again what is native on one platform is weirdly alien on another and if you are targeting one platform only why not just man-up and learn that platform in the long term?  At least give yourself that option.&lt;/p&gt;

&lt;h3&gt;NimbleKit&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; is in some ways a bit like MonoTouch meets &lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt; .  You can use it as you would &lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt;  as a transparent API the bridges native and Web Technologies but you can also create real life native components such a Navigation Controllers and Tabs.  Currently iOS is the only supported platform (more support for iPhone than iPad) though an Android version does exist in beta.&lt;/p&gt;

&lt;p&gt;The interesting thing about &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; is that it allows you to make use of a range of technologies to create a really native application while at the same time making use of HTML5/CSS3 features to create a more compelling experience that becomes very difficult in native platforms (see my previous charting example in my last post).&lt;/p&gt;

&lt;p&gt;Plugins are extremely simple as well.  Just register the Obj-C class and call it from JavaScript.  Very nice, very simple.  This allows third party extensions to be bridged very easily too (Flurry for example).&lt;/p&gt;

&lt;p&gt;The slightly annoying thing about &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; is that it is currently very quiet.  There is still activity but it&amp;#39;s certainly not on par with the likes of PhoneGap.  There are also some issues around stability.  It&amp;#39;s not falling over all the time but there are somethings that need to be done in a certain order that aren&amp;#39;t properly documented.  There is some minor speculation that &lt;a href="http://www.sencha.com/"&gt;Sencha&lt;/a&gt; have acquired &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; and I&amp;#39;d welcome that with open arms because I like the philosophy around &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; and it could do with some money behind it.&lt;/p&gt;

&lt;h2&gt;Options for Using Web Technologies&lt;/h2&gt;

&lt;p&gt;Be it hybrid or simply a mobile targeted web site/app there are a ton of options out there.  An absolute TON!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Native look and feel, ultra rich frameworks&lt;/li&gt;
&lt;li&gt;Truly cross-platform progressively enhancing frameworks&lt;/li&gt;
&lt;li&gt;Frameworks for creating structure in your apps like MVC, MVVM etc.&lt;/li&gt;
&lt;li&gt;Frameworks for offering responsive designs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mind boggling choices that change and evolve on a near hourly basis.  Here are just a few&lt;/p&gt;

&lt;h3&gt;Native Look and Feel - Sencha Touch&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.sencha.com/products/touch/"&gt;Sencha Touch&lt;/a&gt; targets high end iOS and Android devices and creates native-esque UIs (WebKit only).  It&amp;#39;s can be patchy on Android at times but the results you can get on iOS are very appealing.  Version 2.0 is seeing massive improvements in performance across the compatible platforms.  People who have experience in ExtJS will really feel at home here - other people will struggle with the short but steep learning curve (as with all &lt;a href="http://www.sencha.com/"&gt;Sencha&lt;/a&gt; frameworks).&lt;/p&gt;

&lt;p&gt;Bear in mind that &lt;a href="http://www.sencha.com/products/touch/"&gt;Sencha Touch&lt;/a&gt; is a framework not a product so there will be work involved in getting it to behave exactly how you want but the available architecture options such as the MVC approach and the Data Stores make it very powerful.&lt;/p&gt;

&lt;h3&gt;Cross Platform - jQuery Mobile&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://jquerymobile.com/"&gt;jQuery Mobile&lt;/a&gt; lives at the opposite end of the mobile framework spectrum.  It takes the philosophy of jQuery UI (Progressive Enhancement, accessibility, themeability etc.) and put it into a mobile framework.  So you construct a purely functional purely HTML application or site and with data annotations you let &lt;a href="http://jquerymobile.com/"&gt;jQuery Mobile&lt;/a&gt; make the site as rich and functional as it can.  This means provided your mobile device can render HTML the site or app will at least be functional.  Butt ugly but functional.&lt;/p&gt;

&lt;p&gt;This carries a penalty though.  Even when used on the top of the line device there are some trade offs that need to be made.  The experience is not as polished as it could be.  It is possible to tweak it yourself and cater to the high end devices only but there is extra work involved.  Again the result is still very nice and generally smooth but it is easy to nitpick little quirks in the navigation or styling.&lt;/p&gt;

&lt;h3&gt;MVC Frameworks - Backbone, Spine(Mobile), Sammy etc.&lt;/h3&gt;

&lt;p&gt;If you want to roll your own UI entirely but still need to create a scalable and proven foundation &lt;a href="http://documentcloud.github.com/backbone/"&gt;Backbone&lt;/a&gt; and &lt;a href="http://spinejs.com/mobile/index"&gt;Spine&lt;/a&gt; are two very interesting projects.  It&amp;#39;s worth noting that Sencha Touch has a powerful MVC architecture built into to and it is somewhat similar to these frameworks.&lt;/p&gt;

&lt;p&gt;These sort of frameworks offer base classes for your typical project structure - Controllers, Models and Views.  They provide the wiring between these abstract classes allowing the developers to focus on the important stuff.  The controllers allow you to specify custom routing in your single page apps, the models give you structured persistence and sometimes relationships and the views give you a nicer lifecycle around page components and custom event handling.&lt;/p&gt;

&lt;p&gt;It&amp;#39;s often said these frameworks take some time to &amp;quot;get&amp;rdquo; - some people can use them with ease while others just think they introduce unnecessary complexity.  I think they come into their own in the mobile app space but I do still struggle with the concepts at times.&lt;/p&gt;

&lt;h3&gt;Responsive Design - Skeleton&lt;/h3&gt;

&lt;p&gt;There are grid and UI toolkit frameworks out there that are aimed at creating a responsive design.  Got a large screen?  Make use of the better horizontal space and stack elements horizontally.  On a small mobile device with tiny viewport?  Stack the elements vertically.  &lt;a href="http://getskeleton.com"&gt;Skeleton&lt;/a&gt; is the perfect example of this using media queries to layout a grid system depending on available space.  It also has a few nice widgets like Tabs and Buttons.  Geared more around the web site rather than the app these frameworks are a handy addition.&lt;/p&gt;

&lt;h2&gt;Run out of things to say&lt;/h2&gt;

&lt;p&gt;I&amp;#39;ve covered a lot there but I wanted to get my thoughts out there in the world and hopefully educate and be educated.  My tools of choice right now?  Well RIGHT NOW I am tinkering with Obj-C and iOS as well as MonoTouch and did some NimbleKit hacking at the weekend.  To me this sort of understanding is important and that’s why I do it.  You may argue that it makes you a jack-of-all-trades but I don&amp;#39;t think so - this I merely trying to better understand the mobile ecosystem in the same way I try and grok the entire .NET ecosystem.&lt;/p&gt;

&lt;p&gt;To me if you want to embrace mobile you need to understand it properly.  If you&amp;#39;re just sticking with a particular stack because it&amp;#39;s familiar to you you are doing yourself and the project a dis-service.  As many articles before me have said - you are not the programming language you code in - you need to embrace the polyglot nature of a good developer and do what is right for that project.&lt;/p&gt;

&lt;p&gt;Hope you enjoyed this.  That’s me for December I think :).  I have other things to do.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Do you have your mobile strategy yet?  Do you have your &amp;ldquo;one true way&amp;rdquo; to cater for every mobile application need?  If not, the world will suddenly end and you&amp;#39;ll never get anywhere in the mobile market.  Seriously.  Well not seriously.  Obviously that’s a pile of sheep.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;To be blunt the best &amp;ldquo;mobile strategy&amp;rdquo; is the obvious one.  Do whatever suits the project best.  Yeah, yeah your company or your presales guys may not like that, no prepackaged waffle to fill document with or spew out in front of customers.  The easy route is seldom the best route.  Seriously though if your playing it safe with web just in case that iOS project you&amp;#39;ve gotten involved in goes Android you&amp;#39;ll be compromising all the way.&lt;/p&gt;

&lt;h2&gt;Just In Case&lt;/h2&gt;

&lt;p&gt;Ahhhh good old &amp;ldquo;just in case&amp;rdquo;.  Nothing produces more mediocrity through compromise than &amp;ldquo;just in case&amp;rdquo;.  It&amp;#39;s up to you to use your head when it comes to deciding what is the best fit for the project but as long as all the stakeholders are aware of the constraints those choices put on the project then those &amp;ldquo;what if&amp;rdquo; scenarios can be dealt with later.  We need to stop treating &amp;ldquo;mobile&amp;rdquo; as if it was a technology decision.  Web vs Native is not the same as saying Entity Framework vs NHibernate.  It&amp;#39;s so much bigger than that.&lt;/p&gt;

&lt;h2&gt;Weighing up the options&lt;/h2&gt;

&lt;p&gt;So you got a killer mobile project and you want it to be awesome - just like all your projects.  Before we pull out the &amp;ldquo;Native, Hybrid or Web&amp;rdquo; question we need to know what is out there.  What tools, technologies or languages can we use to make the best solution we can?&lt;/p&gt;

&lt;h2&gt;Going Native&lt;/h2&gt;

&lt;p&gt;The problem with the native moniker is that people assume it means a different code base per mobile target and therefore crazy expensive, difficult to handle change, and very time consuming but that isn&amp;#39;t always the case.  It is entirely possible to produce truly native apps without having to have an expansive code base in every language possible.&lt;/p&gt;

&lt;h3&gt;Appcelerator Titanium&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.appcelerator.com/"&gt;Appcelerator&amp;#39;s Titanium&lt;/a&gt; is a good example of a platform that provides an abstract API via a common meta language (in it&amp;#39;s case JavaScript) that allows you to build directly to native apps for each target platform.  You write your code and send it off to the cloud for compilation (AFAIK there currently isn&amp;#39;t an in-house option for building but happy to be corrected).  So you&amp;#39;ve got a middleman that you have no control over. What happens if your app gets rejected due to some low level issue in the compiled code?  What if the cloud service goes down when you really really gotta build?  What if &lt;a href="http://www.appcelerator.com/"&gt;Appcelerator&lt;/a&gt; goes bust?  I dunno maybe that’s just mostly FUD but these are the questions that customers ask and they are difficult ones to answer.  I realise I&amp;#39;ve lambasted the use of too much &amp;ldquo;what if&amp;quot;s in decision making but I&amp;#39;ve come up against these ones and they directly affect the current solution rather than only the future scope.  They need addressing and that’s difficult.&lt;/p&gt;

&lt;p&gt;Having said the a brilliant example of &lt;a href="http://www.appcelerator.com/"&gt;Appcelerators&lt;/a&gt; usefulness is &lt;a href="http://www.wunderlist.com/"&gt;Wunderlist&lt;/a&gt; - available on a ton of mobile and desktop platforms and built with Titanium the whole project shares, AFAIK, a common code base.&lt;/p&gt;

&lt;h3&gt;MonoTouch, Monodroid etc.&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; and its ilk take a slightly different approach to the meta-language.  &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt;, for example, isn&amp;#39;t, as many believe, a cross-platform tool for building native apps.  No, &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; simply compiles to native code through direct bindings to Objective-C code.  You are simply using the C# and the powerful features of the Mono/.NET Base Class Library.  In fact it&amp;#39;s even possible to bind to third party Objective-C code like Flurry, Three20 etc. (and many are made available by other developers).&lt;/p&gt;

&lt;p&gt;The ability to share a common codebase comes from the fact that the same platform is available in MonoDroid (C# and Android) and Silverlight (Windows Phone 7).  So sharing comes down to architecture.  You can share code provided your code doesn&amp;#39;t touch and platform specific code.  You can create your own abstraction layer and work it into your build process or you can use MonoMobile.Extensions which gives you a common API already.&lt;/p&gt;

&lt;p&gt;So in one way the &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; stuff is simply the same as writing Objective-C but simply doing it using C#.  This is nice for a number of reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mono has some very nice features like LINQ and Parallel programming.&lt;/li&gt;
&lt;li&gt;Plenty of nice compatible frameworks - &lt;a href="http://code.google.com/p/sqlite-net/"&gt;sqlite-net&lt;/a&gt;, &lt;a href="https://github.com/timscott/catnap"&gt;catnap&lt;/a&gt;, &lt;a href="http://restsharp.org/"&gt;restsharp&lt;/a&gt; and plenty more.&lt;/li&gt;
&lt;li&gt;Syntax that is less noisy and easier to read&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are of course issues.  Assuming most people who use &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; will come from a .NET background and want to use those skills - when you start you&amp;#39;ll realise just how nice Visual Studio is.  MonoDevelop isn&amp;#39;t terrible, it&amp;#39;s just fine, but it&amp;#39;s simply not on par with Visual Studio (would you expect it to be?).  With the way &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; works your are kind of stuck with MonoDevelop too.  Your average VS2010 developer might easily get frustrated with MonoDevelop.  An aesthetic concern but one that can put people off easily.  That said XCode is equally as infuriating at times (bugs and quirks abound!).&lt;/p&gt;

&lt;p&gt;It&amp;#39;s not all roses though.  What if Xamarin, the commercial sponsor of &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt;, pull the plug?  What if Apple decide, as they tried to before, to ban the use of any intermediary language?  These are questions that people will ask but again the immediate and real advantages always trump theoretical risks.  One other thing worth thinking about - If you came from a Ruby background for example I&amp;#39;m not sure why you would use &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; over Obj-C.  Will this niche have an affect on Mono* in the long term?  Who knows.&lt;/p&gt;

&lt;h2&gt;Mixing It Up aka &lt;em&gt;(cough)&lt;/em&gt;Hybrid&lt;em&gt;(cough)&lt;/em&gt;&lt;/h2&gt;

&lt;p&gt;So maybe you&amp;#39;re a web guru/ninja/hero/wizard type person and you want to make use of those powers/skills in your mobile development but you want to get market visibility by creating a presence in the app stores.  Perhaps you want to have some sort of reuse across platforms but aren&amp;#39;t a .NET dev and Titanium isn&amp;#39;t appealing.  There a number of options in this area already.&lt;/p&gt;

&lt;h3&gt;PhoneGap/Callback&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt; is easily the most technology in the hybrid space.  It is exactly what you expect.  A fullscreen UIWebView in which resources embedded in the application package are executed.  These resources are given access to native device features such as device access etc. via a JavaScript API that hooks into native function calls.  There are wrappers for numerous platforms (iOS, Android, Bada, Blackberry, WP7 etc.) but your code calls the same adaptive API.  Things start to veer off course when you need to introduce custom plugins as these are native and so you need to target all your platforms.  Not much &lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt;  can do in that case of course but worth pointing out.&lt;/p&gt;

&lt;p&gt;With &lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt;  it is up to you to create the experience.  Even if you want a simple straight forward native look and feel you&amp;#39;ll need to simulate it.  Results may vary depending on how good you are at that sort of thing.  Of course something like Sencha Touch could be used to fake native but again what is native on one platform is weirdly alien on another and if you are targeting one platform only why not just man-up and learn that platform in the long term?  At least give yourself that option.&lt;/p&gt;

&lt;h3&gt;NimbleKit&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; is in some ways a bit like MonoTouch meets &lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt; .  You can use it as you would &lt;a href="http://phonegap.com/"&gt;PhoneGap&lt;/a&gt;  as a transparent API the bridges native and Web Technologies but you can also create real life native components such a Navigation Controllers and Tabs.  Currently iOS is the only supported platform (more support for iPhone than iPad) though an Android version does exist in beta.&lt;/p&gt;

&lt;p&gt;The interesting thing about &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; is that it allows you to make use of a range of technologies to create a really native application while at the same time making use of HTML5/CSS3 features to create a more compelling experience that becomes very difficult in native platforms (see my previous charting example in my last post).&lt;/p&gt;

&lt;p&gt;Plugins are extremely simple as well.  Just register the Obj-C class and call it from JavaScript.  Very nice, very simple.  This allows third party extensions to be bridged very easily too (Flurry for example).&lt;/p&gt;

&lt;p&gt;The slightly annoying thing about &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; is that it is currently very quiet.  There is still activity but it&amp;#39;s certainly not on par with the likes of PhoneGap.  There are also some issues around stability.  It&amp;#39;s not falling over all the time but there are somethings that need to be done in a certain order that aren&amp;#39;t properly documented.  There is some minor speculation that &lt;a href="http://www.sencha.com/"&gt;Sencha&lt;/a&gt; have acquired &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; and I&amp;#39;d welcome that with open arms because I like the philosophy around &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt; and it could do with some money behind it.&lt;/p&gt;

&lt;h2&gt;Options for Using Web Technologies&lt;/h2&gt;

&lt;p&gt;Be it hybrid or simply a mobile targeted web site/app there are a ton of options out there.  An absolute TON!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Native look and feel, ultra rich frameworks&lt;/li&gt;
&lt;li&gt;Truly cross-platform progressively enhancing frameworks&lt;/li&gt;
&lt;li&gt;Frameworks for creating structure in your apps like MVC, MVVM etc.&lt;/li&gt;
&lt;li&gt;Frameworks for offering responsive designs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mind boggling choices that change and evolve on a near hourly basis.  Here are just a few&lt;/p&gt;

&lt;h3&gt;Native Look and Feel - Sencha Touch&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.sencha.com/products/touch/"&gt;Sencha Touch&lt;/a&gt; targets high end iOS and Android devices and creates native-esque UIs (WebKit only).  It&amp;#39;s can be patchy on Android at times but the results you can get on iOS are very appealing.  Version 2.0 is seeing massive improvements in performance across the compatible platforms.  People who have experience in ExtJS will really feel at home here - other people will struggle with the short but steep learning curve (as with all &lt;a href="http://www.sencha.com/"&gt;Sencha&lt;/a&gt; frameworks).&lt;/p&gt;

&lt;p&gt;Bear in mind that &lt;a href="http://www.sencha.com/products/touch/"&gt;Sencha Touch&lt;/a&gt; is a framework not a product so there will be work involved in getting it to behave exactly how you want but the available architecture options such as the MVC approach and the Data Stores make it very powerful.&lt;/p&gt;

&lt;h3&gt;Cross Platform - jQuery Mobile&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://jquerymobile.com/"&gt;jQuery Mobile&lt;/a&gt; lives at the opposite end of the mobile framework spectrum.  It takes the philosophy of jQuery UI (Progressive Enhancement, accessibility, themeability etc.) and put it into a mobile framework.  So you construct a purely functional purely HTML application or site and with data annotations you let &lt;a href="http://jquerymobile.com/"&gt;jQuery Mobile&lt;/a&gt; make the site as rich and functional as it can.  This means provided your mobile device can render HTML the site or app will at least be functional.  Butt ugly but functional.&lt;/p&gt;

&lt;p&gt;This carries a penalty though.  Even when used on the top of the line device there are some trade offs that need to be made.  The experience is not as polished as it could be.  It is possible to tweak it yourself and cater to the high end devices only but there is extra work involved.  Again the result is still very nice and generally smooth but it is easy to nitpick little quirks in the navigation or styling.&lt;/p&gt;

&lt;h3&gt;MVC Frameworks - Backbone, Spine(Mobile), Sammy etc.&lt;/h3&gt;

&lt;p&gt;If you want to roll your own UI entirely but still need to create a scalable and proven foundation &lt;a href="http://documentcloud.github.com/backbone/"&gt;Backbone&lt;/a&gt; and &lt;a href="http://spinejs.com/mobile/index"&gt;Spine&lt;/a&gt; are two very interesting projects.  It&amp;#39;s worth noting that Sencha Touch has a powerful MVC architecture built into to and it is somewhat similar to these frameworks.&lt;/p&gt;

&lt;p&gt;These sort of frameworks offer base classes for your typical project structure - Controllers, Models and Views.  They provide the wiring between these abstract classes allowing the developers to focus on the important stuff.  The controllers allow you to specify custom routing in your single page apps, the models give you structured persistence and sometimes relationships and the views give you a nicer lifecycle around page components and custom event handling.&lt;/p&gt;

&lt;p&gt;It&amp;#39;s often said these frameworks take some time to &amp;quot;get&amp;rdquo; - some people can use them with ease while others just think they introduce unnecessary complexity.  I think they come into their own in the mobile app space but I do still struggle with the concepts at times.&lt;/p&gt;

&lt;h3&gt;Responsive Design - Skeleton&lt;/h3&gt;

&lt;p&gt;There are grid and UI toolkit frameworks out there that are aimed at creating a responsive design.  Got a large screen?  Make use of the better horizontal space and stack elements horizontally.  On a small mobile device with tiny viewport?  Stack the elements vertically.  &lt;a href="http://getskeleton.com"&gt;Skeleton&lt;/a&gt; is the perfect example of this using media queries to layout a grid system depending on available space.  It also has a few nice widgets like Tabs and Buttons.  Geared more around the web site rather than the app these frameworks are a handy addition.&lt;/p&gt;

&lt;h2&gt;Run out of things to say&lt;/h2&gt;

&lt;p&gt;I&amp;#39;ve covered a lot there but I wanted to get my thoughts out there in the world and hopefully educate and be educated.  My tools of choice right now?  Well RIGHT NOW I am tinkering with Obj-C and iOS as well as MonoTouch and did some NimbleKit hacking at the weekend.  To me this sort of understanding is important and that’s why I do it.  You may argue that it makes you a jack-of-all-trades but I don&amp;#39;t think so - this I merely trying to better understand the mobile ecosystem in the same way I try and grok the entire .NET ecosystem.&lt;/p&gt;

&lt;p&gt;To me if you want to embrace mobile you need to understand it properly.  If you&amp;#39;re just sticking with a particular stack because it&amp;#39;s familiar to you you are doing yourself and the project a dis-service.  As many articles before me have said - you are not the programming language you code in - you need to embrace the polyglot nature of a good developer and do what is right for that project.&lt;/p&gt;

&lt;p&gt;Hope you enjoyed this.  That’s me for December I think :).  I have other things to do.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>So this mobile stuff then... (Hybrid)</title>
    <link rel="alternate" href="/blog/2011/12/03/so-this-mobile-stuff-then-dot-dot-dot-hybrid"/>
    <id>/blog/2011/12/03/so-this-mobile-stuff-then-dot-dot-dot-hybrid</id>
    <published>2011-12-03T00:00:00+00:00</published>
    <updated>2011-12-03T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;It&amp;#39;s fair to say over the past year or so I&amp;#39;ve dabbled in a bit of mobile development.  I&amp;#39;ve been involved in a number of  projects (from a technical perspective),&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web Based, Tablet Focused Analytics Dashboard (Custom HTML and &lt;a href="http://www.highcharts.com/"&gt;HighCharts&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Web Based, Tablet Focused Data Capture application (&lt;a href="http://www.sencha.com/products/touch"&gt;Sencha Touch&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Hybrid application for a teleco (&lt;a href="http://jquerymobile.com"&gt;jQuery Mobile&lt;/a&gt; and &lt;a href="http://phonegap.com"&gt;PhoneGap&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Mobile Hackathon (&lt;a href="http://jquerymobile.com"&gt;jQuery Mobile&lt;/a&gt; and &lt;a href="http://phonegap.com"&gt;PhoneGap&lt;/a&gt; and &lt;a href="http://parse.com"&gt;Parse&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Hybrid Application for a Bank (&lt;a href="http://www.sencha.com/products/touch"&gt;Sencha Touch&lt;/a&gt; and &lt;a href="http://phonegap.com"&gt;PhoneGap&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Various iPhone and iPad POCs for a health based project (&lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt;, XCode)&lt;/li&gt;
&lt;li&gt;Technology evaluations (Native Apple Development, &lt;a href="http://parse.com"&gt;Parse&lt;/a&gt;, &lt;a href="http://www.sencha.com/products/touch"&gt;Sencha Touch&lt;/a&gt;], &lt;a href="http://phonegap.com"&gt;PhoneGap&lt;/a&gt;, &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt;, &lt;a href="http://jquerymobile.com"&gt;jQuery Mobile&lt;/a&gt;, &lt;a href="http://documentcloud.github.com/backbone/"&gt;Backbone&lt;/a&gt;, &lt;a href="http://spinejs.com"&gt;Spine.js&lt;/a&gt;, &lt;a href="http://www.appcelerator.com/"&gt;Appcelerator&lt;/a&gt;, &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt;, &lt;a href="http://android.xamarin.com/"&gt;Monodroid&lt;/a&gt; and plenty more&amp;hellip;)&lt;/li&gt;
&lt;li&gt;Consulted on various projects around the whole &amp;ldquo;native vs hybrid vs web&amp;rdquo; thing&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- more --&gt;

&lt;h2&gt;That Hybrid Word&lt;/h2&gt;

&lt;p&gt;One thing I&amp;#39;ve found is that many clients are using the old &amp;ldquo;a web app will never be as polished as a native app&amp;rdquo; argument but TBH that really isn&amp;#39;t the case.  This is down to a lack of real understanding and abuse of the word in the industry.  A bit of hybridism can go along way in creating a rich experience.&lt;/p&gt;

&lt;h3&gt;A Rose By Any Other Name&amp;hellip;&lt;/h3&gt;

&lt;p&gt;Many people break mobile applications into 3 VERY distinct areas,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Native&lt;/strong&gt; - app installed on the device, written using the default toolkit for that platform.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hybrid&lt;/strong&gt; - consists of a transparent &amp;ldquo;native&amp;rdquo; layer and a Web View into which HTML, JavaScript and CSS is loaded (generally stored within the native package).  The nativelayer provides and API for the JavaScript model in the Web View to call.  Think PhoneGap.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Web&lt;/strong&gt; - HTML, CSS, JavaScript assets hosted on the web and accessed from a mobile device.  Possibly some native-like features such as icons and removing the browser chrome.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The problem with the hybrid definition there is that it is, well, wrong.  There isn&amp;#39;t a clear distinction between the native and hybrid and there shouldn&amp;#39;t be.  If I spun up a Silverlight app that put a Web View in the middle to display some HTML I wouldn&amp;#39;t call it hybrid.  If I wrote an Android app that used a library written in Scala it wouldn&amp;#39;t be hybrid.  Or even if I wrote a Monotouch app using some bindings to the &lt;a href="http://www.flurry.com/"&gt;Flurry&lt;/a&gt; framework - nope not hybrid.&lt;/p&gt;

&lt;h3&gt;The Charting Example&lt;/h3&gt;

&lt;p&gt;A good example of &amp;ldquo;hybrid&amp;rdquo; is charting.  There aren&amp;#39;t a great deal of nice flexible charting libraries for iOS, but there is for JavaScript/HTML5.  So some of our projects have made use of HighCharts and Sencha Charting inside a transparent UIWebView to render charts that are flexible and rich.  I wouldn&amp;#39;t bother pinning the hybrid tag to that app - it&amp;#39;s simply making use of whatever technologies helped us get the job done in the best way possible.&lt;/p&gt;

&lt;p&gt;I understand the use of hybrid in sales pitches or to simply convey meaning to people who are less technical but the problem is people are starting to develop opinions based on these words alone which is disatorous.  I&amp;#39;ve had customers tell me that they want native because that hybrid stuff is ugly.  True some hybrid apps are ugly as sin (Aer Lingus iPhone app for one) but then so are some native ones.  It&amp;#39;s unfair to collectively throw away and entire type of app because of poorly misunderstood words.&lt;/p&gt;

&lt;h2&gt;But, But, But&amp;hellip; Reusability&lt;/h2&gt;

&lt;p&gt;People use the hybrid term to show that they have thought about portability.  Write once, run anywhere.  In that sense I guess using hybrid makes sense (but that sort of talk is really part of the sales talk right?).  But then it would be just as easy to say that &amp;ldquo;elements of the solution will be written in a platform agnostic language to minimise code rewrites on different devices&amp;rdquo; - or something like that.  In fact that would be better.  That way you cover off more than &amp;ldquo;hybrid&amp;rdquo;.  You&amp;#39;ve included the things like &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; or &lt;a href="http://www.appcelerator.com/"&gt;Appcelerator&lt;/a&gt; as well.  You&amp;#39;ve moved away from implementation specifics at the point where they shouldn&amp;#39;t matter anyway!  Thats got to be a good thing.&lt;/p&gt;

&lt;h2&gt;Ah ha but what about Skills?&lt;/h2&gt;

&lt;p&gt;People go &amp;ldquo;hybrid&amp;rdquo; for another good reason - because they have no experience in the native platform.  I used to be one of those people but I&amp;#39;m not convinced that this is a good reason on its own.  If you want to make a compelling experience your limitation should never be your lack of skill.  Get skilled.  Obj-C isn&amp;#39;t as scary as it seems - in fact I&amp;#39;d rather write Obj-C than Java.  Dig deep - thats what we&amp;#39;ve got the internet for - understanding and learning (well that and porn).&lt;/p&gt;

&lt;h2&gt;Awareness and Education&lt;/h2&gt;

&lt;p&gt;So what am I saying?  Well for a start I&amp;#39;m not saying we totally abandon the word hybrid and mock anyone who uses it.  Hells no.  It&amp;#39;s still useful as I&amp;#39;ve already mentioned above. All I ask is that you make sure you know what you are talking about and that the people you are talking to know what you are talking about.  That and don&amp;#39;t just take the easy route because it&amp;#39;s easier for you.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;It&amp;#39;s fair to say over the past year or so I&amp;#39;ve dabbled in a bit of mobile development.  I&amp;#39;ve been involved in a number of  projects (from a technical perspective),&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web Based, Tablet Focused Analytics Dashboard (Custom HTML and &lt;a href="http://www.highcharts.com/"&gt;HighCharts&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Web Based, Tablet Focused Data Capture application (&lt;a href="http://www.sencha.com/products/touch"&gt;Sencha Touch&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Hybrid application for a teleco (&lt;a href="http://jquerymobile.com"&gt;jQuery Mobile&lt;/a&gt; and &lt;a href="http://phonegap.com"&gt;PhoneGap&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Mobile Hackathon (&lt;a href="http://jquerymobile.com"&gt;jQuery Mobile&lt;/a&gt; and &lt;a href="http://phonegap.com"&gt;PhoneGap&lt;/a&gt; and &lt;a href="http://parse.com"&gt;Parse&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Hybrid Application for a Bank (&lt;a href="http://www.sencha.com/products/touch"&gt;Sencha Touch&lt;/a&gt; and &lt;a href="http://phonegap.com"&gt;PhoneGap&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Various iPhone and iPad POCs for a health based project (&lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt;, XCode)&lt;/li&gt;
&lt;li&gt;Technology evaluations (Native Apple Development, &lt;a href="http://parse.com"&gt;Parse&lt;/a&gt;, &lt;a href="http://www.sencha.com/products/touch"&gt;Sencha Touch&lt;/a&gt;], &lt;a href="http://phonegap.com"&gt;PhoneGap&lt;/a&gt;, &lt;a href="http://nimblekit.com/index.php"&gt;NimbleKit&lt;/a&gt;, &lt;a href="http://jquerymobile.com"&gt;jQuery Mobile&lt;/a&gt;, &lt;a href="http://documentcloud.github.com/backbone/"&gt;Backbone&lt;/a&gt;, &lt;a href="http://spinejs.com"&gt;Spine.js&lt;/a&gt;, &lt;a href="http://www.appcelerator.com/"&gt;Appcelerator&lt;/a&gt;, &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt;, &lt;a href="http://android.xamarin.com/"&gt;Monodroid&lt;/a&gt; and plenty more&amp;hellip;)&lt;/li&gt;
&lt;li&gt;Consulted on various projects around the whole &amp;ldquo;native vs hybrid vs web&amp;rdquo; thing&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- more --&gt;

&lt;h2&gt;That Hybrid Word&lt;/h2&gt;

&lt;p&gt;One thing I&amp;#39;ve found is that many clients are using the old &amp;ldquo;a web app will never be as polished as a native app&amp;rdquo; argument but TBH that really isn&amp;#39;t the case.  This is down to a lack of real understanding and abuse of the word in the industry.  A bit of hybridism can go along way in creating a rich experience.&lt;/p&gt;

&lt;h3&gt;A Rose By Any Other Name&amp;hellip;&lt;/h3&gt;

&lt;p&gt;Many people break mobile applications into 3 VERY distinct areas,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Native&lt;/strong&gt; - app installed on the device, written using the default toolkit for that platform.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hybrid&lt;/strong&gt; - consists of a transparent &amp;ldquo;native&amp;rdquo; layer and a Web View into which HTML, JavaScript and CSS is loaded (generally stored within the native package).  The nativelayer provides and API for the JavaScript model in the Web View to call.  Think PhoneGap.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Web&lt;/strong&gt; - HTML, CSS, JavaScript assets hosted on the web and accessed from a mobile device.  Possibly some native-like features such as icons and removing the browser chrome.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The problem with the hybrid definition there is that it is, well, wrong.  There isn&amp;#39;t a clear distinction between the native and hybrid and there shouldn&amp;#39;t be.  If I spun up a Silverlight app that put a Web View in the middle to display some HTML I wouldn&amp;#39;t call it hybrid.  If I wrote an Android app that used a library written in Scala it wouldn&amp;#39;t be hybrid.  Or even if I wrote a Monotouch app using some bindings to the &lt;a href="http://www.flurry.com/"&gt;Flurry&lt;/a&gt; framework - nope not hybrid.&lt;/p&gt;

&lt;h3&gt;The Charting Example&lt;/h3&gt;

&lt;p&gt;A good example of &amp;ldquo;hybrid&amp;rdquo; is charting.  There aren&amp;#39;t a great deal of nice flexible charting libraries for iOS, but there is for JavaScript/HTML5.  So some of our projects have made use of HighCharts and Sencha Charting inside a transparent UIWebView to render charts that are flexible and rich.  I wouldn&amp;#39;t bother pinning the hybrid tag to that app - it&amp;#39;s simply making use of whatever technologies helped us get the job done in the best way possible.&lt;/p&gt;

&lt;p&gt;I understand the use of hybrid in sales pitches or to simply convey meaning to people who are less technical but the problem is people are starting to develop opinions based on these words alone which is disatorous.  I&amp;#39;ve had customers tell me that they want native because that hybrid stuff is ugly.  True some hybrid apps are ugly as sin (Aer Lingus iPhone app for one) but then so are some native ones.  It&amp;#39;s unfair to collectively throw away and entire type of app because of poorly misunderstood words.&lt;/p&gt;

&lt;h2&gt;But, But, But&amp;hellip; Reusability&lt;/h2&gt;

&lt;p&gt;People use the hybrid term to show that they have thought about portability.  Write once, run anywhere.  In that sense I guess using hybrid makes sense (but that sort of talk is really part of the sales talk right?).  But then it would be just as easy to say that &amp;ldquo;elements of the solution will be written in a platform agnostic language to minimise code rewrites on different devices&amp;rdquo; - or something like that.  In fact that would be better.  That way you cover off more than &amp;ldquo;hybrid&amp;rdquo;.  You&amp;#39;ve included the things like &lt;a href="http://xamarin.com/monotouch"&gt;MonoTouch&lt;/a&gt; or &lt;a href="http://www.appcelerator.com/"&gt;Appcelerator&lt;/a&gt; as well.  You&amp;#39;ve moved away from implementation specifics at the point where they shouldn&amp;#39;t matter anyway!  Thats got to be a good thing.&lt;/p&gt;

&lt;h2&gt;Ah ha but what about Skills?&lt;/h2&gt;

&lt;p&gt;People go &amp;ldquo;hybrid&amp;rdquo; for another good reason - because they have no experience in the native platform.  I used to be one of those people but I&amp;#39;m not convinced that this is a good reason on its own.  If you want to make a compelling experience your limitation should never be your lack of skill.  Get skilled.  Obj-C isn&amp;#39;t as scary as it seems - in fact I&amp;#39;d rather write Obj-C than Java.  Dig deep - thats what we&amp;#39;ve got the internet for - understanding and learning (well that and porn).&lt;/p&gt;

&lt;h2&gt;Awareness and Education&lt;/h2&gt;

&lt;p&gt;So what am I saying?  Well for a start I&amp;#39;m not saying we totally abandon the word hybrid and mock anyone who uses it.  Hells no.  It&amp;#39;s still useful as I&amp;#39;ve already mentioned above. All I ask is that you make sure you know what you are talking about and that the people you are talking to know what you are talking about.  That and don&amp;#39;t just take the easy route because it&amp;#39;s easier for you.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Chutzpah 1.3 Released</title>
    <link rel="alternate" href="/blog/2011/11/27/chutzpah-1-dot-3-released"/>
    <id>/blog/2011/11/27/chutzpah-1-dot-3-released</id>
    <published>2011-11-27T00:00:00+00:00</published>
    <updated>2011-11-27T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;I missed the announcement last week the &lt;a href="http://matthewmanela.com/blog/chutzpah-1-3-0-released/"&gt;Chutzpah 1.3 has been released&lt;/a&gt;.  This is a big release as it brings support for &lt;a href="http://pivotal.github.com/jasmine"&gt;Jasmine&lt;/a&gt; - my BDD framework of choice for JavaScript.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href="http://chutzpah.codeplex.com/"&gt;Chutzpah&lt;/a&gt; is available as a plugin for Visual Studio but more importantly as a command line runner which allows us to integrate JavaScript testing into our continuious integration builds.  Excellent stuff!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I missed the announcement last week the &lt;a href="http://matthewmanela.com/blog/chutzpah-1-3-0-released/"&gt;Chutzpah 1.3 has been released&lt;/a&gt;.  This is a big release as it brings support for &lt;a href="http://pivotal.github.com/jasmine"&gt;Jasmine&lt;/a&gt; - my BDD framework of choice for JavaScript.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href="http://chutzpah.codeplex.com/"&gt;Chutzpah&lt;/a&gt; is available as a plugin for Visual Studio but more importantly as a command line runner which allows us to integrate JavaScript testing into our continuious integration builds.  Excellent stuff!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Out with the old...</title>
    <link rel="alternate" href="/blog/2011/11/25/out-with-the-old-dot-dot-dot"/>
    <id>/blog/2011/11/25/out-with-the-old-dot-dot-dot</id>
    <published>2011-11-25T00:00:00+00:00</published>
    <updated>2011-11-25T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&amp;hellip; in with the new.  So I&amp;#39;ve started rolling out my new site, expect somethings to be slightly broken as images and whatnot have been moved around.  Spent a day or two designing a new site that was similar to the old one but slightly better.  Eventually got frustrated at my inability to do any sort of graphical design and went the &lt;a href="http://octopress.org"&gt;Octopress&lt;/a&gt;.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Still a few things to tweak, possibly add a splash of colour around the place and give it a bit more life.  Also apologies to people who subscribe to my feed - looks like the new feed has pushed all the old posts out as new.  But hey they are worth reading twice!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&amp;hellip; in with the new.  So I&amp;#39;ve started rolling out my new site, expect somethings to be slightly broken as images and whatnot have been moved around.  Spent a day or two designing a new site that was similar to the old one but slightly better.  Eventually got frustrated at my inability to do any sort of graphical design and went the &lt;a href="http://octopress.org"&gt;Octopress&lt;/a&gt;.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;Still a few things to tweak, possibly add a splash of colour around the place and give it a bit more life.  Also apologies to people who subscribe to my feed - looks like the new feed has pushed all the old posts out as new.  But hey they are worth reading twice!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Speaking at DevWeek 2012</title>
    <link rel="alternate" href="/blog/2011/11/17/speaking-at-devweek-2012"/>
    <id>/blog/2011/11/17/speaking-at-devweek-2012</id>
    <published>2011-11-17T00:00:00+00:00</published>
    <updated>2011-11-17T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;img src="http://www.devweek.com/pix/dwbanner2012c.jpg" style="width:100%" /&gt;&lt;/p&gt;

&lt;p&gt;So it&amp;#39;s been officially announced that I am talking at &lt;a href="http://devweek.com"&gt;DevWeek&lt;/a&gt; 2012 in London (26th - 30th March).  Looking at the names on the billing it&amp;#39;s quite weird seeing my name thrown in there, perhaps some one made a mistake :-P&lt;/p&gt;

&lt;!--more--&gt;

&lt;blockquote&gt;
&lt;h3&gt;BDD and .NET&lt;/h3&gt;

&lt;p&gt;Behaviour Driven Design/Development is an interesting premise, but does it really work? What benefits does it offer and how can we successfully apply its principles in the .NET world? We can answer these questions by reviewing the principles around BDD and diving into the technologies that exist in the .NET world that support these principles.&lt;/p&gt;

&lt;p&gt;From low-level unit focused testing technologies all the way up to the more abstract integration and acceptance level suite of specifications, automated testing and continuous integration, we will see that .NET isn’t lacking in choice. As a bonus we will address the oft ignored testing of our JavaScript project components using tools such as Jasmine and QUnit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The brief was written in haste and sounds a bit boilerplate but I will be giving it my all and really pull off an engaging session.  I&amp;#39;ve been at the attendee end of a few bad sessions and I will do my damnedest not to put anyone through that kind of ordeal.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://www.devweek.com/sessions/"&gt;line-up for DevWeek&lt;/a&gt; looks excellent and the pre/post conference workshops all look stellar - so much choice, I just need to find a way to clone myself.&lt;/p&gt;

&lt;p&gt;If you&amp;#39;re going - see you there, catch up with me and come throw tomatoes and/or abuse during my session.  If you&amp;#39;re not going, well sucks to be you then!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;img src="http://www.devweek.com/pix/dwbanner2012c.jpg" style="width:100%" /&gt;&lt;/p&gt;

&lt;p&gt;So it&amp;#39;s been officially announced that I am talking at &lt;a href="http://devweek.com"&gt;DevWeek&lt;/a&gt; 2012 in London (26th - 30th March).  Looking at the names on the billing it&amp;#39;s quite weird seeing my name thrown in there, perhaps some one made a mistake :-P&lt;/p&gt;

&lt;!--more--&gt;

&lt;blockquote&gt;
&lt;h3&gt;BDD and .NET&lt;/h3&gt;

&lt;p&gt;Behaviour Driven Design/Development is an interesting premise, but does it really work? What benefits does it offer and how can we successfully apply its principles in the .NET world? We can answer these questions by reviewing the principles around BDD and diving into the technologies that exist in the .NET world that support these principles.&lt;/p&gt;

&lt;p&gt;From low-level unit focused testing technologies all the way up to the more abstract integration and acceptance level suite of specifications, automated testing and continuous integration, we will see that .NET isn’t lacking in choice. As a bonus we will address the oft ignored testing of our JavaScript project components using tools such as Jasmine and QUnit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The brief was written in haste and sounds a bit boilerplate but I will be giving it my all and really pull off an engaging session.  I&amp;#39;ve been at the attendee end of a few bad sessions and I will do my damnedest not to put anyone through that kind of ordeal.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://www.devweek.com/sessions/"&gt;line-up for DevWeek&lt;/a&gt; looks excellent and the pre/post conference workshops all look stellar - so much choice, I just need to find a way to clone myself.&lt;/p&gt;

&lt;p&gt;If you&amp;#39;re going - see you there, catch up with me and come throw tomatoes and/or abuse during my session.  If you&amp;#39;re not going, well sucks to be you then!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Wednesday Tip: C# Type aliases</title>
    <link rel="alternate" href="/blog/2011/11/16/wednesday-tip-c-number-type-aliases"/>
    <id>/blog/2011/11/16/wednesday-tip-c-number-type-aliases</id>
    <published>2011-11-16T00:00:00+00:00</published>
    <updated>2011-11-16T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Ever written code that looks quite like this?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;Dictionary&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KeyValuePair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Dictionary&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KeyValuePair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I have.  Ugly and noisy isn&amp;#39;t it!  &amp;lt;!&amp;ndash;more&amp;ndash;&amp;gt; OK you could make it &lt;em&gt;slightly&lt;/em&gt; less noisy by using &lt;code&gt;var&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Dictionary&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KeyValuePair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or I suppose you could ahead and create yet another random type to abstract the implementation out of the way but thats just too much work for something internal to a class.&lt;/p&gt;

&lt;p&gt;Turns out you can make use of alises.  I&amp;#39;ve always known about using alises for namespaces to either resolve possible type conflicts or to make code a bit more understandable&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;CoreWeb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Web&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;CoreWeb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So this works with namespaces &lt;strong&gt;AND&lt;/strong&gt; types.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;Cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Dictionary&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KeyValuePair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This allows us to make the declaration above in a much nicer manner,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;Cache&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Cache&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;OK so there are way to many uses of the word cache there but you get the gist.  Handy to know.  Never knew this until today #youlearnsomethingneweveryday&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Ever written code that looks quite like this?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;Dictionary&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KeyValuePair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Dictionary&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KeyValuePair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I have.  Ugly and noisy isn&amp;#39;t it!  &amp;lt;!&amp;ndash;more&amp;ndash;&amp;gt; OK you could make it &lt;em&gt;slightly&lt;/em&gt; less noisy by using &lt;code&gt;var&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Dictionary&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KeyValuePair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or I suppose you could ahead and create yet another random type to abstract the implementation out of the way but thats just too much work for something internal to a class.&lt;/p&gt;

&lt;p&gt;Turns out you can make use of alises.  I&amp;#39;ve always known about using alises for namespaces to either resolve possible type conflicts or to make code a bit more understandable&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;CoreWeb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Web&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;CoreWeb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So this works with namespaces &lt;strong&gt;AND&lt;/strong&gt; types.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;using&lt;/span&gt; &lt;span class="n"&gt;Cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Dictionary&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;KeyValuePair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This allows us to make the declaration above in a much nicer manner,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;Cache&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Cache&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;OK so there are way to many uses of the word cache there but you get the gist.  Handy to know.  Never knew this until today #youlearnsomethingneweveryday&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Innovation Waffle</title>
    <link rel="alternate" href="/blog/2011/11/09/innovation-waffle"/>
    <id>/blog/2011/11/09/innovation-waffle</id>
    <published>2011-11-09T00:00:00+00:00</published>
    <updated>2011-11-09T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;There has been a lot of internal chatter at my employer around innovation.  A recent internal Hackathon produced some interesting, innovative stuff for using a Kinect in one of our projects and piqued peoples interest.  Oddly enough my dad reminded me of a quote the other day.&lt;/p&gt;

&lt;!--more--&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&amp;ldquo;If I had asked my customers what they wanted they would have said a faster horse&amp;rdquo;&lt;/em&gt; - Henry Ford&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Creating a &lt;em&gt;faster horse&lt;/em&gt; is considered &lt;strong&gt;sustaining innovation&lt;/strong&gt; - you&amp;#39;re pushing boundaries but you aren&amp;#39;t breaking into new markets.  Instead, what Ford did was create the &lt;a href="http://en.wikipedia.org/wiki/Ford_Model_T"&gt;Ford Model T&lt;/a&gt;, the first affordable automobile.  This &lt;strong&gt;disruptive innovation&lt;/strong&gt; changed everything, breaking into new markets and created value where once no value existed.&lt;/p&gt;

&lt;p&gt;To be truly innovative you need both a &lt;strong&gt;need&lt;/strong&gt; and the &lt;strong&gt;technology&lt;/strong&gt; to achieve it.  The &lt;strong&gt;need&lt;/strong&gt; doesn&amp;#39;t even need to be particularly complex (in Fords case it was the need to go faster), the &lt;strong&gt;technology&lt;/strong&gt; doesn&amp;#39;t even need to be revolutionary - just applied in a different manner (in my employers case the Kinect).&lt;/p&gt;

&lt;p&gt;But to really succeed in this innovation you need the ability to marry these with something.  That something is a &lt;strong&gt;vision&lt;/strong&gt;.  Ford realised the need and he was capable of harnessing technology to address that need in such a way as to disrupt the market.  This wouldn&amp;#39;t have been possible without Fords vision.  In fact he didn&amp;#39;t even really need to understand the detailed nuances of what the public needed, all he needed to know was the basic premise.  Arguably, even if he wasn&amp;#39;t the engineer, he could have got someone else to manage the technology.  Admittedly this opens up another avenue of discussion - the whole nature vs nurture aspect of innovation - but with a strong enough &lt;strong&gt;vision&lt;/strong&gt; I&amp;#39;m not sure that matters as much.&lt;/p&gt;

&lt;h2&gt;Vision is the Glue of Innovation&lt;/h2&gt;

&lt;p&gt;It&amp;#39;s great to have a &lt;strong&gt;need&lt;/strong&gt; you want to address, it&amp;#39;s even better to be able to apply all sorts of &lt;strong&gt;technology&lt;/strong&gt; to that need but odds are it will all come to nought without a strong &lt;strong&gt;vision&lt;/strong&gt;.  &lt;strong&gt;Vision is the glue of innovation&lt;/strong&gt;, while you need both need and technology they&amp;#39;ll never really stay together without that binding vision.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;There has been a lot of internal chatter at my employer around innovation.  A recent internal Hackathon produced some interesting, innovative stuff for using a Kinect in one of our projects and piqued peoples interest.  Oddly enough my dad reminded me of a quote the other day.&lt;/p&gt;

&lt;!--more--&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&amp;ldquo;If I had asked my customers what they wanted they would have said a faster horse&amp;rdquo;&lt;/em&gt; - Henry Ford&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Creating a &lt;em&gt;faster horse&lt;/em&gt; is considered &lt;strong&gt;sustaining innovation&lt;/strong&gt; - you&amp;#39;re pushing boundaries but you aren&amp;#39;t breaking into new markets.  Instead, what Ford did was create the &lt;a href="http://en.wikipedia.org/wiki/Ford_Model_T"&gt;Ford Model T&lt;/a&gt;, the first affordable automobile.  This &lt;strong&gt;disruptive innovation&lt;/strong&gt; changed everything, breaking into new markets and created value where once no value existed.&lt;/p&gt;

&lt;p&gt;To be truly innovative you need both a &lt;strong&gt;need&lt;/strong&gt; and the &lt;strong&gt;technology&lt;/strong&gt; to achieve it.  The &lt;strong&gt;need&lt;/strong&gt; doesn&amp;#39;t even need to be particularly complex (in Fords case it was the need to go faster), the &lt;strong&gt;technology&lt;/strong&gt; doesn&amp;#39;t even need to be revolutionary - just applied in a different manner (in my employers case the Kinect).&lt;/p&gt;

&lt;p&gt;But to really succeed in this innovation you need the ability to marry these with something.  That something is a &lt;strong&gt;vision&lt;/strong&gt;.  Ford realised the need and he was capable of harnessing technology to address that need in such a way as to disrupt the market.  This wouldn&amp;#39;t have been possible without Fords vision.  In fact he didn&amp;#39;t even really need to understand the detailed nuances of what the public needed, all he needed to know was the basic premise.  Arguably, even if he wasn&amp;#39;t the engineer, he could have got someone else to manage the technology.  Admittedly this opens up another avenue of discussion - the whole nature vs nurture aspect of innovation - but with a strong enough &lt;strong&gt;vision&lt;/strong&gt; I&amp;#39;m not sure that matters as much.&lt;/p&gt;

&lt;h2&gt;Vision is the Glue of Innovation&lt;/h2&gt;

&lt;p&gt;It&amp;#39;s great to have a &lt;strong&gt;need&lt;/strong&gt; you want to address, it&amp;#39;s even better to be able to apply all sorts of &lt;strong&gt;technology&lt;/strong&gt; to that need but odds are it will all come to nought without a strong &lt;strong&gt;vision&lt;/strong&gt;.  &lt;strong&gt;Vision is the glue of innovation&lt;/strong&gt;, while you need both need and technology they&amp;#39;ll never really stay together without that binding vision.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>GiveCamp Northern Ireland 2012</title>
    <link rel="alternate" href="/blog/2011/11/03/givecamp-northern-ireland-2012"/>
    <id>/blog/2011/11/03/givecamp-northern-ireland-2012</id>
    <published>2011-11-03T00:00:00+00:00</published>
    <updated>2011-11-03T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;&lt;img alt="GiveCamp" src="http://givecampni.org.uk/assets/img/givecamp-large-logo.png" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://givecampni.org.uk/"&gt;http://givecampni.org.uk/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Aint no backing out now son!  In 2012 there is going to be a Northern Ireland based &lt;a href="http://givecamp.org"&gt;GiveCamp&lt;/a&gt;.  The &amp;ldquo;Register Your Interest&amp;rdquo; placeholder site is now live at &lt;a href="http://givecampni.org.uk/"&gt;http://givecampni.org.uk/&lt;/a&gt; so if everyone can start spreading the word and getting excited that would be super awesome.&lt;/p&gt;

&lt;p&gt;Any tips, advice or help at this point is also really welcome.&lt;/p&gt;

&lt;p&gt;Let the fun begin&amp;hellip;.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;&lt;img alt="GiveCamp" src="http://givecampni.org.uk/assets/img/givecamp-large-logo.png" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://givecampni.org.uk/"&gt;http://givecampni.org.uk/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Aint no backing out now son!  In 2012 there is going to be a Northern Ireland based &lt;a href="http://givecamp.org"&gt;GiveCamp&lt;/a&gt;.  The &amp;ldquo;Register Your Interest&amp;rdquo; placeholder site is now live at &lt;a href="http://givecampni.org.uk/"&gt;http://givecampni.org.uk/&lt;/a&gt; so if everyone can start spreading the word and getting excited that would be super awesome.&lt;/p&gt;

&lt;p&gt;Any tips, advice or help at this point is also really welcome.&lt;/p&gt;

&lt;p&gt;Let the fun begin&amp;hellip;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Nancy JSONP Hook</title>
    <link rel="alternate" href="/blog/2011/11/01/nancy-jsonp-hook"/>
    <id>/blog/2011/11/01/nancy-jsonp-hook</id>
    <published>2011-11-01T00:00:00+00:00</published>
    <updated>2011-11-01T00:00:00+00:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;3 Nov 2011: As of Nancy v0.9 this is part of the core (same logic applies)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I needed to write a simple JSONP capable service recently and decided to run with &lt;a href="http://nancyfx.org"&gt;Nancy&lt;/a&gt;.  Turns out Nancy doesn&amp;#39;t give us a way to do JSONP so I set about creating something that fitted my use case.  The fruits of my very very short labour (thanks to the super-hyper-flexible-powerfulness of the Nancy Pipeline) can be seen here.  The full source is available in the &lt;a href="https://github.com/kouphax/nancy-jsonp"&gt;Github repo&lt;/a&gt; and hopefully we can get this pushed into the core of Nancy shortly (or at least part of the official repo one way or another) - just for the geek cred of course :)&lt;/p&gt;

&lt;!--more--&gt;

&lt;h2&gt;Implementation Rundown&lt;/h2&gt;

&lt;p&gt;I took the same approach as the existing hooks (using the SassAndCoffee one as my implementation pattern) so created a static &lt;code&gt;Hooks&lt;/code&gt; class with an &lt;code&gt;Enable&lt;/code&gt; method that simply adds a new item to the end of the pipeline&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// Enable JSONP support in the application&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;param name=&amp;quot;pipeline&amp;quot;&amp;gt;Application Pipeline to Hook into&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;static&lt;/span&gt; &lt;span class="bp"&gt;void&lt;/span&gt; &lt;span class="nx"&gt;Enable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;IApplicationPipelines&lt;/span&gt; &lt;span class="nx"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;pipeline.AfterRequest.AddItemToEndOfPipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PrepareJsonp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The meat of the work lies in the &lt;code&gt;PrepareJsonp&lt;/code&gt; method&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// Transmogrify original response and apply JSONP Padding&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;Current Nancy Context&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;static&lt;/span&gt; &lt;span class="bp"&gt;void&lt;/span&gt; &lt;span class="nx"&gt;PrepareJsonp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;NancyContext&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isJson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;context.Response.ContentType&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;hasCallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;context.Request.Query&lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;callback&amp;quot;&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;.HasValue;

    if (isJson &lt;span class="err"&gt;&amp;amp;&amp;amp;&lt;/span&gt; hasCallback)
    {
        // grab original contents for running later
        Action&lt;span class="nt"&gt;&amp;lt;Stream&amp;gt;&lt;/span&gt; original = context.Response.Contents;
        string callback = context.Request.Query&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;callback&amp;quot;&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;.Value;

        // set content type to application/javascript so browsers can handle it by default
        // http://stackoverflow.com/questions/111302/best-content-type-to-serve-jsonp
        context.Response.ContentType = &amp;quot;application/javascript&amp;quot;;
        context.Response.Contents = stream =&amp;gt;
        {
            // disposing of stream is handled elsewhere
            StreamWriter writer = new StreamWriter(stream)
            {
                AutoFlush = true
            };

            writer.Write(&amp;quot;{0}(&amp;quot;, callback);
            original(stream);
            writer.Write(&amp;quot;);&amp;quot;);
        };
    }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let me highlight a few of the key areas here.&lt;/p&gt;

&lt;h3&gt;Determine if Response need JSONP Padded&lt;/h3&gt;

&lt;p&gt;I decided to take a basic approach to determining if the request should return a JSONP response,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the content type of the current response is &lt;code&gt;application/json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;If there is a query string parameter called &lt;code&gt;callback&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is what we need to satisfy that,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isJson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContentType&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;hasCallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;callback&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;HasValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isJson&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;hasCallback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I am sure this could be refined and open to suggestion (perhaps more applicable content types or extra possible configuration for the callback parameter).  I wonder if it is a bit safer to restrict requests that are GET requests seeing as that is the only way to do JSONP? Hmmmm.&lt;/p&gt;

&lt;p&gt;Next thing I set the content type to &lt;code&gt;application/javascript&lt;/code&gt; as that makes perfect sense&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContentType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;application/javascript&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally I wrap the original responses content in the JSONP &amp;ldquo;padding&amp;rdquo; (the callback function) and write everything out.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Contents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// disposing of stream is handled elsewhere&lt;/span&gt;
    &lt;span class="n"&gt;StreamWriter&lt;/span&gt; &lt;span class="n"&gt;writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;StreamWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;AutoFlush&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;{0}(&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;original&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;);&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So all in all very simple but damn I&amp;#39;m proud that I got off my arse and contributed to such a stellar community. hopefully someone finds this useful.&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;3 Nov 2011: As of Nancy v0.9 this is part of the core (same logic applies)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I needed to write a simple JSONP capable service recently and decided to run with &lt;a href="http://nancyfx.org"&gt;Nancy&lt;/a&gt;.  Turns out Nancy doesn&amp;#39;t give us a way to do JSONP so I set about creating something that fitted my use case.  The fruits of my very very short labour (thanks to the super-hyper-flexible-powerfulness of the Nancy Pipeline) can be seen here.  The full source is available in the &lt;a href="https://github.com/kouphax/nancy-jsonp"&gt;Github repo&lt;/a&gt; and hopefully we can get this pushed into the core of Nancy shortly (or at least part of the official repo one way or another) - just for the geek cred of course :)&lt;/p&gt;

&lt;!--more--&gt;

&lt;h2&gt;Implementation Rundown&lt;/h2&gt;

&lt;p&gt;I took the same approach as the existing hooks (using the SassAndCoffee one as my implementation pattern) so created a static &lt;code&gt;Hooks&lt;/code&gt; class with an &lt;code&gt;Enable&lt;/code&gt; method that simply adds a new item to the end of the pipeline&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// Enable JSONP support in the application&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;param name=&amp;quot;pipeline&amp;quot;&amp;gt;Application Pipeline to Hook into&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;static&lt;/span&gt; &lt;span class="bp"&gt;void&lt;/span&gt; &lt;span class="nx"&gt;Enable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;IApplicationPipelines&lt;/span&gt; &lt;span class="nx"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;pipeline.AfterRequest.AddItemToEndOfPipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PrepareJsonp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The meat of the work lies in the &lt;code&gt;PrepareJsonp&lt;/code&gt; method&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// Transmogrify original response and apply JSONP Padding&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;param name=&amp;quot;context&amp;quot;&amp;gt;Current Nancy Context&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;static&lt;/span&gt; &lt;span class="bp"&gt;void&lt;/span&gt; &lt;span class="nx"&gt;PrepareJsonp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;NancyContext&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isJson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;context.Response.ContentType&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;hasCallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;context.Request.Query&lt;/span&gt;&lt;span class="err"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;callback&amp;quot;&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;.HasValue;

    if (isJson &lt;span class="err"&gt;&amp;amp;&amp;amp;&lt;/span&gt; hasCallback)
    {
        // grab original contents for running later
        Action&lt;span class="nt"&gt;&amp;lt;Stream&amp;gt;&lt;/span&gt; original = context.Response.Contents;
        string callback = context.Request.Query&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;callback&amp;quot;&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;.Value;

        // set content type to application/javascript so browsers can handle it by default
        // http://stackoverflow.com/questions/111302/best-content-type-to-serve-jsonp
        context.Response.ContentType = &amp;quot;application/javascript&amp;quot;;
        context.Response.Contents = stream =&amp;gt;
        {
            // disposing of stream is handled elsewhere
            StreamWriter writer = new StreamWriter(stream)
            {
                AutoFlush = true
            };

            writer.Write(&amp;quot;{0}(&amp;quot;, callback);
            original(stream);
            writer.Write(&amp;quot;);&amp;quot;);
        };
    }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let me highlight a few of the key areas here.&lt;/p&gt;

&lt;h3&gt;Determine if Response need JSONP Padded&lt;/h3&gt;

&lt;p&gt;I decided to take a basic approach to determining if the request should return a JSONP response,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the content type of the current response is &lt;code&gt;application/json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;If there is a query string parameter called &lt;code&gt;callback&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is what we need to satisfy that,&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isJson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContentType&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;hasCallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;callback&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;HasValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isJson&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;hasCallback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I am sure this could be refined and open to suggestion (perhaps more applicable content types or extra possible configuration for the callback parameter).  I wonder if it is a bit safer to restrict requests that are GET requests seeing as that is the only way to do JSONP? Hmmmm.&lt;/p&gt;

&lt;p&gt;Next thing I set the content type to &lt;code&gt;application/javascript&lt;/code&gt; as that makes perfect sense&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContentType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;application/javascript&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally I wrap the original responses content in the JSONP &amp;ldquo;padding&amp;rdquo; (the callback function) and write everything out.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Contents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// disposing of stream is handled elsewhere&lt;/span&gt;
    &lt;span class="n"&gt;StreamWriter&lt;/span&gt; &lt;span class="n"&gt;writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;StreamWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;AutoFlush&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;{0}(&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;original&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;);&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So all in all very simple but damn I&amp;#39;m proud that I got off my arse and contributed to such a stellar community. hopefully someone finds this useful.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Tinyweb.FluentSecurity v0.1 Released</title>
    <link rel="alternate" href="/blog/2011/10/19/tinyweb-dot-fluentsecurity-v0-dot-1-released"/>
    <id>/blog/2011/10/19/tinyweb-dot-fluentsecurity-v0-dot-1-released</id>
    <published>2011-10-19T00:00:00+01:00</published>
    <updated>2011-10-19T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;Slight change here - FluentSecurity is now FluentAuth to avoid any confusion with a similarly named product of which there is some inspiration taken.  Anyway on with the original post&amp;hellip;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src="http://yobriefca.se/projects/fluentauth/images/logo.png" style="float:right;height:150px;" /&gt;&lt;/p&gt;

&lt;p&gt;I have procrastinated long enough on this and it was blocking some of the other work I wanted to get on with.  I have just pushed v0.1 to Nuget and launched the &lt;a href="http://yobriefca.se/projects/fluentauth/"&gt;site sans documentation&lt;/a&gt;.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Not a great deal has changed since my last announcement, well it has but it hasn&amp;#39;t been documented as it should be backwards compatible.  Just a few more configuration options that I&amp;#39;ll explain once I get the documentation rolled out.&lt;/p&gt;

&lt;script type="text/javascript"&gt;
    (function () {
        var nb = document.createElement('script'); nb.type = 'text/javascript'; nb.async = true;
        nb.src = 'http://s.prabir.me/nuget-button/0.2.1/nuget-button.min.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(nb, s);
    })();
&lt;/script&gt;

&lt;pre class="nuget-button"&gt;Install-Package Tinyweb.FluentAuth&lt;/pre&gt;

&lt;p&gt;So go check it out and hopefully you&amp;#39;ll find it useful - plenty of plans for expansion to other frameworks and some more API changes coming too.  Now back to procrastinating.&lt;/p&gt;
</summary>
    <content type="html">&lt;blockquote&gt;
&lt;p&gt;Slight change here - FluentSecurity is now FluentAuth to avoid any confusion with a similarly named product of which there is some inspiration taken.  Anyway on with the original post&amp;hellip;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src="http://yobriefca.se/projects/fluentauth/images/logo.png" style="float:right;height:150px;" /&gt;&lt;/p&gt;

&lt;p&gt;I have procrastinated long enough on this and it was blocking some of the other work I wanted to get on with.  I have just pushed v0.1 to Nuget and launched the &lt;a href="http://yobriefca.se/projects/fluentauth/"&gt;site sans documentation&lt;/a&gt;.&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;Not a great deal has changed since my last announcement, well it has but it hasn&amp;#39;t been documented as it should be backwards compatible.  Just a few more configuration options that I&amp;#39;ll explain once I get the documentation rolled out.&lt;/p&gt;

&lt;script type="text/javascript"&gt;
    (function () {
        var nb = document.createElement('script'); nb.type = 'text/javascript'; nb.async = true;
        nb.src = 'http://s.prabir.me/nuget-button/0.2.1/nuget-button.min.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(nb, s);
    })();
&lt;/script&gt;

&lt;pre class="nuget-button"&gt;Install-Package Tinyweb.FluentAuth&lt;/pre&gt;

&lt;p&gt;So go check it out and hopefully you&amp;#39;ll find it useful - plenty of plans for expansion to other frameworks and some more API changes coming too.  Now back to procrastinating.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>refORM: Death to ORMs in .NET</title>
    <link rel="alternate" href="http://speakerdeck.com/u/kouphax/p/reform-death-to-orms-in-net"/>
    <id>http://speakerdeck.com/u/kouphax/p/reform-death-to-orms-in-net</id>
    <published>2011-10-17T00:00:00+01:00</published>
    <updated>2011-10-17T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>CoffeeScript the Awesome</title>
    <link rel="alternate" href="http://speakerdeck.com/u/kouphax/p/coffeescript-the-awesome"/>
    <id>http://speakerdeck.com/u/kouphax/p/coffeescript-the-awesome</id>
    <published>2011-10-10T00:00:00+01:00</published>
    <updated>2011-10-10T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>refORM: Death to ORMs in .NET</title>
    <link rel="alternate" href="http://speakerdeck.com/u/kouphax/p/reform-death-to-orms-in-net"/>
    <id>http://speakerdeck.com/u/kouphax/p/reform-death-to-orms-in-net</id>
    <published>2011-10-10T00:00:00+01:00</published>
    <updated>2011-10-10T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html"></summary>
    <content type="html"></content>
  </entry>
  <entry>
    <title>refORM: Death to ORMs in .NET</title>
    <link rel="alternate" href="/blog/2011/10/10/reform-death-to-orms-in-net"/>
    <id>/blog/2011/10/10/reform-death-to-orms-in-net</id>
    <published>2011-10-10T00:00:00+01:00</published>
    <updated>2011-10-10T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;Data Access is a difficult area to master. There are plenty of frameworks such as Entity Framework, NHibernate, i/myBatis. These frameworks attempt to make data access simpler but while these products are widely used they can lead to leaky abstractions forcing us to work around constraints of the technology or introduce the nightmare of trying to figure out what is happening deep down in the frameworks internals.&lt;/p&gt;

&lt;p&gt;In this session we will look at the various lightweight alternatives and the advantages they offer as well as provide rationale about why the more heavyweight approach isn&amp;#39;t always the best approach.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href="https://bitbucket.org/kouphax/ddd-data-access/"&gt;Demo Code and Examples&lt;/a&gt;&lt;/p&gt;

&lt;script src="http://speakerdeck.com/embed/4eb7ebb05040b9005400eb4f.js"&gt;&lt;/script&gt;
</summary>
    <content type="html">&lt;p&gt;Data Access is a difficult area to master. There are plenty of frameworks such as Entity Framework, NHibernate, i/myBatis. These frameworks attempt to make data access simpler but while these products are widely used they can lead to leaky abstractions forcing us to work around constraints of the technology or introduce the nightmare of trying to figure out what is happening deep down in the frameworks internals.&lt;/p&gt;

&lt;p&gt;In this session we will look at the various lightweight alternatives and the advantages they offer as well as provide rationale about why the more heavyweight approach isn&amp;#39;t always the best approach.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;a href="https://bitbucket.org/kouphax/ddd-data-access/"&gt;Demo Code and Examples&lt;/a&gt;&lt;/p&gt;

&lt;script src="http://speakerdeck.com/embed/4eb7ebb05040b9005400eb4f.js"&gt;&lt;/script&gt;
</content>
  </entry>
  <entry>
    <title>CoffeeScript the Awesome</title>
    <link rel="alternate" href="/blog/2011/10/10/coffeescript-the-awesome"/>
    <id>/blog/2011/10/10/coffeescript-the-awesome</id>
    <published>2011-10-10T00:00:00+01:00</published>
    <updated>2011-10-10T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;CoffeeScript - &amp;ldquo;a little language that compiles into JavaScript&amp;rdquo; has been making a lot of noise in the web community with its inclusion in Ruby on Rail v3 and its swift rise in popularity on Github.&lt;/p&gt;

&lt;p&gt;This session will look at the benefits this language brings over the native JavaScript alternative, the syntactical double rainbow it creates, the problems you&amp;#39;ll face and of course how you can actually use it in different technology stacks such as Ruby, node.js, .NET and Java.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;script src="http://speakerdeck.com/embed/4eb7effc5040b9005100f937.js"&gt;&lt;/script&gt;
</summary>
    <content type="html">&lt;p&gt;CoffeeScript - &amp;ldquo;a little language that compiles into JavaScript&amp;rdquo; has been making a lot of noise in the web community with its inclusion in Ruby on Rail v3 and its swift rise in popularity on Github.&lt;/p&gt;

&lt;p&gt;This session will look at the benefits this language brings over the native JavaScript alternative, the syntactical double rainbow it creates, the problems you&amp;#39;ll face and of course how you can actually use it in different technology stacks such as Ruby, node.js, .NET and Java.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;script src="http://speakerdeck.com/embed/4eb7effc5040b9005100f937.js"&gt;&lt;/script&gt;
</content>
  </entry>
  <entry>
    <title>DDDNorth Retrospective</title>
    <link rel="alternate" href="/blog/2011/10/09/dddnorth-retrospective"/>
    <id>/blog/2011/10/09/dddnorth-retrospective</id>
    <published>2011-10-09T00:00:00+01:00</published>
    <updated>2011-10-09T00:00:00+01:00</updated>
    <author>
      <name>James Hughes</name>
    </author>
    <summary type="html">&lt;p&gt;So its the day after DDD North and I&amp;#39;m more or less getting packed and ready to do the long boring travel bit home, which is really less travelling and more waiting around.  Anyway DDD North was pretty special.  Excellent turn out, great location and above all some great talks.  My talk (refORM: Death to ORMs in .NET) had a technical problem with the projector which meant the live demo section I wove in since last weeks talk had to be abandoned, shit happens.  It also went very fast, the talk was over in about 35 minutes but at least there was plenty of banter and questions - so at least the people seemed to be engaged.  Enough about my woes.  I&amp;#39;ll have the slides and the (super secret) demo code available as soon as get back home.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;So what about the rest of the talks?&lt;/p&gt;

&lt;h2&gt;Commercial Software Development - Writing Software Is Easy, Not Going Bust is the Hard Bit - Liam Westley&lt;/h2&gt;

&lt;p&gt;Liam took us through some of his personal experience of working in the industry as a sole(ish) trader.  He highlighted some of the things that you should really be doing to ensure you aren&amp;#39;t &amp;ldquo;wasting time&amp;rdquo; and raised a very valid point - every time you take a support call you are bleeding money.  Makes sense but I initially rebelled against this premise.  I had wrongly jumped to the conclusion that if you don&amp;#39;t get support calls you don&amp;#39;t need a support contract - which in hindsight is pretty stupid of me.&lt;/p&gt;

&lt;p&gt;He also highlighted that if the phone does ring, or a support issue is raised then you need to make sure you have all the information at hand.  Detailed logging of crucial areas of your system, automated emails or tweets when the system detects something is wrong and generally making sure you don&amp;#39;t need to rely on the end user to tell you what has went wrong.  Again makes perfect sense.  Obviously writing good code that is well tested prior to release is another winner in this area.&lt;/p&gt;

&lt;p&gt;In terms of releases he re-iterated the old &amp;ldquo;release early&amp;rdquo; mantra.  You don&amp;#39;t want to waste time writing features that no one is going to use and you aren&amp;#39;t really going to know this until users have the product in their hands - the minimum viable product.&lt;/p&gt;

&lt;p&gt;All in all a great session, nothing massively new for me here but I love hearing this stuff from people with real experience in it - it really helps solidify my beliefs in good code and early release.&lt;/p&gt;

&lt;h2&gt;&amp;ldquo;The Happy Programmer&amp;rdquo; - Is It a Myth? - Andy Gibson&lt;/h2&gt;

&lt;p&gt;Looking the various aspects of a developers life that determine if it is truly possible to have a &amp;ldquo;happy developer&amp;rdquo;.  A fair amount of audience participation looking at the best office type, the rationale for having the best hardware and all that other stuff.&lt;/p&gt;

&lt;h2&gt;Continuous Delivery - Paul Stack&lt;/h2&gt;

&lt;p&gt;Certainly the highlight of the day for me.  Many people I work with believe that CD is a long way off for many projects but there was so much hard evidence at this talk that debunked this theory.  If it can be scripted or automated in anyway it should be.  This includes HTML, JS, CSS, and C# code analysis, unit tests, acceptance tests, environment configuration, document generation, Sharepoint config and setup (yep that to), VM rollout, DB upgrades and backups.  Everything really.&lt;/p&gt;

&lt;p&gt;A great example of this was a massive search engine in Norway that turned their 2 &amp;frac12; year release cycle into once every 4 hours.  This wasn&amp;#39;t some big massive leap, it was done by gradually shortening the release cycle and tightening up the processes bit by bit till they got there.&lt;/p&gt;

&lt;p&gt;A good point was raised on this topic later in the evening - CI/CD scripts should be the very first thing you do on a project.  Then you build them up gradually as and when you need to.  No point in waiting till the end of the first release do this - it&amp;#39;ll hurt way too much and never get done.&lt;/p&gt;

&lt;h2&gt;The 10 Habits of Highly Effective Programmers - Dennis Doomen&lt;/h2&gt;

&lt;p&gt;The last session, and after being up since 4AM I was wrecked.  But you know what?  Even with the tiredness and the heat of the room I remained engaged.  Again a lot of the topics in this talk I was already very familiar with but it was great to get a different perspective and new techniques for achieving them.  Also managed to increase my &amp;ldquo;To Read&amp;rdquo; list with a few books from this session.  Nice way to finish off the day.&lt;/p&gt;

&lt;h2&gt;Grok Talks&lt;/h2&gt;

&lt;p&gt;Through lunchtime there were a number of quick, informal grok talks.  The one I want to mention was on &amp;ldquo;teaching your kids to code&amp;rdquo; and showed various tools/games like LightBot and SmallBasic - my son is still a tiny bit young for this sort of thing but he&amp;#39;ll probably be forced to do some of this with me being his dad.  I&amp;#39;d also have liked to have seen Scratch (from MIT) mentioned as this is a similar technology.&lt;/p&gt;

&lt;p&gt;Overall the day was beyond my expectations - plenty of refreshments, goodies, decent food and great people.  To be honest I really felt like a small fish presenting though - after seeing the other guys I felt my delivery was decidedly amateur.  But hey thats why I am doing this - to get better.  Looking forward to the next one!  Thanks everyone.&lt;/p&gt;

&lt;p&gt;Next up I have GOTOAmsterdam (this Wednesday).  Funnily enough I need to find my passport ASAP as 2 minutes after jokingly saying &amp;ldquo;Wouldn&amp;#39;t it be funny if I couldn&amp;#39;t find my passport?&amp;rdquo; to my wife, well, you can probably guess what happened.  So not only did I look like a dick in-front of my lovely wife I also managed to put my GOTO conf attendance in jeopardy - hell I really am a dick!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;So its the day after DDD North and I&amp;#39;m more or less getting packed and ready to do the long boring travel bit home, which is really less travelling and more waiting around.  Anyway DDD North was pretty special.  Excellent turn out, great location and above all some great talks.  My talk (refORM: Death to ORMs in .NET) had a technical problem with the projector which meant the live demo section I wove in since last weeks talk had to be abandoned, shit happens.  It also went very fast, the talk was over in about 35 minutes but at least there was plenty of banter and questions - so at least the people seemed to be engaged.  Enough about my woes.  I&amp;#39;ll have the slides and the (super secret) demo code available as soon as get back home.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;So what about the rest of the talks?&lt;/p&gt;

&lt;h2&gt;Commercial Software Development - Writing Software Is Easy, Not Going Bust is the Hard Bit - Liam Westley&lt;/h2&gt;

&lt;p&gt;Liam took us through some of his personal experience of working in the industry as a sole(ish) trader.  He highlighted some of the things that you should really be doing to ensure you aren&amp;#39;t &amp;ldquo;wasting time&amp;rdquo; and raised a very valid point - every time you take a support call you are bleeding money.  Makes sense but I initially rebelled against this premise.  I had wrongly jumped to the conclusion that if you don&amp;#39;t get support calls you don&amp;#39;t need a support contract - which in hindsight is pretty stupid of me.&lt;/p&gt;

&lt;p&gt;He also highlighted that if the phone does ring, or a support issue is raised then you need to make sure you have all the information at hand.  Detailed logging of crucial areas of your system, automated emails or tweets when the system detects something is wrong and generally making sure you don&amp;#39;t need to rely on the end user to tell you what has went wrong.  Again makes perfect sense.  Obviously writing good code that is well tested prior to release is another winner in this area.&lt;/p&gt;

&lt;p&gt;In terms of releases he re-iterated the old &amp;ldquo;release early&amp;rdquo; mantra.  You don&amp;#39;t want to waste time writing features that no one is going to use and you aren&amp;#39;t really going to know this until users have the product in their hands - the minimum viable product.&lt;/p&gt;

&lt;p&gt;All in all a great session, nothing massively new for me here but I love hearing this stuff from people with real experience in it - it really helps solidify my beliefs in good code and early release.&lt;/p&gt;

&lt;h2&gt;&amp;ldquo;The Happy Programmer&amp;rdquo; - Is It a Myth? - Andy Gibson&lt;/h2&gt;

&lt;p&gt;Looking the various aspects of a developers life that determine if it is truly possible to have a &amp;ldquo;happy developer&amp;rdquo;.  A fair amount of audience participation looking at the best office type, the rationale for having the best hardware and all that other stuff.&lt;/p&gt;

&lt;h2&gt;Continuous Delivery - Paul Stack&lt;/h2&gt;

&lt;p&gt;Certainly the highlight of the day for me.  Many people I work with believe that CD is a long way off for many projects but there was so much hard evidence at this talk that debunked this theory.  If it can be scripted or automated in anyway it should be.  This includes HTML, JS, CSS, and C# code analysis, unit tests, acceptance tests, environment configuration, document generation, Sharepoint config and setup (yep that to), VM rollout, DB upgrades and backups.  Everything really.&lt;/p&gt;

&lt;p&gt;A great example of this was a massive search engine in Norway that turned their 2 &amp;frac12; year release cycle into once every 4 hours.  This wasn&amp;#39;t some big massive leap, it was done by gradually shortening the release cycle