<?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>Marcin Obel&#187; Marcin Obel</title>
	<atom:link href="http://marcinobel.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://marcinobel.com</link>
	<description>.NET, ASP.NET MVC, jQuery, Ruby, Ruby on Rails, Test Driven Development, Agile</description>
	<lastBuildDate>Wed, 10 Feb 2010 13:56:36 +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>Ruby for Windows with debug support</title>
		<link>http://marcinobel.com/index.php/ruby-windows-debug-support/</link>
		<comments>http://marcinobel.com/index.php/ruby-windows-debug-support/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 13:56:36 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=283</guid>
		<description><![CDATA[I mentioned somewhere in previous posts I am playing a little with Ruby and Ruby on Rails. Because I do not have an experience yet, there are a lot of situations where I need a debugger to figure out how something works. Unfortunately before I was able to debug anything I spend a lot of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-16 alignleft" title="Ruby Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/ruby_logo.png" alt="" width="106" height="109" />I mentioned somewhere in previous posts I am playing a little with <a href="http://www.ruby-lang.org/en/" target="_blank"><strong>Ruby</strong></a> and <strong><a href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a></strong>. Because I do not have an experience yet, there are a lot of situations where I need a debugger to figure out how something works. Unfortunately before I was able to debug anything I spend a lot of time trying to enable debugging in <a href="http://www.jetbrains.com/ruby/" target="_blank"><strong>RubyMine</strong></a>. The main problem was in Ruby gems responsible for debugging. This gems are native C libraries and have to be compiled before usage. Of course you can guess that compilation did not work as expected. After long fight and few hours with Google I have managed to prepare a version of Ruby which can be used with RubyMine to debug applications.</p>
<p>Because Ruby for Windows does not require any installation I am able to easily provide you the version I have build mostly in order to save your time and do not describe whole procedure I had to follow during compilation.</p>
<p>The package contains <strong>Ruby 1.8.7 for Windows </strong>with following gems:</p>
<ul>
<li>actionmailer (2.3.5)</li>
<li>actionpack (2.3.5)</li>
<li>activerecord (2.3.5)</li>
<li>activeresource (2.3.5)</li>
<li>activesupport (2.3.5)</li>
<li>albacore (0.1.1, 0.1.0)</li>
<li>columnize (0.3.1)</li>
<li>linecache (0.43)</li>
<li>net-sftp (2.0.4)</li>
<li>net-ssh (2.0.19)</li>
<li>rack (1.1.0, 1.0.1)</li>
<li>rails (2.3.5)</li>
<li>rake (0.8.7)</li>
<li>RedCloth (4.2.2)</li>
<li><strong>ruby-debug</strong> (0.10.3)</li>
<li><strong>ruby-debug-base</strong> (0.10.3)</li>
<li><strong>ruby-debug-ide</strong> (0.4.9)</li>
<li>rubyzip (0.9.4, 0.9.1)</li>
<li>sqlite3-ruby (1.2.5)</li>
</ul>
<p>Installation is very simple. Uncompress files to <em>C:\Ruby</em> directory and add <em>C:\Ruby\bin</em> path to <em>PATH</em> environment variable.</p>
<h2><a href="http://marcinobel.com/download/Ruby.1.8.7.zip">Download Ruby 1.8.7 for Windows with debug support</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/ruby-windows-debug-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IronRuby/RHTML based templates for .NET</title>
		<link>http://marcinobel.com/index.php/ironruby-rhtml-based-templates-for-net/</link>
		<comments>http://marcinobel.com/index.php/ironruby-rhtml-based-templates-for-net/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 23:09:20 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=225</guid>
		<description><![CDATA[
During last few days I was prototyping some of new features I would like to add to ByteCarrot application. One of them is new template engine which will replace current XSLT based solution. I wanted something with more friendly syntax, something easy to create, change and maintain. I took a look at many template engines [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png"><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt=".NET Logo" width="240" height="74" /></a></p>
<p>During last few days I was prototyping some of new features I would like to add to <a title="ByteCarrot Project" href="http://bytecarrot.com" target="_blank"><strong>ByteCarrot </strong></a>application. One of them is new template engine which will replace current XSLT based solution. I wanted something with more friendly syntax, something easy to create, change and maintain. I took a look at many template engines available for .NET platform but none of them met my needs. I thought that it would be nice to have solution with scripting support and syntax similar to this available in default <strong><a title="ASP.NET MVC" href="http://www.asp.net/mvc/" target="_blank">ASP.NET MVC</a></strong> view engine.</p>
<p>After digging I have found an <strong>ASP.NET MVC</strong> application prototype with view engine based on <strong><a title="IronRuby" href="http://ironruby.net/" target="_blank">IronRuby</a></strong>. It was created by <strong><a title="Phil Haack" href="http://haacked.com/" target="_blank">Phil Haack</a></strong>&#8217;s team and its syntax was exactly the same as <strong>RHTML </strong>used in <strong><a title="Ruby on Rails" href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a></strong> views. It turned out that this engine was exactly what I needed, so I have taken parts of the code and adapted it to my scenario. The result is amazing because now I have fully functional templates engine with support of dynamic language where I can handle every possible HTML generation scenario.</p>
<p>As an attachment to this post I have added the code created during prototyping. The code contains few classes where the most important is <em>RhtmlEngine</em>. It has very simple, self-expanatory interface and acts as an &#8220;entry point&#8221; for using mentioned templates engine. Below you can find two samples showing capabilities of my solution but if you want to take a look at the implementation and make your hands dirty feel free to download the code and play with it for yourself.</p>
<pre class="brush: csharp;">
public class RhtmlEngine
{
    public Result Render(object model, string temlateFile, string targetFile)
        ...
    public Result Render(object model, StreamReader rhtml, StreamWriter writer)
        ...
}
</pre>
<h2>Simple template</h2>
<p>The templates engine requires three things to be able to generate HTML:</p>
<ul>
<li><strong>Model</strong> representing the data which should be presented in form of HTML page,</li>
<li><strong>Template</strong> defining how model should be presented,</li>
<li><strong>Target</strong> where generated HTML page should be saved.</li>
</ul>
<p>Listing below shows simple template generating a header and a list of hobbies. Notice that IronRuby blocks are embedded exactly the same as Visual Basic .NET or C# code is embedded in ASP.NET MVC views.</p>
<p><strong>SimpleTemplate.rhtml</strong></p>
<pre class="brush: xml;">
&lt;html&gt;
    &lt;body&gt;
        &lt;h1&gt;Hi! My name is: &lt;%= model.FirstName %&gt;&lt;%= model.LastName %&gt;&lt;/h2&gt;
        I like:
        &lt;ul&gt;
        &lt;% model.Hobbies.each do |hobby| %&gt;
			&lt;li&gt;&lt;%= hobby %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Template shown above can be used to generate an HTML representation of the following model:</p>
<pre class="brush: csharp;">
var model = new SampleModel
{
    FirstName = &quot;Marcin&quot;,
    LastName = &quot;Obel&quot;,
    Hobbies = new List&lt;string&gt;
    {
        &quot;yachting&quot;,
        &quot;fishing&quot;,
        &quot;cycling&quot;
    }
};
</pre>
<p>As you can notice looking at listing below, because the templates engine is very simple, you need only one line to change the model into HTML page.</p>
<pre class="brush: csharp;">
var result = new RhtmlEngine().Render(model, &quot;SimpleTemplate.rhtml&quot;, &quot;SimpleHtml.html&quot;);
</pre>
<p>In result (as shown below) the code above will produce clean HTML filled in with the data from model.</p>
<p><strong>SimpleHtml.html</strong></p>
<pre class="brush: xml;">
&lt;html&gt;
    &lt;body&gt;
        &lt;h1&gt;Hi! My name is: MarcinObel&lt;/h2&gt;
        I like:
        &lt;ul&gt;
            &lt;li&gt;yachting&lt;/li&gt;
            &lt;li&gt;fishing&lt;/li&gt;
            &lt;li&gt;cycling&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>More advanced example</h2>
<p>The example above does not show the most powerful part of this solution which is in fact inherited from <strong>IronRuby </strong>itself. Because templates are based on fully functional, dynamic language there is a possibility to extend basic features like <em>loops</em> and <em>if</em> statements (available in all templates engines) with things like functions, classes or even use some functionalities available in .NET Framework. Next example extends this one mentioned in previous section. In the listing below you can notice two new functions:</p>
<ul>
<li><strong>encode </strong>- uses <em>HttpUtility </em>class from .NET Framework to encode HTML code</li>
<li><strong>render_li</strong> &#8211; renders an item of HTML list</li>
</ul>
<p><strong>AdvancedTemplate.rhtml</strong></p>
<pre class="brush: xml;">
&lt;%
require 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
include System::Web

def encode(text)
    HttpUtility.HtmlEncode(text)
end

def render_li(text)
    writer.Write &quot;&lt;li&gt;#{text}&lt;/li&gt;&quot;;
end
%&gt;

&lt;html&gt;
    &lt;body&gt;
        &lt;h1&gt;Hi! My name is: &lt;%= model.FirstName %&gt;&lt;%= model.LastName %&gt;&lt;/h2&gt;
        I like:
        &lt;ul&gt;
        &lt;% model.Hobbies.each do |hobby|
                 render_li hobby
             end %&gt;
        &lt;/ul&gt;
        &lt;pre&gt;
            &lt;%= encode model.UglyJavaScript %&gt;
        &lt;/pre&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>In order to present a usage of custom <strong>IronRuby </strong>function added to the template, below you can find extended model from previous example. Now the model contains additional property named <em>UglyJavaScript </em>containing JavaScript code which should be encoded before it can be presented in HTML.</p>
<pre class="brush: csharp;">
var model = new SampleModel
{
    FirstName = &quot;Marcin&quot;,
    LastName = &quot;Obel&quot;,
    Hobbies = new List&lt;string&gt;
    {
        &quot;yachting&quot;,
        &quot;fishing&quot;,
        &quot;cycling&quot;
    },
    UglyJavaScript = @&quot;&lt;script type='text/javascript'&gt;window.close();&lt;/script&gt;&quot;
};

var result = new RhtmlEngine().Render(model, &quot;AdvancedTemplate.rhtml&quot;, &quot;AdvancedHtml.html&quot;);
</pre>
<p>Like in previous example after passing the model and the template into engine we receive an HTML.  This time as you can see it contains JavaScript code from model encoded using .NET Framework functionality in order to be able to display it.</p>
<pre class="brush: xml;">
&lt;html&gt;
    &lt;body&gt;
        &lt;h1&gt;Hi! My name is: MarcinObel&lt;/h2&gt;
        I like:
        &lt;ul&gt;
        &lt;li&gt;yachting&lt;/li&gt;&lt;li&gt;fishing&lt;/li&gt;&lt;li&gt;cycling&lt;/li&gt;
        &lt;/ul&gt;
        &lt;pre&gt;
        &amp;lt;script type='text/javascript'&amp;gt;window.close();&amp;lt;/script&amp;gt;
        &lt;/pre&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>Resources</h2>
<ul>
<li><a title="RHTML templates engine source code" href="http://marcinobel.com/wp-content/uploads/Rhtml.Sample.zip" target="_blank">RHTML templates engine source code</a></li>
<li><a title="IronRuby official website" href="http://ironruby.net/" target="_blank">IronRuby official website</a></li>
<li><a title="Phil Haack" href="http://haacked.com/" target="_blank">Phil Haack&#8217;s blog</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/ironruby-rhtml-based-templates-for-net/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fluent NHibernate conventions &#8211; examples</title>
		<link>http://marcinobel.com/index.php/fluent-nhibernate-conventions-examples/</link>
		<comments>http://marcinobel.com/index.php/fluent-nhibernate-conventions-examples/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 22:22:59 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=195</guid>
		<description><![CDATA[Fluent NHibernate is my favorite extension for NHibernate. I am using it since early betas and I have to say that I love it. One of its underestimated features are conventions. I decided to extract some of them from one of my projects and provide real life examples how they can be used. My conventions [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://marcinobel.com/wp-content/uploads/fluent-nhibernate.png"><img class="alignleft size-full wp-image-210" title="Fluent NHibernate" src="http://marcinobel.com/wp-content/uploads/fluent-nhibernate.png" alt="Fluent NHibernate" width="360" height="117" /></a><strong><a title="Fluent NHibernate" href="http://fluentnhibernate.org/" target="_blank">Fluent NHibernate</a></strong> is my favorite extension for <strong><a title="NHibernate" href="http://nhforge.org/" target="_blank">NHibernate</a></strong>. I am using it since early betas and I have to say that I love it. One of its underestimated features are conventions. I decided to extract some of them from one of my projects and provide real life examples how they can be used. My conventions are listed below but if you need more information visit <strong><a title="Fluent NHibernate Documentation" href="http://wiki.fluentnhibernate.org/Conventions" target="_blank">Fluent NHibernate Wiki</a><span style="font-weight: normal;"> where this feature is described in detail</span></strong>.</p>
<p><strong>ColumnNullabilityConvention</strong> &#8211; says that if nullability for column has not been specified explicitly, should be set to &#8220;NOT NULL&#8221;.</p>
<pre class="brush: csharp;">
public class ColumnNullabilityConvention
    : IPropertyConvention, IPropertyConventionAcceptance
{
    public void Accept(IAcceptanceCriteria&lt;IPropertyInspector&gt; criteria)
    {
        criteria.Expect(x =&gt; x.Nullable, Is.Not.Set);
    }

    public void Apply(IPropertyInstance instance)
    {
        instance.Not.Nullable();
    }
}
</pre>
<p><strong>CreatedAtPropertyAccessConvention</strong> &#8211; says that every property named <span style="text-decoration: underline;">CreatedAt </span>should be accessed through camel case field hidden behind it.</p>
<pre class="brush: csharp;">
public class CreatedAtPropertyAccessConvention
    : IPropertyConvention, IPropertyConventionAcceptance
{
    public void Accept(IAcceptanceCriteria&lt;IPropertyInspector&gt; criteria)
    {
        criteria.Expect(x =&gt; x.Property.Name == &quot;CreatedAt&quot;);
    }

    public void Apply(IPropertyInstance instance)
    {
        instance.Access.ReadOnlyPropertyThroughCamelCaseField(
            CamelCasePrefix.Underscore);
    }
}
</pre>
<p><strong>ForeignKeyConstraintNameConvention</strong> &#8211; says that name of every foreign key constraint representing one to many relation should consist of names of entities for which it was specified.</p>
<pre class="brush: csharp;">
public class ForeignKeyConstraintNameConvention
    : IHasManyConvention
{
    public void Apply(IOneToManyCollectionInstance instance)
    {
        instance.Key.ForeignKey(&quot;{0}_{1}_FK&quot;.AsFormat(
        instance.Member.Name, instance.EntityType.Name));
    }
}
</pre>
<p><strong>ForeignKeyNameConvention</strong> &#8211; says that name of every column containing foreign key id should consist of name of type which it points to with &#8220;Id&#8221; suffix.</p>
<pre class="brush: csharp;">
public class ForeignKeyNameConvention : IHasManyConvention
{
    public void Apply(IOneToManyCollectionInstance instance)
    {
        instance.Key.Column(instance.EntityType.Name + &quot;Id&quot;);
    }
}
</pre>
<p><strong>PrimaryKeyNameConvention </strong>- says that name of every column representing primary key should consist of entity name and &#8220;Id&#8221; suffix.</p>
<pre class="brush: csharp;">
public class PrimaryKeyNameConvention : IIdConvention
{
    public void Apply(IIdentityInstance instance)
    {
        instance.Column(instance.EntityType.Name + &quot;Id&quot;);
    }
}
</pre>
<p><strong>ReferenceConvention</strong> &#8211; says that name of column referenced in many to one convention should consist of entity name and &#8220;Id&#8221; suffix.</p>
<pre class="brush: csharp;">
public class ReferenceConvention : IReferenceConvention
{
    public void Apply(IManyToOneInstance instance)
    {
        instance.Column(instance.Property.PropertyType.Name + &quot;Id&quot;);
    }
}
</pre>
<p><strong>StringColumnLengthConvention</strong> &#8211; says that if length for string column has not been specified, it should be set to 100.</p>
<pre class="brush: csharp;">
public class StringColumnLengthConvention
    : IPropertyConvention, IPropertyConventionAcceptance
{
    public void Accept(IAcceptanceCriteria&lt;IPropertyInspector&gt; criteria)
    {
        criteria.Expect(x =&gt; x.Type == typeof(string))
            .Expect(x =&gt; x.Length == 0);
    }

    public void Apply(IPropertyInstance instance)
    {
        instance.Length(100);
    }
}
</pre>
<p><strong>TableNameConvention</strong> &#8211; says that if name for table has not been specified, it should be created using concatenation of entity name and &#8220;s&#8221; suffix.</p>
<pre class="brush: csharp;">
public class TableNameConvention
    : IClassConvention, IClassConventionAcceptance
{
    public void Accept(IAcceptanceCriteria&lt;IClassInspector&gt; criteria)
    {
        criteria.Expect(x =&gt; x.TableName, Is.Not.Set);
    }

    public void Apply(IClassInstance instance)
    {
        instance.Table(instance.EntityType.Name + &quot;s&quot;);
    }
}
</pre>
<p><strong>At the end the most important thing</strong> which shows that such conventions make sense. With default <strong>Fluent NHibernate</strong> conventions DDL generated by NHibernate for MySQL looked like this:</p>
<pre class="brush: sql;">
alter table `Athlete`  drop foreign key FK9221C9B94070A6F0

drop table if exists Countries

drop table if exists `Athlete`

create table Countries (
     Id INTEGER NOT NULL AUTO_INCREMENT,
     Name VARCHAR(255),
     primary key (Id)
)

create table `Athlete` (
     Id INTEGER NOT NULL AUTO_INCREMENT,
     DisplayName VARCHAR(255),
     Email VARCHAR(255),
     Password VARCHAR(255),
     CreatedAt DATETIME,
     IsActive TINYINT(1),
     Country_id INTEGER,
     primary key (Id)
)

alter table `Athlete`
	add index (Country_id),
	add constraint FK9221C9B94070A6F0
	foreign key (Country_id)
	references Countries (Id)
</pre>
<p>When I have applied conventions mentioned above to my fluent mappings DDL looks like this:</p>
<pre class="brush: sql;">
alter table Athletes  drop foreign key Athletes_Country_FK

drop table if exists Athletes

drop table if exists Countries

create table Athletes (
     AthleteId INTEGER NOT NULL AUTO_INCREMENT,
     DisplayName VARCHAR(100) not null,
     Email VARCHAR(100) not null,
     Password VARCHAR(100) not null,
     CreatedAt DATETIME not null,
     IsActive TINYINT(1) not null,
     CountryId INTEGER,
     primary key (AthleteId)
)

create table Countries (
     CountryId INTEGER NOT NULL AUTO_INCREMENT,
     Name VARCHAR(100) not null,
     primary key (CountryId)
)

alter table Athletes
	add index (CountryId),
	add constraint Athletes_Country_FK
	foreign key (CountryId)
	references Countries (CountryId)
</pre>
<p>For me it looks much better. Additionally I have made it once and that is it. Now I have to care only about domain model and business logic without thinking about not so important stuff lake names of database objects.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/fluent-nhibernate-conventions-examples/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MSpec BDD framework installer</title>
		<link>http://marcinobel.com/index.php/mspec-bdd-installer/</link>
		<comments>http://marcinobel.com/index.php/mspec-bdd-installer/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 11:23:35 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=186</guid>
		<description><![CDATA[Installation of MSpec BDD framework from source code is quite annoying. With each release you have to deploy everything manually one more time what in fact is hard to accept in 21th century. I know that work on Open Source project requires a lot of time (I have my own project called ByteCarrot) and you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png"><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt=".NET Logo" width="240" height="74" /></a>Installation of <strong>MSpec</strong> BDD framework from source code is quite annoying. With each release you have to deploy everything manually one more time what in fact is hard to accept in 21th century. I know that work on <strong>Open Source</strong> project requires a lot of time (I have my own project called <a title="ByteCarrot Project" href="http://bytecarrot.com" target="_blank"><strong>ByteCarrot</strong></a>) and you cannot do everything. Because of that I decided to help a little bit creators of <strong>MSpec </strong>and I have prepared an installer for this BDD framework. It is based on <strong>WiX </strong>and latest release of <strong>MSpec </strong>witch is version <strong>0.3</strong>.</p>
<p>The installer is able to automatically integrate <strong>MSpec</strong> with <strong>TestDriven.NET</strong> and <strong>ReSharper</strong> (4.1, 4.5, 5.0). This is first version of the installer and of course like always there can be some bugs so please let me know if you find something.</p>
<h2><a title="Download installer for MSpec 0.3" href="http://marcinobel.com/download/MSpec-0.3.msi" target="_self">Download installer for MSpec 0.3</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/mspec-bdd-installer/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Rake in .NET projects – installation and setup</title>
		<link>http://marcinobel.com/index.php/rake-net-projects-installation-setup/</link>
		<comments>http://marcinobel.com/index.php/rake-net-projects-installation-setup/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 18:10:27 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=169</guid>
		<description><![CDATA[
Recently I have rewritten all MSBuild scripts which I used in ByteCarrot project to Rake. I made the decision about changing build solution mostly because I required something what works not only under Windows but also on other operating systems. After rewriting turned out that Rake is a great solution for tasks for which it [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt=".NET Logo" width="240" height="74" /><br />
Recently I have rewritten all <em><strong>MSBuild </strong></em>scripts which I used in <a title="ByteCarrot" href="Recently I have rewritten all MSBuild scripts which I used in ByteCarrot project to Rake. I made the decision about changing build solution mostly because I required something what works not only under Windows but also on other operating systems. After rewriting turned out that Rake is a great solution for tasks for which it was created and can be used not only with Ruby/RoR projects but also with other technologies like .NET and Mono. It is really awesome multi-purpose tool. Today I would like to show you how to install and configure Rake on Windows operating system in order to start using it in your projects. Ruby installation First of all, because Rake is based on Ruby language, you will need an interpreter. You can download Ruby distribution from its official website but I do not recommend that because there is only installer for version 1.8.6 which is quite old. Other packages for Windows on this website are in a form of compressed archives and do not contain some additional, required libraries. In my opinion the best option is to download one of preview version of installer for Ruby 1.9.1-p129 (rubyinstaller-1.9.1-p129-preview1.exe) available on RubyForge. When the installer is on your hard drive, start installation. There is nothing magic in the installation process but you should remember that Rake does not work properly when Ruby in installed in C:\Program Files directory (probably because of space in the path). Because of that leave the default installation path or change it to something without spaces like for example C:\Ruby. Last thing you should do to be able to use Ruby is adding the location of Ruby binaries to the %Path% environment variable. In my case this variable was extended with C:\Ruby\bin path. Now you can check if everything works by executing from command line two following commands: ruby –v gem -v The output from console should be: C:\&gt;ruby –v ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32] C:\&gt;gem –v 1.3.4 Rake installation Now, when Ruby is installed and you are sure that it works you can take care of Rake. The most popular and safe way to install Ruby extensions and libraries (including Rake) is mechanism called Gems. In order to install Rake using Gems execute following command from command line: C:\&gt;gem install --remote rake The output from console should be: C:\&gt;gem install --remote rake Successfully installed rake-0.8.7 1 gem installed Installing ri documentation for rake-0.8.7... Updating class cache with 0 classes... Installing RDoc documentation for rake-0.8.7... When the command will finish do not close command line window yet. At the end execute one more command to be sure that Rake is installed properly: C:\&gt;rake –V The output from console should be: C:\Users\Marcin&gt;rake –V rake, version 0.8.3 Congratulations! You have managed to install Rake and you are ready to write your first build script. More about rake can be found on official site of the project. Example Rake scripts can be found in ByteCarrot source code on CodePlex. " target="_blank"><em><strong>ByteCarrot</strong></em></a><em><strong> </strong></em>project to <a title="Rake project" href="http://rake.rubyforge.org/" target="_blank"><em><strong>Rake</strong></em></a>. I made the decision about changing build solution mostly because I required something what works not only under <em>Windows </em>but also on other operating systems. After rewriting turned out that <em>Rake </em>is a great solution for tasks for which it was created and can be used not only with <em><strong>Ruby/RoR</strong></em> projects but also with other technologies like <strong>.</strong><em><strong>NET</strong></em><em> </em>and <em><strong>Mono</strong></em>. It is really awesome multi-purpose tool. Today I would like to show you how to install and configure <em>Rake </em>on <em>Windows </em>operating system in order to start using it in your projects.</p>
<h2>Ruby installation</h2>
<p>First of all, because <em>Rake </em>is based on <em>Ruby </em>language, you will need an interpreter. You can download <em>Ruby </em>distribution from its <em><a title="Ruby Language" href="http://ruby-lang.org/" target="_blank">official website</a></em> but I do not recommend that because there is only installer for version 1.8.6 which is quite old. Other packages for <em>Windows </em>on this website are in a form of compressed archives and do not contain some additional, required libraries. In my opinion the best option is to download one of preview version of installer for <em>Ruby </em>1.9.1-p129 <em>(rubyinstaller-1.9.1-p129-preview1.exe)</em> available on <em><a title="RubyForge" href="http://rubyforge.org/frs/?group_id=167" target="_blank"><strong>RubyForge</strong></a></em>.</p>
<p><img class="alignright size-full wp-image-16" title="Ruby Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/ruby_logo.png" alt="Ruby Logo" width="106" height="109" /></p>
<p>When the installer is on your hard drive, start installation. There is nothing magic in the installation process but you should remember that <em>Rake</em> does not work properly when <em>Ruby</em> in installed in <em>C:\Program Files</em> directory (probably because of space in the path). Because of that leave the default installation path or change it to something without spaces like for example <em>C:\Ruby</em>.</p>
<p>Last thing you should do to be able to use <em>Ruby </em>is adding the location of its binaries to the <em>%Path%</em> environment variable. In my case this variable was extended with <em>C:\Ruby\bin</em> path.</p>
<p>Now you can check if everything works by executing from command line two following commands:</p>
<pre class="brush: csharp;">
ruby –v
gem -v
</pre>
<p>The output from console should be:</p>
<pre class="brush: csharp;">
C:\&gt;ruby –v
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]
C:\&gt;gem –v
1.3.4
</pre>
<h2>Rake installation</h2>
<p>Now, when <em>Ruby </em>is installed and you are sure that it works you can take care of <em>Rake</em>. The most popular and safe way to install <em>Ruby </em>extensions and libraries (including <em>Rake</em>) is mechanism called <em><strong>Gems</strong></em>. In order to install <em>Rake </em>using <em>Gems </em>execute following command from command line:</p>
<pre class="brush: csharp;">
C:\&gt;gem install --remote rake
</pre>
<p>The output from console should be:</p>
<pre class="brush: csharp;">
C:\&gt;gem install --remote rake
Successfully installed rake-0.8.7
1 gem installed
Installing ri documentation for rake-0.8.7...
Updating class cache with 0 classes...
Installing RDoc documentation for rake-0.8.7...
</pre>
<p>When the command will finish do not close command line window yet. At the end execute one more command to be sure that <em>Rake </em>is installed properly:</p>
<pre class="brush: csharp;">
C:\&gt;rake –V
</pre>
<p>The output from console should be:</p>
<pre class="brush: csharp;">
C:\&gt;rake –V
rake, version 0.8.3
</pre>
<p>Congratulations! You have managed to install <em>Rake </em>and you are ready to write your first build script. <strong>More about Rake can be found on </strong><a title="Rake project" href="http://rake.rubyforge.org/" target="_blank"><em><strong>official site</strong></em></a><strong> of the project</strong>. Example <em>Rake </em>scripts can be found in <em><a title="ByteCarrot source code" href="http://bytecarrot.codeplex.com/SourceControl/ListDownloadableCommits.aspx" target="_blank"><strong>ByteCarrot source code on CodePlex</strong></a></em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/rake-net-projects-installation-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC 2 Beta &#8211; new features</title>
		<link>http://marcinobel.com/index.php/aspnet-mvc-2-beta-features/</link>
		<comments>http://marcinobel.com/index.php/aspnet-mvc-2-beta-features/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 12:38:57 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=134</guid>
		<description><![CDATA[Yesterday at PDC 09 Bob Muglia announced the release of ASP.NET MVC 2 Beta. This release contains a lot of new, interesting stuff. Below you can find a list of new features taken from official release notes.
New RenderAction method
Html.RenderAction (and its counterpart Html.Action) is an HTML helper method that calls into an action method from [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png"><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt=".NET Logo" width="240" height="74" /></a>Yesterday at <strong><a title="PDC 09" href="http://microsoftpdc.com/" target="_blank">PDC 09</a></strong> Bob Muglia announced the release of <strong><a title="ASP.NET MVC 2 Beta" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=4817cdb2-88ea-4af4-a455-f06b4c90fd2c&amp;displaylang=en" target="_blank">ASP.NET MVC 2 Beta</a></strong>. This release contains a lot of new, interesting stuff. Below you can find a list of new features taken from official release notes.</p>
<h2>New RenderAction method</h2>
<p><em>Html.RenderAction</em> (and its counterpart <em>Html.Action</em>) is an HTML helper method that calls into an action method from within a view and renders the output of the action method in place. <em>Html.RenderAction</em> writes directly to the response, whereas <em>Html.Action</em> returns a string with the output. <em>RenderAction</em> works only with actions that render views.</p>
<h2>Strongly typed UI helpers</h2>
<p>ASP.NET MVC 2 includes new expression-based versions of existing HTML helper methods. The new helpers include the following:</p>
<ul>
<li><em>ValidationMessageFor</em></li>
<li><em>TextAreaFor</em></li>
<li><em>TextBoxFor</em></li>
<li><em>HiddenFor</em></li>
<li><em>DropDownListFor</em></li>
</ul>
<h2>TempDataDictionary improvements</h2>
<p>The behavior of the <em>TempDataDictionary</em> class has been changed slightly to address scenarios where temp data was either removed prematurely or persisted longer than necessary. For example, in cases where temp data was read in the same request in which it was set, the temp data was persisting for the next request even though the intent was to remove it. In other cases, temp data was not persisted across multiple consecutive redirects.</p>
<p>To address these scenarios, the <em>TempDataDictionary </em>class was changed so that all the keys survive indefinitely until the key is read from the <em>TempDataDictionary </em>object. The Keep method was added to <em>TempDataDictionary </em>to let you indicate that the value should not be removed after reading. The <em>RedirectToActionResult </em>is an example where the <em>Keep </em>method is called in order to retain all the keys for the next request.</p>
<h2>Client validation library</h2>
<p>MicrosoftMvcAjax.js now includes a client-side validation library that is used to provide client validation for models in ASP.NET MVC. To enable client validation, include the following two scripts in your view.</p>
<ul>
<li>MicrosoftAjax.js</li>
<li>MicrosoftMvcAjax.js</li>
</ul>
<p>The following example shows a view with client validation enabled.</p>
<pre class="brush: xml;">
&lt;script type=&quot;text/javascript&quot; src=&quot;MicrosoftAjax.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;MicrosoftMvcAjax.js&quot;&gt;&lt;/script&gt;

&lt;% Html.EnableClientValidation(); %&gt;
&lt;% using(Html.BeginForm()) { %&gt;
  //...
&lt;% } %&gt;
</pre>
<h2>&#8220;Add Area&#8221; dialog box</h2>
<p>ASP.NET MVC 2 Beta includes a new <em>Add Area</em> context menu item when you right-click either the root project node or the Areas folder (if one exists). If a root Areas folder does not already exist, the command creates one, and it then creates the files and folders for the area that you specify.</p>
<h2>Calling action methods asynchronously</h2>
<p>The AsyncController class is a base class for controllers that enables action methods to be called asynchronously. This lets an action method call external services such as a Web service without blocking the current thread. For more information, see <a title="Using an Asynchronous Controller in ASP.NET MVC " href="http://go.microsoft.com/fwlink/?LinkId=177780" target="_blank">Using an Asynchronous Controller in ASP.NET MVC</a> In the ASP.NET MVC 2 documentation.</p>
<h2>Blank project template</h2>
<p>In response to customer feedback, an empty ASP.NET MVC project template is now included with ASP.NET MVC 2 Beta. This empty project template contains a minimal set of files used to build a new ASP.NET MVC project.</p>
<h2>Multiple model validator providers</h2>
<p>ASP.NET MVC 2 Beta lets you register multiple validation providers. The following example shows how to register multiple providers.</p>
<pre class="brush: csharp;">
protected void Application_Start() {
    ModelValidatorProviders.Providers.Add(new MyXmlModelValidatorProvider());
    ModelValidatorProviders.Providers.Add(new MyDbModelValidatorProvider());
    //...
}
</pre>
<h2>Multiple value provider registration</h2>
<p>In ASP.NET MVC 2 Beta, the single value provider that was available in ASP.NET MVC 1.0 has been split into multiple value providers, one for each source of request data. The new value providers include the following:</p>
<ul>
<li><em>FormValueProvider</em></li>
<li><em>RouteDataValueProvider</em></li>
<li><em>QueryStringValueProvider</em></li>
<li><em>HttpFileCollectionValueProvider</em></li>
</ul>
<p>These value providers are registered by default. You can register additional value providers that pull data from other sources. The following example shows how to register additional value providers in the in Global.asax file.</p>
<pre class="brush: csharp;">
protected void Application_Start() {
    ValueProviders.Providers.Add(new JsonValueProvider());
    //...
}
</pre>
<p><a title="ASP.NET MVC 2 Beta Release Notes" href="http://go.microsoft.com/fwlink/?LinkID=157069">Download full ASP.NET MVC 2 Beta Release Notes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/aspnet-mvc-2-beta-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Metadata based validation with jQuery</title>
		<link>http://marcinobel.com/index.php/metadata-based-validation-with-jquery/</link>
		<comments>http://marcinobel.com/index.php/metadata-based-validation-with-jquery/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 19:36:36 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=75</guid>
		<description><![CDATA[
Recently I spent some time prototyping my own validation for ASP.NET MVC. Why did not I reuse any of existing solutions? This is a story for another post so I did not want to bring this topic up now. One of the things which I had to figure out during prototyping was how to implement [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://marcinobel.com/wp-content/uploads/2009/10/jquery.validation.png"><img class="alignleft size-full wp-image-76" title="jQuery Validation enabled form" src="http://marcinobel.com/wp-content/uploads/2009/10/jquery.validation.png" alt="jQuery Validation enabled form" width="353" height="498" /></a></p>
<p>Recently I spent some time prototyping my own validation for <a href="http://www.asp.net/mvc/" target="_blank"><strong>ASP.NET MVC</strong></a>. Why did not I reuse any of existing solutions? This is a story for another post so I did not want to bring this topic up now. One of the things which I had to figure out during prototyping was how to implement client side validation. Of course I wanted to utilize capabilities of some well known <strong>JavaScript</strong> framework (no I am not so crazy to write it for my own). I made small evaluation comparing available options and at the end I decided to incorporate <a href="http://jquery.com/" target="_blank"><strong>jQuery</strong></a> and its <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank"><strong>Validation</strong></a> plugin. One of the things which were crucial to my decision was ability of this framework to use metadata stored as <strong>JSON</strong> in class attribute of <strong>HTML</strong> element. The concept of metadata available in<strong> jQuery</strong> is amazing and gives possibility to describe validation rules for specified input control inside itself. In my case this was very important feature because I wanted to render validation using my custom HtmlHelper extensions together with corresponding input controls. Second thing which convinced me to <strong>jQuery Validation</strong> was easy setup which I want to show you now.</p>
<p>If you want to use <strong>jQuery Validation</strong> in your project first of all you will need of course <strong>jQuery</strong> library which can be downloaded <a href="http://jquery.com/" target="_blank"><strong>here</strong><strong></strong></a>, <strong>jQuery Metadata</strong> plugin which is available <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank"><strong>here</strong></a> and <strong>jQuery Validation</strong> plugin downloadable from <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank"><strong>here</strong></a>.</p>
<p>When you collected all required prerequisites you have to add reference to them in your <strong>HTML</strong>. Simply add code shown below to the body of <em><strong><head /></strong></em> tag but remember to ensure that paths lead to place where <strong>JavaScript</strong> files are located.</p>
<pre class="brush: xml;">
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.3.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.validate.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.metadata.js&quot;&gt;&lt;/script&gt;
</pre>
<p>When<strong> jQuery</strong> libraries are already where they should be you can specify validation rules using metadata. In order to do it extend your input control tag with <em><strong>class</strong></em> attribute and set its value to <strong><em>{required:true}</em></strong>. This will tell <strong>Validation</strong> plugin that this specified input control should contain a value before it can be send back to server. Of course this is very simple rule but below I have listed few more, complex definitions.</p>
<pre class="brush: xml;">
&lt;input class=&quot;{required:true, maxlength:100, messages:{required:'This field is required.', maxlength:'This field can contain maximum 100 characters.'}}&quot; /&gt;
&lt;input class=&quot;{maxlength:50, email:true, equalTo:'#Email',  messages:{required:'This field is required.', maxlength:'This field can contain maximum 100 characters.', email:'This is not a valid email.', equalTo:'Value entered in this field should equal to value of Email field.'}}&quot; /&gt;
</pre>
<p>Listing below shows this validation metadata in wider context.</p>
<pre class="brush: xml;">
&lt;form id=&quot;MyForm&quot; method=&quot;post&quot; action=&quot;/Registration&quot;&gt;
    &lt;label for=&quot;DisplayName&quot;&gt;Username:&lt;/label&gt;
    &lt;input id=&quot;DisplayName&quot; class=&quot;{required:true, maxlength:100, messages:{required:'This field is required.', maxlength:'This field can contain maximum 100 characters.'}}&quot; type=&quot;text&quot; name=&quot;DisplayName&quot; /&gt;
    &lt;input value=&quot;Submit!&quot; type=&quot;submit&quot; /&gt;
&lt;/form&gt;
</pre>
<p>At the end when you have defined all validation rules only thing you should do is adding following code after closing <em><strong></strong></em> tag and that is it.</p>
<pre class="brush: xml;">
&lt;script type=&quot;text/javascript&quot;&gt;
    $(&quot;#MyForm&quot;).validate({
        errorElement: &quot;span&quot;
    });
&lt;/script&gt;
</pre>
<p>Now when you will click <em>Submit!</em> button your form will be validated and in case of errors apropriate messages will be displayed below corresponding input control.</p>
<p>Because I know that described example can be not enough to fully understand how all it works I have prepared more complex, example form which can be downloaded from here: <a href="http://marcinobel.com/wp-content/uploads/2009/10/jQuery.Validation.Sample.zip"><strong>download</strong></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/metadata-based-validation-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My favorite System.String extension methods</title>
		<link>http://marcinobel.com/index.php/my-favorite-system-string-extension-methods/</link>
		<comments>http://marcinobel.com/index.php/my-favorite-system-string-extension-methods/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 15:47:26 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=65</guid>
		<description><![CDATA[Each business applications developer spends a lot of the time working with strings. Strings are everywhere and we do not avoid that, but we can make our life simpler. How many times each day do you use String.Format(), String.Trim() or String.IsNullOrEmpty()? This are of course very helpful method but turned out that in my case [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png"><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt=".NET Logo" width="240" height="74" /></a>Each business applications developer spends a lot of the time working with strings. Strings are everywhere and we do not avoid that, but we can make our life simpler. How many times each day do you use <strong>String.Format()</strong>, <strong>String.Trim()</strong> or <strong>String.IsNullOrEmpty()</strong>? This are of course very helpful method but turned out that in my case they do not provide a functionality I require. I found out that almost all the time I am treating null, an empty string and a string with whitespaces only as the same <em>&#8220;undefined/unkown&#8221;</em> value. I am doing that mostly with strings received from outside of my applications where I an interested in <em>&#8220;real values&#8221;</em> instead of for instance a string with spaces only. In this case, methods mentioned above do not meet my needs. Because of that I have created replacement for them as an extension methods and they became my favorite tools to work with strings (I am using them everywhere instead of out of the box methods).</p>
<p><strong>StringExtensions</strong> class defining extension methods:</p>
<pre class="brush: csharp;">
using System;

namespace ByteCarrot.Shared.Infrastructure
{
    public static class StringExtensions
    {
        public static string NullTrim(this string s)
        {
            if (s == null)
            {
                return null;
            }

            s = s.Trim();
            return s == String.Empty ? null : s;
        }

        public static bool IsSet(this string s)
        {
            return s.NullTrim() != null;
        }

        public static string AsFormat(
            this string s, params object[] args)
        {
            return String.Format(s, args);
        }
    }
}
</pre>
<p><strong>IsSet()</strong> extension method &#8211; returns true only if string contains at least one &#8220;printable&#8221; character:</p>
<pre class="brush: csharp;">
if (!this.Commands.IsSet())
{
    this.Logger.LogError(&amp;quot;Commands not specified.&amp;quot;);
}
</pre>
<p><strong>NullTrim()</strong> extension method &#8211; returns string trimmed from both sides and null when base string was null or after trimming turned out that output is an empty string:</p>
<pre class="brush: csharp;">
var commands = this.Commands.NullTrim();
</pre>
<p><strong>AsFormat()</strong> extension method &#8211; shorter replacement for System.String:</p>
<pre class="brush: csharp;">
Resources.RequiredField.AsFormat(&amp;quot;First name&amp;quot;);
</pre>
<p>It is nothing fancy but make my life easier.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/my-favorite-system-string-extension-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReSharper&#8217;s Live Templates for MSpec BDD framework</title>
		<link>http://marcinobel.com/index.php/resharpers-live-templates-for-mspec-bdd-framework/</link>
		<comments>http://marcinobel.com/index.php/resharpers-live-templates-for-mspec-bdd-framework/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 20:57:31 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=52</guid>
		<description><![CDATA[Few days ago Pawel Lesnikowski has blogged about his Live Templates for ReSharper. Because I think it is good idea to share such things with other developers I decided to show my Live Templates I have made to be able to create BDD specifications with MSpec faster. Here they are:
specc &#8211; Short template for MSpec [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago <a href="http://www.lesnikowski.com/blog/" target="_blank">Pawel Lesnikowski</a> has blogged about <a href="http://www.lesnikowski.com/blog/index.php/2009/09/21/my-resharper-templates-for-unit-testing/" target="_blank">his Live Templates for ReSharper</a>. Because I think it is good idea to share such things with other developers I decided to show my <a href="http://www.jetbrains.com/resharper/features/code_templates.html#Live_Templates" target="_blank">Live Templates</a> I have made to be able to create BDD specifications with <a href="http://codebetter.com/blogs/aaron.jensen/" target="_blank">MSpec</a> faster. Here they are:</p>
<p><strong>specc</strong> &#8211; Short template for MSpec BDD context</p>
<pre class="brush: csharp;">
public abstract class with_$Context$
{
	Establish context = () =&amp;gt;
	{
		$END$
	};
}
</pre>
<p><strong>specf</strong> &#8211; Full template for MSpec BDD specification</p>
<pre class="brush: csharp;">
[Subject(typeof($Subject$))]
public class when_$Specification$
{
	Establish context = () =&amp;gt;
	{

	};

	Because of = () =&amp;gt;
	{

	};

	It should_$Behaviour$;$END$
}
</pre>
<p><strong>specs</strong> &#8211; Short template for MSpec BDD specification</p>
<pre class="brush: csharp;">
[Subject(typeof($Subject$))]
public class when_$Specification$
{
	It should_$Behaviour$;$END$
}
</pre>
<p><strong>spect</strong> &#8211; Default template for MSpec BDD specification</p>
<pre class="brush: csharp;">
[Subject(typeof($Subject$))]
public class when_$Specification$ : with_$Context$
{
	Because of = () =&amp;gt;
	{

	};

	It should_$Behaviour$;$END$
}
</pre>
<p>Here you can download definition of all mentioned templates which can be imported to your ReSharper: <a href="http://marcinobel.com/wp-content/uploads/2009/09/MSpec.LiveTemplates.xml">MSpec.LiveTemplates</a></p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/resharpers-live-templates-for-mspec-bdd-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC in a corporation &#8211; part #2</title>
		<link>http://marcinobel.com/index.php/asp-net-mvc-in-a-corporation-part-2/</link>
		<comments>http://marcinobel.com/index.php/asp-net-mvc-in-a-corporation-part-2/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 21:03:49 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=24</guid>
		<description><![CDATA[In my previous post I have mentioned that I am currently evaluating the ASP.NET MVC in context of usage for building internal corporate applications. During the evaluation I have made my small SWOT analysis and I want to share it with you in order to get to know what your opinion on this topic is. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt=".NET Logo" width="240" height="74" />In my previous <a href="http://marcinobel.com/index.php/2009/08/25/asp-net-mvc-in-a-corporation-part-1/" target="_self">post</a> I have mentioned that I am currently evaluating the ASP.NET MVC in context of usage for building internal corporate applications. During the evaluation I have made my small <em>SWOT</em> analysis and I want to share it with you in order to get to know what your opinion on this topic is. Because my all thoughts reside in a mind map I have dumped them to the plain list:</p>
<p><strong>Strengths</strong>:</p>
<ul>
<li>It is based on the Convention over Configuration principle, what means less ceremony in code and more time to focus on business rules;</li>
<li>It is highly extensible with many points of extension in every part of application lifecycle.</li>
<li>It is highly testable no matter if you are using the TDD or BDD style of unit testing;</li>
<li>It is provided by Microsoft – big player on the market, what at least in theory guarantee that the solution will be supported for a long time;</li>
<li>It contains a lot of elements known from classic ASP.NET like notion of session, modules, handlers, HTTP context, views based on ASPX pages and ASCX controls. This is quite important if employees have to switch to the ASP.NET MVC and previously they have used classic ASP.NET, because the learning curve is smaller;</li>
<li>It does not use the ASP.NET postback and view state models what improves testability and separation between user interface and business logic;</li>
<li>It has a routing functionality what enables cleaner URLs;</li>
<li>It gives the full control over all aspects of developed application. Many elements of the ASP.NET MVC can be easily replaced with its custom implementation (i.e. view engine, controller factory);</li>
<li>It gives the full control over HTML and how views are rendered;</li>
<li>It has a great AJAX and JSON support so usage of JavaScript frameworks like jQuery is trivial;</li>
<li>It can be easily integrated with any of popular Inversion of Control frameworks;</li>
<li>It has quite big community, there is a lot of online documentation and books;</li>
</ul>
<p><strong>Weaknesses:</strong></p>
<ul>
<li>It is based on the Convention over Configuration principle, what means more magic working in a background (probably harder debugging in some cases);</li>
<li>It is not event driven, so can be difficult for people who know only ASP.NET Web Forms to wrap their minds around it;</li>
<li>Third party libraries support is not that strong. Not to many companies write extensions for this framework what means more work for internal team;</li>
<li>Current version (1.0) requires some additional effort to reduce usage of magic strings to the minimum;</li>
</ul>
<p><strong>Opportunities:</strong></p>
<ul>
<li>Allows for Test Driven Development – it is build with TDD in mind, so it is much easier to write unit tests, mock objects and to intercept the program flow;</li>
</ul>
<p><strong>Threats:</strong></p>
<ul>
<li>Bigger ramp-up and training time is required for developers with no or little experience in web application development;</li>
</ul>
<p>For the time being this is all what came up to my mind. If you have some other thought I will be grateful if you will share them with me.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/asp-net-mvc-in-a-corporation-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC in a corporation &#8211; part #1</title>
		<link>http://marcinobel.com/index.php/asp-net-mvc-in-a-corporation-part-1/</link>
		<comments>http://marcinobel.com/index.php/asp-net-mvc-in-a-corporation-part-1/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 11:47:00 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVP]]></category>

		<guid isPermaLink="false">http://marcinobel.com/index.php/2009/08/25/asp-net-mvc-in-a-corporation-part-1/</guid>
		<description><![CDATA[Each big organization like this in which I work is mostly based on processes. Everything from purchase orders to computer hardware is described by them. To be honest I am not a big fan of this way of work. My mind is closer to Agile way of thinking rather than stiff procedures for solving problems [...]]]></description>
			<content:encoded><![CDATA[<div class="mceTemp"><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt=".NET Logo" width="240" height="74" />Each big organization like this in which I work is mostly based on processes. Everything from purchase orders to computer hardware is described by them. To be honest I am not a big fan of this way of work. My mind is closer to Agile way of thinking rather than stiff procedures for solving problems but from a bigger perspective this approach seems to work because my current employer has over 100 years and is in very good health.</div>
<p>One thing which is quite funny with processes is that someone has to figure out how each of them should work. In case of my department, which is very young and in its nature very different than rest of the organization, there is no process for many things and we have to develop them for our own. One of our processes is “software development process”. Because the department consists of about 300 developers, administrators and IT specialists and we are using wide range of tools and technologies, the process I mentioned above is very general and describes things in a high level. In order to be able to use it and be safe in case of internal or external audit we need many supporting documents which customize it to a needs of particular team. This detailed documents describe how we should do development in a particular technology (for example .NET Framework), what tools, libraries, methodologies can we use etc. Of course we do not choose tools with which we will work only basing on our subjective opinions and feelings. During choosing process each technology or tool is evaluated by a group of specialist (developers, administrators) and compared to its competitors/equivalents which are available on the market.</p>
<p>Currently I have a pleasure to initialize a process of ASP.NET MVC evaluation. Its purpose is to check if this framework can be used as the replacement for ASP.NET Web Forms and Model-View-Presenter pattern which we are using now. Because the evaluation process does not touch only ASP.NET MVC but also other presentation framework for web .NET application me and my teammates had to prepare a list of things to check and evaluate:</p>
<ul>
<li>Data binding</li>
<li>Validation</li>
<li>Navigation</li>
<li>State saving</li>
<li>Embedded controls support</li>
<li>Testability</li>
<li>Security</li>
<li>Collaboration between developers and UI designers</li>
<li>Adoption to existing projects</li>
<li>Extensibility</li>
<li>Community support</li>
<li>Documentation availability</li>
<li>Development tools support</li>
</ul>
<p>Order in which topics on the list appear is accidental and all items are in my meaning equal in theirs importance.</p>
<p>Because I am currently at the beginning of the ASP.NET MVC evaluation I do not have to much more I could share with you. Only thing I have prepared is a mind map with detailed topics I will have to take a look at. I will provide more information about pros and cons of the framework for a big companies in a next posts. If you would like to hear about something regarding this topic please leave your comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/asp-net-mvc-in-a-corporation-part-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My beginnings with Ruby</title>
		<link>http://marcinobel.com/index.php/my-beginnings-with-ruby/</link>
		<comments>http://marcinobel.com/index.php/my-beginnings-with-ruby/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 12:44:45 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=9</guid>
		<description><![CDATA[Since some time I have had a feeling that I should turn my eyes in direction other than .NET and technologies connected to it. Maybe not as a new path of career, because I have invested a lot of time to get to the point where I am now, but as something additional what can [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-16" title="Ruby Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/ruby_logo.png" alt="Ruby Logo" width="106" height="109" />Since some time I have had a feeling that I should turn my eyes in direction other than .NET and technologies connected to it. Maybe not as a new path of career, because I have invested a lot of time to get to the point where I am now, but as something additional what can give me some new perspective and help to become a better developer. Because I cannot learn all available technologies I had to choose one and only one of them. After reading some blogs and mostly because of Jeremy D. Miller’s opinion my choice fell on Ruby and the Rails. So many developers are excited about this technology, I decided to find out what is a source of theirs excitement.</p>
<p>So how am I going to learn Ruby? First of all I always try to start from a book. In this case I am going to read (in fact I have already started yesterday) Polish translation of “Ruby in a Nutshell” by Yukihiro Matsumoto. I think and the author has the same opinion that this is not the book for someone who is new to programming and wants to learn his first language. The “Ruby in a Nutshell” is something like language reference but in more accessible form so for me (developer with above 8 years of commercial experience) is perfect. I do not need 20 pages of description how to use while loop or what are iterators and where can be used.</p>
<p>I am not able to read this type of book from end to end without touching computer so during reading I am going to play a little bit with the language itself in a more practical manner. In order to do it I had to setup a development environment and there I faced first problems. Turned out that current version of Ruby (1.9) for Windows does not have official all-in-one installer. There is installer for version 1.8 and some preview installers for 1.9 which do not work perfectly (at least on my Windows 7 machine). Because of this I had to install Ruby manually using binary distribution and again I had problems. Of course binaries were in a form of compressed file so I uncompressed them and moved to C:\Ruby directory. Secondly I have added C:\Ruby\bin\ path to the environment variables. In my opinion this should be all I have to do to start learning but turned out that I was wrong. The official binary distribution does not contain all required libraries and was crashing from time to time. After some googling I have found very useful blog post (unfortunately I have lost its address) which solved my problems pointing where I can find missing libraries and where should I put them.</p>
<p>When I had Ruby environment ready to work, theoretically I was able to start playing with it but … I am .NET developer and I used to use reach IDEs with syntax highlighting, suggestions, debugging, refactoring tools etc. I decided to find such tool but about it, learning progress and my thoughts about Ruby from perspective of my quite long experience with .NET I am going to write in some of future posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/my-beginnings-with-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
