Saturday, April 19, 2008
I've been in a bit of a blogging slump. I blame taxes, NHL playoffs and an upcoming wedding for the slump. Bil recently posted a meme about being trapped in an elevator with 2 other geeks. The jist of it is if you were trapped in an elevator with 2 other geeks, who would you be trapped with and why.*

I would choose to be trapped with:

  •  Reginald Braithwaite because I like reading his essays and I believe I could have a meaningful conversation about various software development topics with him.
  • John McCarthy I would like to talk programming languages and AI with him.


* I've actually been trapped in an elevator before for 2 hours with a friend and it sucks big time. I try and take the stairs now.

Saturday, April 19, 2008 5:16:39 AM (GMT Standard Time, UTC+00:00)  #    Comments [2]  | 
Tuesday, April 01, 2008

Via Marc-Andre Cournoyer on Twitter, a reason for ASP.NET developers to switch to Rails: http://www.railsjedi.com/posts/15-Acts-as-ASP-NET-a-Ruby-on-Rails-Plugin-

Sadly, I bet I could sell Ruby and Rails to local businesses easier by showing them this page.

P.S. I am the altnet purse fight blog author. No one ever suspects the quiet guy.

Tuesday, April 01, 2008 9:11:50 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
Friday, March 28, 2008
Last night I tried installing Visual Studio 2008 and the .NET 3.5 Framework. I kept getting the error: "Error: Installation failed for component Microsoft .NET Framework 3.0a. MSI returned error code 1603".

Not very informative. I eventually ended up getting it installed by temporarily uninstalling IIS. Hope this helps someone else out who is having the same problem.

Friday, March 28, 2008 5:25:21 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
Wednesday, March 05, 2008

Sweetness!

booishMac.png


Wednesday, March 05, 2008 5:51:55 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
Friday, February 08, 2008

Today I was creating a test data builder for a unit test. I am fairly new to test data builders, on the last project I was on I relied on the ObjectMother pattern which became fairly tedious over time. Both the ObjectMother pattern and the Test Data Builder are Test Helper patterns:

"We define a helper class to hold any Test Utility Methods we want to reuse in several tests." 

If your objects aren't immutable and all you really care about is getting sensible test data without having to repeat yourself, you can use the Rhino Mocks GenerateStub feature to provide sensible test data and deal with invariant test data:

 

[TestFixture]
public class InvoiceTests
{
    [Test]
    public void ShouldCreateInvoiceWithNoPostalCode()
    {
        Invoice invoiceWithNoPostalCode =
                new InvoiceBuilder()
                .WithRecipient(new RecipientBuilder()
                    .WithAddress(new AddressBuilder()
                        .WithNoPostalCode()
                        .Build())
                    .Build())
                .Build();
 
        Assert.AreEqual(string.Empty,
            invoiceWithNoPostalCode.Recipient.Address.PostalCode);
    }
 
 
}
 
public class InvoiceBuilder
{
    private Invoice invoice;
 
    public InvoiceBuilder()
    {
        invoice = MockRepository.GenerateStub<Invoice>();
    }
 
    public InvoiceBuilder WithRecipient(Recipient recipient)
    {
        invoice.Recipient = recipient;
        return this;
    }
 
    public Invoice Build()
    {
        return invoice;
    }
}
 
public class RecipientBuilder
{
    private Recipient recipient;
 
    public RecipientBuilder()
    {
        recipient = MockRepository.GenerateStub<Recipient>();
    }
 
    public RecipientBuilder WithAddress(Address address)
    {
        recipient.Address = address;
        return this;
    }
 
    public Recipient Build()
    {
        return recipient;
    }
}
 
public class AddressBuilder
{
    private Address address;
 
    public AddressBuilder()
    {
        address = MockRepository.GenerateStub<Address>();
    }
 
    public AddressBuilder WithNoPostalCode()
    {
        address.PostalCode = string.Empty;
        return this;
    }
 
    public Address Build()
    {
        return address;
    }
}

Once again be warned that this does not work for immutable objects, I don't recommend making value objects mutable just to implement this pattern so i'm not sure if it actually provides any real value. Maybe if it is combined with a mutable entity and a custom builder for a value object that preserves that value object's immutability. 

If anyone that reads this blog has a way to make Test Data Builders easier I would be glad to hear it.

 

[Currently Listening To: Young Galaxy- Young Galaxy - Wailing Wall]

Friday, February 08, 2008 6:56:17 AM (GMT Standard Time, UTC+00:00)  #    Comments [3]  | 
Tuesday, February 05, 2008

Justice asked a bunch of us to write a treasured memory that we have of Donald Belcham as a birthday tribute to Don. I am in a bit of a blogging slump so I figured I would oblige his request.

My memory is from DevTeach Vancouver last year. It all started at the Party with Palermo. Donald started the night off having a great conversation with a bunch of us about the merits of TDD and how it relates to life, the universe and everything.

Then someone told him that the booze was free.

Donald proceeded to order the finest scotch available in the bar. For those that don't know him Scotch to Donald is like Beer to Bender. Donald was ok but then Jeffery Palermo announced that booze would only be free for the next 5 minutes.

I was standing at the bar when the announcement was made and I heard Donald yell "LETS DO SHOTS!!!". Luckily Donald kept it classy and suggested that everyone do Prairie Fires (tequila and Tabasco). Knowing the dangers that Prairie Fires can bring, I tried to convince Donald that he should do something less harsh like Whiskey.

After 10 Prairie Fires everyone was amazed that Donald had proceeded to keep them down and we went for more drinks at The Earls on Robson Street. After 10 minutes I look over at down who is slumped over and hiccupping. 10 more minutes pass and Donald's cheeks are full with a finger holding in the gray liquid that eventually shot out into D'Arcy Lussier's hot chocolate (that whole sentence just sounded wrong).

DSCF1702

The next day Donald was scheduled to present and he lays out a great metaphor which to me, is pure Donald Belcham:

"A development shop without Cruise Control and NAnt is like having too many prairie fires here at DevTeach. Everything looks ok on the outside but sooner or later things are going to blow up."

PHENOMINAL!

If this blows your mind, make sure to check out Donald at this year's DevTeach Toronto. He will be presenting not one, count em 4 different presentations all likely to be fuelled by prairie fires and scotch.

Tuesday, February 05, 2008 8:20:52 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
Tuesday, January 08, 2008

I like reading other people's posts on the year that was 2007 so I thought I would try it myself.

During 2007 I had a lot of fun in software development

- I managed to somehow do 3 speaking engagments, 2 at the Calgary and Edmonton Code Camps and one at DevTeach. Although I had fun presenting, i'm not sure if the spotlight is for me. Helping the community has always been one of my main goals but I got into software development because I like coding. I could care less if I get my way paid to various conferences based on my speaking ability I would rather be recognized for my coding ability.

- I completed all of my goals that I had for becoming a better developer. This surprised me as I thought I was way behind on them.

- I contributed to a couple OSS projects. In 2008 my main goal will be to give away even more code. Take it, its yours.

- I found something new that I am going to use to motivate myself to get my skills another level, I'll probably write about it sometime in the future but now is to soon.

 

Non-Technical Stuff

- Last year started out very poorly for me. I lost my last remaining Grandfather a year ago today, he was my hero and things haven't been the same without him.

- I was finally able to move into a new condo that I bought with my fiance. No more paying rent for me. Despite having a flood and still waiting on our floor to be replaced I am happy with the new place.

- I got to help my fiance Catherine celebrate a special birthday this year.

- My dog somehow got published in a book and featured on Entertainment Tonight (blog post dog mention quota met).

Whats in store for 2008

- I am getting married in May of 2008. At least if we can get organized in time.

- More OSS coding than last year.

- Many more things that I have yet to find out about.

Tuesday, January 08, 2008 3:31:19 PM (GMT Standard Time, UTC+00:00)  #    Comments [2]  | 
Saturday, December 01, 2007

For everyone that was at my DevTeach presentation thank you for showing up and listening to me. I had my adrenaline flowing and ended up finishing a little to early, if only I could code like that day to day!

If you have svn installed, you can download my presentation from the command line with the following command:

svn checkout http://stevenrockartspresentations.googlecode.com/svn/trunk/ devteachgenericspresentation

I still have to do one more check-in to add my reduce implementation and to clean up the code. I am also going to upload a zipped version of the code to the downloads section located here: http://code.google.com/p/stevenrockartspresentations/downloads/list

 

Here is a list of resources from the presentation:

- Combining Generics, Specifications and Functional Programming Part 1

- Combining Generics, Specifications and Functional Programming Part 2

- Combining Generics, Specifications and Functional Programming Part 3

- Combining Generics, Specifications and Functional Programming Part 4

- Follow up to Generics Presentation Feedback

- Reduce in C#

Saturday, December 01, 2007 5:12:27 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 

I got a couple of emails with great feedback from my last couple of posts. I think I could probably turn this presentation into 2 different presentations but it is curing my blogging writers block so i'll post the responses here for everyone's benefit.

Shane was very quick to point out that the method signature in Customer is kind of misleading:

public bool IsAnActiveCustomer(ISpecification<Customer> activeCustomerSpecification)

We could actually pass any specification that implements the ISpecification interface into this function. We can refactor a little to make it a little more clear to someone consuming the Customer class:

public bool IsAnActiveCustomer()
{
    return this.Matches(new ActiveCustomerSpecification());
}
 
public bool Matches(ISpecification<Customer> specification)
{
    return specification.IsSatisfiedBy(this);
}

Using this approach we supply consumers of our class with a default for an active customer and allow them to specify their own specification for what constitutes an active customer.

One thing that I should have mentioned in my post is that Filter and Map are included in the List class in .NET 2.0. Filter == FindAll and Map==ConvertAll, here is the code from Reflector:

public List<T> FindAll(Predicate<T> match)
{
    if (match == null)
    {
        ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
    }
    List<T> list = new List<T>();
    for (int i = 0; i < this._size; i++)
    {
        if (match(this._items[i]))
        {
           list.Add(this._items[i]);
        }
    }
    return list;
}
 
public List<TOutput> ConvertAll<TOutput>(Converter<T, TOutput> converter)
{
    if (converter == null)
    {
        ThrowHelper.ThrowArgumentNullException(ExceptionArgument.converter);
    }
    List<TOutput> list = new List<TOutput>(this._size);
    for (int i = 0; i < this._size; i++)
    {
        list._items[i] = converter(this._items[i]);
    }
    list._size = this._size;
    return list;
}
Saturday, December 01, 2007 3:39:40 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 

At my DevTeach presentation I showed how you can do Map and Filter from Functional programming right now in C# 2.0. In mathematics Reduce is "the process of manipulating a series of equations or matrices into a desired 'simpler' format". In C# you can think of it as taking a list and reducing it down to one value. 

Here is my implementation of Reduce in C# 2.0:

[Test]
public void ShouldReduceListOfIntegersToTotal()
{
    IList<int> numbers = new List<int>();
    numbers.Add(1);
    numbers.Add(2);
    numbers.Add(3);
    numbers.Add(4);
 
    RecordBook<int> recordBook = new RecordBook<int>(numbers);
 
    Assert.AreEqual(10, recordBook.Reduce<int, int>(numbers, Add));
}
 
[Test]
public void ShouldPrintIntegersAsOneString()
{
    IList<int> numbers = new List<int>();
    numbers.Add(1);
    numbers.Add(2);
    numbers.Add(3);
    numbers.Add(4);
 
    RecordBook<int> recordBook = new RecordBook<int>(numbers);
 
    Assert.AreEqual("1234", recordBook.Reduce<int, string>(numbers, BuildStringFromIntegers));
}
 
private string BuildStringFromIntegers(int number, string test)
{
    return test + number;
}
 
private int Add(int number1, int number2)
{
    return number1 + number2;
}

and the implementation of the tests:

public delegate TResult Accumulator<TSource, TResult>(TSource x, TResult y);
 
public TResult Reduce<TSource, TResult>(IList<TSource> source, Accumulator<TSource, TResult> accumulator)
{
    TResult result = default(TResult);
 
    foreach (TSource item in source)
        result = accumulator(item, result);
 
    return result;
}

The first test calculates the sum of adding all the integers in the list together using the add function. The second test takes an integer and concatenates it to a string producing a string of all the integers in the list.

The Reduce function introduces the default keyword that you can leverage with generics. This will give you the default value for value types (0 for integers, 0.0 for decimals, null for string).

Saturday, December 01, 2007 1:21:02 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: