Blog Image

Åbn skuffen

This is about

Paying attention to detail


Programming Posted on 2010-09-15 00:16:42

Being spoiled by the concise nature of Perl programs, old fashioned for loops bother me. I know that the traditional 3 statement for-loop is universally understood form, but I can do without the C heritage.

Consider Perl:

for my $var (@array) { push @result, $var }

Versus the C-derivative:

for (int i = 1; i <= array.count; ++i) { result[i] = array[i]; }

The former is simply easier to explain. Of course, in Perl, one would probably end up with:

my @result = map { compute($_) } (1..10);

C# offers something similar:

var result = Enumerable.Range(1, 10).Select(x => Compute(x));

Even though the Range method is a bit unwieldy, this is occassionally a pleasant alternative. And a way of get rid of the last for/foreach loops when having fun with LINQ.

Fluent NHibernate

Programming Posted on 2010-06-14 00:47:48

Even though Fluent NHibernate cannot be called mature, I find it to be a really nice companion for NHibernate. At least, it takes away some of the configuration burden that appears to be part of modern software development.

I like compilers, and I want them to do as much work for me as possible. I like static analysis and how it can help me make permanent improvements to how I program. When we start putting parts of our programs into configuration files, the compile time security is eroded.

Ok, so Fluent NHibernate gives us NHibernate mapping rules in code. And it uses some language features that I appreciate (generics, lambda expressions), e.g.

public class MyClassMap : ClassMap<MyClass> {
public MyClassMap() {
Id(c => c.Id);
Map(c => c.Name);
References(c => c.OtherObject);

With the above, the Hibernate mapping will break at compile-time, when changes are made. At least, some of the time. Nothing is perfect.

Oh, and there’s a convenience class for testing too:

public void CanCorrectlyMapEmployee()
new PersistenceSpecification<MyClass>(session)
.CheckProperty(c => c.Id, 1)
.CheckProperty(c => c.Name, “rasmoo”)
.CheckReference(c => c.OtherObject, new OtherObject())


Programming Posted on 2009-01-28 22:45:42

At first I wanted to write about about craftmanship and paying attention to detail in software development. This resulted in approximately zero blog entries in a year and a half, so I will try a different angle which I am currently calling harmony in IT development.

Perhaps you know how work can be rewarding when you manage to strike a good balance between cost, quality, and speed (or whichever N properties you choose to pick from). Or when a design decision turns out to help you produce Beautiful Code. That’s what I’d rather explore because it seems to be extremely important to have this sensation of relief and accomplishment.

To put in a backwards way, I’d prefer not to pollute my mind with all sorts of strange procedures, hacks, smelly code, obscure commands, and whatnot. Perhaps I’ll complain a bit about things that annoy me from time to time. Let’s see.