Code Elegance

Archive for May, 2008

Good code at a glance

I like readable code. I like well written code. I like ordered code.

Sometimes this characteristics are measurable giving just a fast look at a piece of code. Here an example: which one of this two snipped do you think is better?

bad good

 

Even if you can’t read the code (I applied a blur effect) you can see at a glance which one seems better.

The first contains a lot of executable path, nested if and one long method, (it smells!). The second is more linear and well-organized.

The problem with the first one is that is hard to read. Consider the following image which shows the path that my eye has to do to read them:

 

bad_lines good_lines

 

To read the first one I have to continually enter in a new context (code block), this because the McCabe index is quite high for this method.

This doesn’t mean that the first piece of block is absolutely better than the second, it’s just a quick evaluation based on what the code look like (remember that readability is a quality of good code).

Technorati Tags: ,,
No comments

New podcasts from the ALT.NET World

A new web site is born and it publsh podcast on ALT.NET. The first one is about Continuous improvement, you can find it here: http://altnetpodcast.com/

No comments

Second Italian ALT.NET (medium) conference

It’s official, fix the date: 14-06-2008, fix the location: Milan.

That’s the day of the second ALT.NET Conference, if you want to join us you can take a look here (sorry the page is in Italian :-| ).

The day is focused on developing a blog engine using the agile methodologies, the ASP.NET MVC, IoC and all the others things that we like.

During this days, we are planning to write some stories that we will implement at the conf, so you can help us if you want on the mailing list of italian ALT.NET movement (here).

No comments