<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>James Gregory &#187; Uncategorized</title>
	<atom:link href="http://jagregory.com/writings/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://jagregory.com</link>
	<description>Monkeying with the code</description>
	<lastBuildDate>Tue, 22 Jun 2010 11:07:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>NDC 2010</title>
		<link>http://jagregory.com/writings/ndc-2010/</link>
		<comments>http://jagregory.com/writings/ndc-2010/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 11:00:51 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[FluentNHibernate]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[ndc]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://jagregory.com/?p=402</guid>
		<description><![CDATA[NDC 2010 was a huge success, if you ask me. This was largely down to the NDC team, who deserve all the praise they&#8217;re getting (and much more). Unlike conferences I&#8217;ve been to in the past, NDC was truely by the people, for the people. Scott Bellware put it much better than I could, with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ndc2010.no">NDC 2010</a> was a huge success, if you ask me. This was largely down to the NDC team, who deserve all the praise they&#8217;re getting (and much more). Unlike conferences I&#8217;ve been to in the past, NDC was truely by the people, for the people. <a href="http://blog.scottbellware.com">Scott Bellware</a> put it much better than I could, with his <a href="http://blog.scottbellware.com/2010/06/praise-for-norwegian-developers.html">praise for Norwegian Developers</a> (and Kjersti Sandberg). Herself and the rest of the team were there because they wanted to be, not because they had to. The whole attitude surrounding this conference was one of learning, not plugging products or motives.</p>
<p>I could go into great detail about the individual aspects of the conference, but it&#8217;s much easier to say that there&#8217;s nothing I&#8217;d change.</p>
<p>If there&#8217;s one conference you should go to next year, make it NDC 2011.</p>
<h2>My part in all this&#8230;</h2>
<p>I presented on two topics at NDC; the first was an introduction to <a href="http://fluentnhibernate.org">Fluent NHibernate</a>, and the second an introduction and demo of <a href="http://git-scm.com">Git</a>. Fluent NHibernate was on the Thursday, and Git the Friday. It was a great experience speaking at an event of this size, and the number of people who seemed genuinely interested in what I had to say (by either turning up to my talks, or approaching me afterwards) was quite humbling. If you&#8217;re interested in seeing what I presented, the talks will be on the NDC website before too long.</p>
<blockquote><p>The videos are becoming available at <a href="http://streaming.ndc2010.no">streaming.ndc2010.no</a>, but they&#8217;re suffering from bandwidth issues. If you do want to watch the videos, please stream them until the issues are resolved.</p></blockquote>
<p>Due to me speaking, and also being woefully unprepared, I didn&#8217;t get to see as many talks as I would&#8217;ve liked &mdash; regardless of how well rehearsed and prepared my talks are, it seems I always end up rewriting them an hour before I go on &mdash; I did end up catching Lisa Crispin, Steve Strong, Eric Evans, Greg Young, Jon Skeet, Roy Osherove, Michael Feathers, Sebastian Lambla, and Mark Nijhof. I recommend you catch their talks online when they&#8217;re published. The quality of the talks at NDC have been significantly higher than I&#8217;ve seen elsewhere, and (more importantly) the technical level seems to be higher too; there was very few basic talks (a few introductions, mine included, but no pandering), but the majority were pretty in-depth. This is quite a contrast to the all-too-often &#8220;Microsoft technology of the week&#8221; presentations you can get at conferences.</p>
<p>Of course, a big part of any conference is what happens between (and after) the talks. Meeting other developers is a big part of why I go to these things, after all I don&#8217;t get out much normally. The socialising aspect of NDC was excellent, good drinks and food was had by all (I have a good idea they did anyway, at least one place we ate refused to serve us as a group anything other than the same meal for everyone!). I can&#8217;t possibly list everyone who I met while I was out there, but it was really good to meet up with some people who I&#8217;ve known on Twitter for a long time; specifically Hadi Hariri, Steve Strong, Greg Young, Ben Hall, Seb Lambla, Mark Nijhof, and Rob Conery are ones that stand out to me right now.</p>
<p>NDC 2011 will be next year, and it&#8217;s looking like it&#8217;ll be in May this time. If there&#8217;s anyone that&#8217;s on the fence about going, I would whole heartedly recommend you do. Even more so, I&#8217;d recommend you submit a talk of your own. It&#8217;s a great way to test yourself, if nothing else. I&#8217;ll definitely be going next year; hopefully I&#8217;ll speak again, but if not I&#8217;ll still be there. Hope to see you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/ndc-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speaking engagements in 2010</title>
		<link>http://jagregory.com/writings/speaking-engagements-2010/</link>
		<comments>http://jagregory.com/writings/speaking-engagements-2010/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 13:10:31 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://jagregory.com/?p=394</guid>
		<description><![CDATA[In an attempt to get out of my shell more this year, I&#8217;ve taken up speaking (at conferences, not just in general). First came my Git E-VAN, then came Pablo&#8217;s Fiesta, so what else have I got lined up this year?
24th April: Irish Open Spaces Coding Day II in Dublin, where I&#8217;ll be speaking about [...]]]></description>
			<content:encoded><![CDATA[<p>In an attempt to get out of my shell more this year, I&#8217;ve taken up speaking (at conferences, not just in general). First came my <a href="http://jagregory.com/writings/git-e-van-recording/">Git E-VAN</a>, then came <a href="http://fiesta.lostechies.com/">Pablo&#8217;s Fiesta</a>, so what else have I got lined up this year?</p>
<p><strong>24<sup>th</sup> April</strong>: <a href="http://codingday.org/">Irish Open Spaces Coding Day II</a> in Dublin, where I&#8217;ll be speaking about <a href="http://fluentnhibernate.org">Fluent NHibernate</a>.</p>
<p><strong>16<sup>th</sup>-18<sup>th</sup> June</strong>: <a href="http://ndc2010.no" title="Norwegian Developers Conference 2010">NDC 2010</a> in Oslo, speaking about <a href="http://fluentnhibernate.org">Fluent NHibernate</a> and DVCS with Git.</p>
<p>The abstracts for my talks can be found below. If you&#8217;re interested in hearing me speak, or know of any opportunities that you think I might be interested in, please drop me an email (<a href="mailto:james@jagregory.com">james@jagregory.com</a>). You can see my availability on my <a href="http://www.google.com/calendar/embed?src=mtbk7g2u13e2j7s1u8p0flitho@group.calendar.google.com&#038;ctz=Europe/London&#038;gsessionid=GBDJzqgaRWqAze87fNda9Q">speaking calendar</a>.</p>
<h3>Fluent NHibernate</h3>
<p>An introduction and overview to object⁄relational mapping using Fluent NHibernate. See how Fluent NHibernate can help you map your domain with the least amount of effort, how you can remain flexible with your database, and how to drive your design through convention–over–configuration; all without writing a single line of XML.</p>
<p>The talk is an introduction to Fluent NHibernate for those that aren&#8217;t familiar with it, and assumes some NHibernate experience and is for .Net developers primarily. The goal is to show people how low–impact NHibernate can be with Fluent NHibernate, and how it can actually speed up development in rapid–change environments.</p>
<p>I&#8217;ll cover an overview of what Fluent NHibernate is, the various parts of it (the fluent interface, the conventions, and the auto–mappings, and the configuration aspect), then expand on how these features can be utilised to improve your NHibernate experience and simplify your development process.</p>
<h3>Introduction to Git</h3>
<p>An introduction to distributed version control using Git, and how your VCS should work with you and not against you. How DVCS can completely alter your development process, streamline it, and help you produce better software, faster. Covering how local repositories speed up your development, multiple authoritative sources, distributed teams, multiple workflows, and some of the more distinct features of Git. With experiences from an OSS team on how the migration from SVN to Git has helped the project and changed how the team works (Fluent NHibernate).</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/speaking-engagements-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git E-VAN recording</title>
		<link>http://jagregory.com/writings/git-e-van-recording/</link>
		<comments>http://jagregory.com/writings/git-e-van-recording/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 10:43:44 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://jagregory.com/?p=386</guid>
		<description><![CDATA[Last monday (8th of Feb) I did an E-VAN on Git; an introductory talk on Git and DVCS, covering pretty much everything you need to know for day-to-day Git life. I think it went down well, certainly didn&#8217;t hear anyone complaining.
The talk was recorded, so if you haven&#8217;t already seen it then you can do [...]]]></description>
			<content:encoded><![CDATA[<p>Last monday (8th of Feb) I did an <a href="http://jagregory.com/writings/git-e-van/">E-VAN on Git</a>; an introductory talk on Git and DVCS, covering pretty much everything you need to know for day-to-day Git life. I think it went down well, certainly didn&#8217;t <em>hear</em> anyone complaining.</p>
<p>The talk was recorded, so if you haven&#8217;t already seen it then you can do so at your own leisure.</p>
<p>The video is up on the <a href="http://vimeo.com/user1286822">E-VAN&#8217;s Vimeo account</a>, specifically <a href="http://vimeo.com/9324683" title="Git E-VAN recording">here</a>.</p>
<p><object width="600" height="450"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=9324683&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=9324683&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/git-e-van-recording/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Git E-VAN</title>
		<link>http://jagregory.com/writings/git-e-van/</link>
		<comments>http://jagregory.com/writings/git-e-van/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 11:44:12 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://jagregory.com/?p=383</guid>
		<description><![CDATA[Just a reminder that tonight I&#8217;ll be doing an E-VAN on Git tonight at 7pm GMT.
It&#8217;s going to be a pretty basic talk on what Git is (and indirectly what DVCS is), and a demo on how to use most of the features you&#8217;ll need daily. There might be some advanced talk at the end, [...]]]></description>
			<content:encoded><![CDATA[<p>Just a reminder that tonight I&#8217;ll be doing an <a href="http://europevan.blogspot.com/2010/01/next-european-van-on-08-february-2010.html">E-VAN on Git</a> tonight at 7pm GMT.</p>
<p>It&#8217;s going to be a pretty basic talk on what Git is (and indirectly what DVCS is), and a demo on how to use most of the features you&#8217;ll need daily. There might be some advanced talk at the end, depending on how well I time things.</p>
<p>If you&#8217;ve already used Git (successfully), then this talk won&#8217;t really be for you; unless you just want to listen to me ramble for an hour and an half.</p>
<p>Looking forward to &#8220;seeing&#8221; you there. Now, I best finish reading that &#8220;Getting started with Git&#8221; book I&#8217;ve had lying around for months.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/git-e-van/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Git: Remotes, contributions, and the letter N</title>
		<link>http://jagregory.com/writings/git-remotes-contributions-and-the-letter-n/</link>
		<comments>http://jagregory.com/writings/git-remotes-contributions-and-the-letter-n/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 02:59:49 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://jagregory.com/?p=359</guid>
		<description><![CDATA[Here&#8217;s a few ways to think about Git and it&#8217;s distributed nature.

You deal with multiples of repositories, not a single central repository
Updates come from a remote repository, and changes are pushed to a remote; none of these repositories have to be the same
Origin is the canonical name for the repository you cloned from
Upstream is the [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a few ways to think about Git and it&#8217;s distributed nature.</p>
<ul>
<li>You deal with multiples of repositories, not a single central repository</li>
<li>Updates come from a remote repository, and changes are pushed to a remote; none of these repositories have to be the same</li>
<li><em>Origin</em> is the canonical name for the repository you cloned from</li>
<li><em>Upstream</em> is the canonical name for the original project repository you forked from</li>
</ul>
<h2>General pushing and pulling</h2>
<p style="text-align:center;"><img src="http://jagregory.com/wp-content/uploads/2010/02/remote-1.png" /></p>
<p>Pushing your changes to a remote: <code>git push remote_name</code></p>
<p style="text-align:center;"><img src="http://jagregory.com/wp-content/uploads/2010/02/remote-2.png" /></p>
<p>Pulling changes from a remote: <code>git pull remote_name</code></p>
<p>Or if you want to rebase:</p>
<pre>git fetch remote_name
git rebase remote_name/branch</pre>
<blockquote><p>You can change your <code>branch.autosetuprebase</code> to <code>always</code>, to make this the default <code>git pull</code> behaviour.</p></blockquote>
<p>That&#8217;s all there is to moving commits around in Git repositories. Any other operations you perform are all combinations of the above.</p>
<h2>Github &mdash; personal repositories</h2>
<p>When you&#8217;re dealing directly with Github, on a personal project or as the project owner, your repositories will look like this:</p>
<p style="text-align:center;"><img src="http://jagregory.com/wp-content/uploads/2010/02/remote-3.png" /></p>
<p>To push and pull changes between your local and your github repositories, just issue the push and pull commands with the origin remote:</p>
<pre>git push origin
git pull origin</pre>
<p>You can set the defaults for these commands too, so the origin isn&#8217;t even necessary in a lot of cases.</p>
<h2>Github &mdash; receiving contributions</h2>
<p>As a project owner, you&#8217;ll sometimes have to deal with contributions from other people. Each contributor will have their own github repository, and they&#8217;ll issue you with a pull request.</p>
<p style="text-align:center;"><img src="http://jagregory.com/wp-content/uploads/2010/02/remote-4.png" /></p>
<p>There&#8217;s no direct link to push between these two repositories; they&#8217;re unmanned. To manage changes from contributors, you need to involve your local repository.</p>
<p>You can think of this as taking the shape of a V.</p>
<p style="text-align:center;"><img src="http://jagregory.com/wp-content/uploads/2010/02/remote-5.png" /></p>
<p>You need to register their github repository as a remote on your local, pull in their changes, merge them, and push them up to your github. This can be done as follows:</p>
<pre>git remote add contributor contributor_repository.git
git pull contributor branch
git push</pre>
<h2>Github &mdash; providing contributions</h2>
<p>Do exactly as you would your own personal project. Local changes, pushed up to your github fork; then issue a pull request. That&#8217;s all there is to it.</p>
<h2>Github &mdash; the big picture</h2>
<p>Here&#8217;s how to imagine the whole process, think of it as an N shape.</p>
<p style="text-align:center;"><img src="http://jagregory.com/wp-content/uploads/2010/02/remote-6.png" /></p>
<p>On the left is the contributor, and the right is the project. Flow goes from bottom left, along the lines to the top right.</p>
<ol>
<li>Contributor makes a commit in their local repository</li>
<li>Contributor pushes that commit to their github</li>
<li>Contributor issues a pull request to the project</il>
<li>Project lead pulls the contributor&#8217;s change into their local repository</li>
<li>Project lead pushes the change up to the project github</li>
</ol>
<p>That&#8217;s as complicated as it gets.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/git-remotes-contributions-and-the-letter-n/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Behaviours in MSpec</title>
		<link>http://jagregory.com/writings/behaviours-in-mspec/</link>
		<comments>http://jagregory.com/writings/behaviours-in-mspec/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 01:15:31 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[MSpec]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=346</guid>
		<description><![CDATA[Cross posted to Los Techies
MSpec is awesome, I think it&#8217;s praised by myself and others enough for that particular point to not need any expansion; however, there is a particular feature I would like to highlight that hasn&#8217;t really got a lot of press: behaviours.
Behaviours define reusable specs that encapsulate a particular set of, you [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Cross posted to <a href="http://www.lostechies.com/blogs/jagregory/archive/2010/01/18/behaviours-in-mspec.aspx">Los Techies</a></p></blockquote>
<p><a href="http://github.com/machine/machine.specifications">MSpec</a> is awesome, I think it&#8217;s praised by myself and others enough for that particular point to not need any expansion; however, there is a particular feature I would like to highlight that hasn&#8217;t really got a lot of press: behaviours.</p>
<p>Behaviours define reusable specs that encapsulate a particular set of, you guessed it, behaviours; you&#8217;re then able to include these specs in any context that exhibits a particular behaviour.</p>
<p>Lets go with the cliche&#8217;d Vehicle example. Given an <code>IVehicle</code> interface, with <code>Car</code> and <code>Motorbike</code> implementations; these all expose a <code>StartEngine</code> method and some properties reflecting the state of the vehicle. We&#8217;ll start the engine and verify that it is actually started, whether it&#8217;s got anything on the rev counter, and whether it&#8217;s killing our planet in the process (zing!).</p>
<pre name="code" class="c-sharp">
public interface IVehicle
{
  void StartEngine();
  bool IsEngineRunning { get; }
  bool IsPolluting { get; }
  int RevCount { get; }
}

public class Car : IVehicle
{
  public bool IsEngineRunning { get; private set; }

  public void StartEngine()
  {
    // use your imagination...
  }
}

public class Motorbike : IVehicle
{
  public bool IsEngineRunning { get; private set; }

  public void StartEngine()
  {
    // use your imagination...
  }
}
</pre>
<p>Those are our classes, if rather contrived, but they&#8217;ll do. Now what we need to do is write some specs for them.</p>
<pre name="code" class="c-sharp">
public class when_a_car_is_started
{
  Establish context = () =>
    vehicle = new Car();

  Because of = () =>
    vehicle.StartEngine();

  It should_have_a_running_engine = () =>
    vehicle.IsEngineRunning.ShouldBeTrue();

  It should_be_polluting_the_atmosphere = () =>
    vehicle.IsPolluting.ShouldBeTrue();

  It should_be_idling = () =>
    vehicle.RevCount.ShouldBeBetween(0, 1000);

  static Car vehicle;
}

public class when_a_motorbike_is_started
{
  Establish context = () =>
    vehicle = new Motorbike();

  Because of = () =>
    vehicle.StartEngine();

  It should_have_a_running_engine = () =>
    vehicle.IsEngineRunning.ShouldBeTrue();

  It should_have_a_running_engine = () =>
    vehicle.IsEngineRunning.ShouldBeTrue();

  It should_be_polluting_the_atmosphere = () =>
    vehicle.IsPolluting.ShouldBeTrue();

  It should_be_idling = () =>
    vehicle.RevCount.ShouldBeBetween(0, 1000);

  static Motorbike vehicle;
}
</pre>
<p>Those are our specs, there&#8217;s not much in there but already you can see that we&#8217;ve got duplication. Our two contexts contain identical specs, they&#8217;re the same in what they&#8217;re verifying, the only difference is the vehicle instance. This is where behaviours can come in handy.</p>
<p>With behaviours we can extract the specs and make them reusable. Lets do that.</p>
<p>Create a class for your behaviour and adorn it with the <code>Behaviors</code> attribute &mdash; this ensures MSpec recognises your class as a behaviour definition and not just any old class &mdash; then move your specs into it.</p>
<pre name="code" class="c-sharp">
[Behaviors]
public class VehicleThatHasBeenStartedBehaviors
{
  protected static IVehicle vehicle;

  It should_have_a_running_engine = () =>
    vehicle.IsEngineRunning.ShouldBeTrue();

  It should_have_a_running_engine = () =>
    vehicle.IsEngineRunning.ShouldBeTrue();

  It should_be_polluting_the_atmosphere = () =>
    vehicle.IsPolluting.ShouldBeTrue();

  It should_be_idling = () =>
    vehicle.RevCount.ShouldBeBetween(0, 1000);
}
</pre>
<p>We&#8217;ve now got our specs in the behaviour, and have defined a field for the vehicle instance itself (it won&#8217;t compile otherwise). This is our behaviour complete, it defines a set of specifications that verify that a particular behaviour.</p>
<p>Lets hook that behaviour into our contexts from before:</p>
<pre name="code" class="c-sharp">
public class when_a_car_is_started
{
  Establish context = () =>
    vehicle = new Car();

  Because of = () =>
    vehicle.StartEngine();

  Behaves_like&lt;VehicleThatHasBeenStartedBehaviors&gt; a_started_vehicle;

  protected static Car vehicle;
}

public class when_a_motorbike_is_started
{
  Establish context = () =>
    vehicle = new Motorbike();

  Because of = () =>
    vehicle.StartEngine();

  Behaves_like&lt;VehicleThatHasBeenStartedBehaviors&gt; a_started_vehicle;

  protected static Motorbike vehicle;
}
</pre>
<p>We&#8217;ve now put to use the <code>Behaves_like</code> feature, which references our behaviour class and imports the specs into the current context. Now when you run your specs, the specs from our behaviour are imported and run in each context. We don&#8217;t need to assign anything to that field, just defining it is enough; the name you choose for the field is what&#8217;s used by MSpec as the description for what your class is behaving like. In our case this is translated roughly to <em>&#8220;when a motorbike is started it behaves like a started vehicle&#8221;</em>.</p>
<p>There are a couple of things you need to be aware of to get this to work: your fields must be <code>protected</code>, both in the behaviour and the contexts; and the fields must have identical names. If you don&#8217;t get these two correct your behaviour won&#8217;t be hooked up properly. It&#8217;s also good to know that the fields <strong>do not</strong> need to have the same type, as long as the value from your context is assignable to the field in the behaviour then you&#8217;re good; this is key to defining reusable specs for classes that share a sub-set of functionality.</p>
<p>In short, behaviours are an excellent way of creating reusable specs for shared functionality, without the need to create complex inheritance structures. It&#8217;s not a feature you should use lightly, as it can greatly reduce the readability of your specs, but it is a good feature if you&#8217;ve got a budding spec explosion nightmare on your hands.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/behaviours-in-mspec/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Git&#8217;s guts: Merging and rebasing</title>
		<link>http://jagregory.com/writings/gits-guts-merging-and-rebasing/</link>
		<comments>http://jagregory.com/writings/gits-guts-merging-and-rebasing/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 10:03:57 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=334</guid>
		<description><![CDATA[Cross posted to Los Techies
Here we go again, explaining the internals of Git with the intention of helping you understand what you&#8217;re doing day-to-day. Last time I covered branches, HEAD, and fast-forwarding. Today we&#8217;ll dive into the guts of merging and rebasing.
Merging branches
You&#8217;ve probably merged before. You do it when you want the changes from [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Cross posted to <a href="http://www.lostechies.com/blogs/jagregory/archive/2009/11/27/git-guts-merging-and-rebasing.aspx">Los Techies</a></p></blockquote>
<p>Here we go again, explaining the internals of Git with the intention of helping you understand what you&#8217;re doing day-to-day. Last time I covered <a href="http://blog.jagregory.com/2009/11/25/gits-guts-branches-head-and-fast-forwards">branches, HEAD, and fast-forwarding</a>. Today we&#8217;ll dive into the guts of merging and rebasing.</p>
<h3>Merging branches</h3>
<p>You&#8217;ve probably merged before. You do it when you want the changes from one branch in another. The principal is the same in Git as it is most other source control systems, but the implementation differs.</p>
<p>Given the following commit structure, consisting of two branches created from the same commit, each with two commits after the branching occurred.</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure1.png" /></p>
<p>When these two branches are merged together, this is the structure that results:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure2.png" /></p>
<p>The top-most commit, the red one, is a new commit made by the merge; the merge commit is what reminds Git that a merge occurred next time it&#8217;s showing the history. This commit is special, as it contains multiple parent&#8217;s in it&#8217;s meta-data; these multiple parent&#8217;s allow Git to follow the two trees of commits that constituted the branches that were merged.</p>
<p>One difference in how Git handles merges compared to many other SCMs is that it preserves the commits that were made in both branches. In other systems merges are often represented as a single commit containing the squashed contents of all the commits that were made in the branch being merged in. Git doesn&#8217;t do this (by default, you can tell it to if you want), and therefore preserves all the commits just as they were made; this is quite nice, as it proves incredibly useful to be able to track the origin of changes beyond the point of a merge.</p>
<p>When you merge two branches, it&#8217;s interesting to know that none of the commits are altered in the process. Just bare this in mind for now, I&#8217;ll explain why this is good to know later.</p>
<p>After a merge, if you were to view the history, you&#8217;d see it shown like the previous example, commits in chronological order; the feature branch commits are interspersed between the master commits.</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure2.png" /></p>
<p>Yet no commits have been altered in the merge, so how are the commits in a different order? Well, they&#8217;re not, Git&#8217;s just showing you it in the order you expect it to be in. Internally the structure is still as below:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure3.png" /></p>
<p>The merge commit instructs Git to walk the two trees while building the history, and it just displays the results in chronological order. This makes more sense if you recall that Git commits don&#8217;t hold differences like other SCM systems, instead they each contain a snapshot of the complete repository; while in another SCM the ordering of commits is vital &mdash; otherwise the diffs wouldn&#8217;t build a valid file &mdash; Git is able to infer order without affecting the repository contents.</p>
<p>Looking at it in commit order, you can quite easily see how Git flattens the history to be perceived as linear without ever having to touch any of the original commits.</p>
<h4>What happens if there&#8217;s a merge conflict?</h4>
<p>We&#8217;ve all dealt with conflicts in merging before. They typically happen when changes are made to the same file in two branches, in a way that cannot be easily merged (two people edit the same line, for example).</p>
<p>Git&#8217;s commit&#8217;s are immutable though, so how are the changes that you need to make to resolve these conflicts saved? Simple. The merge commit is a regular commit with some extra meta-data, and so it capable of containing changes itself; merge conflict changes are stored in the merge commit. Again, no changes necessary to the original commits.</p>
<h3>Git objects, immutability, and rewriting history</h3>
<p>A Git repository is comprised of objects. A file is a blob object with a name attached to it; if you have two files with the same content, that&#8217;s just two names to a single blob. A directory is a tree object, which is comprised of other trees and blobs. A commit is an object that references a tree object, which is the state of the repository at the time of committing.</p>
<blockquote><p>To read more about git objects, I&#8217;d definitely recommend you read the <a href="http://book.git-scm.com">Git community book</a>.</p></blockquote>
<p>Git objects are immutable. To change an object after it&#8217;s been created is impossible, you have to recreate the object with any changes made. Even operations that seem to modify objects actually don&#8217;t; <code>commit --amend</code> is a typical example, that deletes and re-creates the commit rather than actually amending it.</p>
<p>I mentioned that merges don&#8217;t rewrite history, and that it&#8217;s a good thing. Now I&#8217;ll explain why. When you rewrite history, you do so by making changes to commits that ripple up the commit tree; when this happens, it can cause complications when others merge from you. Given a series of commits, like so:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure4.png" /></p>
<p>You then share these commits with another user.</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure5.png" /></p>
<p>John now has Michael&#8217;s commits in his repository; however, Michael notices he&#8217;s made a typo in the first commit message, so he amends the commit message. The change in the message requires the commit be recreated. With that first commit recreated, the second commit now has an invalid parent reference, so that commit has to be recreated with the new reference; this recreation ripples it&#8217;s way up the tree, recreating each commit with a new parent. Michael has completely rewritten his tree&#8217;s history.</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure6.png" /></p>
<p>Notice all the commit hashes have changed in Michael&#8217;s repository, and John&#8217;s now don&#8217;t match. If Michael was then to make a new commit to his repository, and John tried to merge that change into his repository, Git would get very upset because the new commit would reference a commit that doesn&#8217;t exist in John&#8217;s repository.</p>
<p><strong>The golden rule is:</strong> rewriting history is fine as long as the commits that will be affected haven&#8217;t been made public.</p>
<h3>Rebasing</h3>
<p>The purpose of a rebase is the same as a merge, to bring two tree&#8217;s of commits together. It differs in it&#8217;s approach. Rebasing is a seriously sharp tool. Very powerful, but pretty easy to cut yourself with it.</p>
<p>When you rebase one branch onto another, Git undoes any changes you&#8217;ve made in the target branch, brings it up to date with the changes made in the source branch, then replays your commits on top. This sounds quite strange, so I&#8217;ll go over it step-by-step.</p>
<p>You start with your diverged branches:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure7.png" /></p>
<p>If you then rebase feature onto master, Git undoes the changes in master.</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure8.png" /></p>
<p>The history of both branches is now the same, master has been updated to reflect feature; the new commits that were made in master are now detached, floating in the repository without anything referencing them.</p>
<p>The next step is to replay the master commits onto the new structure. This is done one-by-one, and can sometimes result in conflicts that will need to be handled like any merge.</p>
<p>After replaying the repository will look like this:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts2_Figure9.png" /></p>
<p>The master branch commits are now on the top of the stack, after the commits from the feature branch.</p>
<p>You should recall that commits are immutable, and for changes to be made commits need to be recreated. A rebase is a destructive operation, as it has to rewrite commits to be able to work. In this case, the commits from feature have been unaffected, but the master commits have been assigned new parents (and thus rewritten). What&#8217;s also noticeable is there&#8217;s a lack of a merge commit, which isn&#8217;t needed because the commits have been integrated into the tree; any conflicts are stored in the amended commits, rather than in a merge commit.</p>
<p>The rewriting of commits in a rebase is what makes it a dangerous operation to perform on any branch that has already been pushed to the public (or specifically, that the changes affected by the rebase have already been pushed to the public). A rebase can cause problems upstream, like mentioned in the previous section.</p>
<p>Rebase has it&#8217;s place though. If you&#8217;re working locally and haven&#8217;t yet pushed your changes public, it can be a useful tool. Rebase can be used to pull in changes from upstream in the order that the upstream repository has them, and your local changes (that can be rewritten because you&#8217;re the only one with them) can be replayed on-top; this is a really easy way to keep your repository up-to-date with an authoritative source. You can also use Rebase to manage local branches that you don&#8217;t necessarily want polluting the history with merge markers.</p>
<h3>When to rebase and when to merge?</h3>
<p>Merge when you&#8217;ve already made changes public, and when you want to indicate that two tree&#8217;s have converged. Rebase pretty much any other time.</p>
<p>That&#8217;s it for this time. Same deal as last time, if you have anything you&#8217;d like me to cover I&#8217;ll nail it in the next one.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/gits-guts-merging-and-rebasing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git&#8217;s guts: Branches, HEAD, and fast-forwards</title>
		<link>http://jagregory.com/writings/gits-guts-branches-head-and-fast-forwards/</link>
		<comments>http://jagregory.com/writings/gits-guts-branches-head-and-fast-forwards/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 10:00:08 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=316</guid>
		<description><![CDATA[Cross posted to Los Techies
Lets get some learning done. There are a few questions that keep cropping up when I introduce people to Git, so I thought I&#8217;d post some answers as a mini-series of blog posts. I&#8217;ll cover some fundamentals, while trying not to retread too much ground that the fantastic Git community book [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Cross posted to <a href="http://www.lostechies.com/blogs/jagregory/archive/2009/11/25/git-s-guts-branches-head-and-fast-forwards.aspx">Los Techies</a></p></blockquote>
<p>Lets get some learning done. There are a few questions that keep cropping up when I introduce people to Git, so I thought I&#8217;d post some answers as a mini-series of blog posts. I&#8217;ll cover some fundamentals, while trying not to retread too much ground that the fantastic <a href="http://book.git-scm.com">Git community book</a> already covers so well. Instead I&#8217;m going to talk about things that should help you understand what you and Git are doing day-to-day.</p>
<h3>What&#8217;s a branch?</h3>
<p>I know what you&#8217;re thinking. <em>&#8220;C&#8217;mon, we know what a branch is&#8221;</em>. A branch is a copy of a source tree, that&#8217;s maintained separately from it&#8217;s parent; that&#8217;s what we perceive a branch to be, and that&#8217;s how we&#8217;re used to dealing with them. Sometimes they&#8217;re physical copies (VSS and TFS), other times they&#8217;re lightweight copies (SVN), but they&#8217;re copies non-the-less. Or are they?</p>
<p>Lets look at it a different way. <em>The Git way</em>.</p>
<p>Git works a little differently than most other version control systems. It doesn&#8217;t store changes using <a href="http://en.wikipedia.org/wiki/Delta_encoding">delta encoding</a>, where complete files are built up by stacking differences contained in each commit. Instead, in Git each commit stores a snapshot of how the repository looked when the commit occurred; a commit also contains a bit of meta-data, author, date, but more importantly a reference to the parent of the commit (the previous commit, usually).</p>
<p>That&#8217;s a bit weird, I know, but bare with me.</p>
<p>So what is a branch? Nothing more than a pointer to a commit (with a name). There&#8217;s nothing physical about it, nothing is created, moved, copied, nothing. A branch contains no history, and has no idea of what it consists of beyond the reference to a single commit.</p>
<p>Given a stack of commits:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts1_Figure1.png" /></p>
<p>The branch references the newest commit. If you were to make another commit in this branch, the branch&#8217;s reference would be updated to point at the new commit.</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts1_Figure2.png" /></p>
<p>The history is built up by recursing over the commits through each&#8217;s parent.</p>
<h3>What&#8217;s HEAD?</h3>
<p>Now that you know what a branch is, this one is easy. <code>HEAD</code> is a reference to the latest commit in the branch you&#8217;re in.</p>
<p>Given these two branches:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts1_Figure3.png" /></p>
<p>If you had master checked out, <code>HEAD</code> would reference <code>e34fa33</code>, the exact same commit that the master branch itself references. If you had feature checked out, <code>HEAD</code> would reference <code>dde3e1</code>. With that in mind, as both <code>HEAD</code> and a branch is just a reference to a commit, it is sometimes said that <code>HEAD</code> points to the current branch you&#8217;re on; while this is not strictly true, in most circumstances it&#8217;s close enough.</p>
<h3>What&#8217;s a fast-forward?</h3>
<p>A fast-forward is what Git does when you merge or rebase against a branch that is simply ahead the one you have checked-out.</p>
<p>Given the following branch setup:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts1_Figure4.png" /></p>
<p>You&#8217;ve got both branches referencing the same commit. They&#8217;ve both got exactly the same history. Now commit something to feature.</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts1_Figure5.png" /></p>
<p>The <code>master</code> branch is still referencing <code>7ddac6c</code>, while <code>feature</code> has advanced by two commits. The <code>feature</code> branch can now be considered ahead of <code>master</code>.</p>
<p>It&#8217;s now quite easy to see what&#8217;ll happen when Git does a fast-forward. It simply updates the <code>master</code> branch to reference the same commit that <code>feature</code> does. No changes are made to the repository itself, as the commits from <code>feature</code> already contain all the necessary changes.</p>
<p>Your repository history would now look like this:</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts1_Figure6.png" /></p>
<h3>When doesn&#8217;t a fast-forward happen?</h3>
<p>Fast-forwards don&#8217;t happen in situations where changes have been made in the original branch and the new branch.</p>
<p><img src="http://blog.jagregory.com/wp-content/uploads/2010/01/GitGuts1_Figure7.png" /></p>
<p>If you were to merge or rebase <code>feature</code> onto <code>master</code>, Git would be unable to do a fast-forward because the trees have both diverged. Considering Git commits are immutable, there&#8217;s no way for Git to get the commits from <code>feature</code> into <code>master</code> without changing their parent references.</p>
<p>For more info on all this object malarky, I&#8217;d recommend reading the <a href="http://book.git-scm.com">Git community book</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/gits-guts-branches-head-and-fast-forwards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m a Los Techie</title>
		<link>http://jagregory.com/writings/im-a-los-techie/</link>
		<comments>http://jagregory.com/writings/im-a-los-techie/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 10:39:09 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/2009/03/28/im-a-los-techie/</guid>
		<description><![CDATA[Just to let anyone know that hasn&#8217;t heard by other means, I&#8217;m now blogging at Los Techies. I&#8217;m going to cross-post between these two blogs, so there&#8217;s no need to update your feeds if you&#8217;re too lazy; but if you&#8217;re already subscribing to the Los Techies general feed then you&#8217;ll now get me too.
You can [...]]]></description>
			<content:encoded><![CDATA[<p>Just to let anyone know that hasn&#8217;t heard by other means, I&#8217;m now blogging at <a href="http://lostechies.com">Los Techies</a>. I&#8217;m going to cross-post between these two blogs, so there&#8217;s no need to update your feeds if you&#8217;re too lazy; but if you&#8217;re already subscribing to the Los Techies general feed then you&#8217;ll now get me too.</p>
<p>You can find my blog at: <a href="http://jagregory.lostechies.com">jagregory.lostechies.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/im-a-los-techie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Tribute to Subversion</title>
		<link>http://jagregory.com/writings/a-tribute-to-subversion/</link>
		<comments>http://jagregory.com/writings/a-tribute-to-subversion/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 14:10:07 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[sourcecontrol]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=151</guid>
		<description><![CDATA[Note: This is based on my personal experiences, and is not specifically &#8220;fact&#8221;. If your experiences differ, fine, but these are mine.
Subversion has started receiving some more flak in certain circles, it&#8217;s no longer in-vogue, no longer cool. Distributed version control is the big thing now, Git, Mecurial, Bazaar etc. Well I&#8217;m a huge Git [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: This is based on my personal experiences, and is not specifically &#8220;fact&#8221;. If your experiences differ, fine, but these are mine.</em></p>
<p>Subversion has started receiving some more flak in certain circles, it&#8217;s no longer in-vogue, no longer cool. Distributed version control is the big thing now, Git, Mecurial, Bazaar etc. Well I&#8217;m a huge Git fan, and I&#8217;m finding myself slowly transitioning away from Subversion project by project. However, I think I need to address something.</p>
<p>Subversion radically changed how people percieve source control, certainly in the environments that I&#8217;ve introduced it into (primarily SourceSafe based). That&#8217;s no small feat, and I don&#8217;t think it should be forgotten amid all the hype around newer source control systems.</p>
<p>The attitude towards source control prior to Subversion was that of fear; it was a black box that you threw your code into at the end of every day. Nobody really understood what it does, or why it does it, and even in some cases why they&#8217;re actually doing it. This was probably down to poor user interfaces, but nobody really <em>wanted</em> to use it, they just had to. It was never made a proper part of anyone&#8217;s workflow, apart from as a part of shutting down your machine at the end of the day (hopefully you remembered to do that!).</p>
<p>Then along came Subversion (sometimes with a bit of force), with it&#8217;s good tools, it&#8217;s stable repository, and it&#8217;s ease of management. You could host it through a webserver, everybody could access it via a URL. It never corrupts itself randomly, and it doesn&#8217;t require scary maintenance work.</p>
<p>With Subversion people stopped fearing source control, infact they started enjoying it. People started deleting old code, entire swaths of code, because they were now happy that it was always going to be available. They actually made it a primary part of their workflow; multiple commits a day, regular history lookups, blame, branches, tags, the lot.</p>
<p>Maybe Subversion isn&#8217;t cool any more, but we shouldn&#8217;t forget what it did for many shops that adopted it.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/a-tribute-to-subversion/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
