Code Elegance

Agile Testing Days in Berlin

From 12th to 14th I will be in Berlin for the Agile Testing Days not only as an attendee but also as a speaker.

With Alessandro I will present a session on Continuous Integration, a 60 minutes walkthrough on the setup process of a CI Server.

Here you can find the agenda of the days: http://www.agiletestingdays.com/programme.html

I will write more about our session in the next weeks on this blog.

Technorati Tags:
Posted in ALT.NET, Course, TDD | No comments

The Application

In these days we are working to a big application and iteration by iteration the design is coming out.

We found that what our users want is this:

Capture

Posted in Design, Rant | No comments

Who calls me?

When we need to write the caller information in the log file we usually write a call like this:

_log.Error(“ThisClass.ThisMethod”, ex.Message);

The specification of the caller class and method is convenient to have information about the error location, but writing that string all the time is boring.

Searching in the .NET Class Library I found the class StackFrame that enable the program to access the application stack, so I write this piece of code:

public void Error(Exception ex)
{
     StackFrame sf = new StackFrame(1);
     _log.Error(
         String.Concat(sf.GetMethod().DeclaringType.FullName, ".", sf.GetMethod().Name),
         ex.Message);
}

This method navigate the stack up one level and using the StackFrame extract the caller class and the caller method and write them to the log file.

Maybe many of you already knows the StackFrame class, but the .NET Fx is big and while searching in it you always find something interesting.

Posted in Logging | No comments

Blend3 preview does not show the design view

I’m trying Blend3 preview on an quite big project and all the windows and user controls were available only in XAML view while the design view was disabled.

I post a question on the blend forum and after a mail to Unni Ravindranathan he have found the solution.

You must open the .csprj file with notepad and add this element as a child of PropertyGroup:

<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Maybe the problem is because the project is quite old and I created it with Visual Studio 2008 without SP1.

Posted in Blend, WPF, XAML | No comments

The sessions are online, now it’s time to vote

After two months in which we collected the sessions proposal for the next UgiALT.NET conference, today we published the list and opened the poll for vote your preferred sessions.

We are very satisfied about the collected sessions, 18 proposals on variuous arguments all with something very interesting.

Some of the arguments are: Mono, XNA, Rhino ETL, UIX design, CI, Spring.NET, Scrum, etc…

So now it’s time to vote your five preferred sessions and wait until the 27 June to came to listen and discuss with us.

You can vote here: http://groups.yahoo.com/group/ugialtnet/surveys?id=12895553 and get more information here: http://ugialt.net/IV_UgiAltNetConf.ashx

Posted in ALT.NET | No comments

Are we sure that goto is dead?

Last week, during a code review I found this code (I cut some lines to keep the post short)

 

// [Cut]
case USER_AGENT:
     // [Cut]...various code....
     goto default; //we want it to be added to serverVariables
case CONTENT_TYPE:
     // [Cut]...more code (with some "if")
     goto default; //we want it to be added to serverVariables
 case USER_LANGUAGE:
     ParseUserLanguage(variableValue);
     break;
 default:
     ServerVariables.Add(variableName, variableValue);
     break;
// [Cut]...continue...

No words.

 

Technorati Tags: ,,
Posted in Design | 3 comments

Horizontal growth

Reading some posts about “gratification” on Luka’s blog I think how (in Italy) the next step for a software developer is to  became a project manager.

First: it is not clear how this two roles are correlated. It’s absolutely false that a good developer will be a good manager.

Second: what make you think that I, as a developer, want to became a project manager? I love my profession, I love develop software and I hate working with project and excel.

I would like that our bosses would give us other path, an alternative to the vertical growth. I would like to have the horizontal growth.

I mean, I would like to have more space to try new practices, to go to the conferences, to buy new books and to learn new technologies.

This would benefit all the company because I would share my know how with other developers and I could give something different to my company.

So, managers out there: think about this!

Posted in Project Management | No comments

TDD Course in Bologna

Like I already write here (in Italian) next week I will teach a the Test Driven Development Course in Bologna.

The course is in two days and will have a practical cut (most of the second day is dedicated to write a real application in TDD).

We will start from Unit Testing, passing through the Mock Objects and Refactoring to arrive to real TDD.

And for the UgilALT.net members there will be a 10% discount.

More info here.

Technorati Tags: ,,
Posted in ALT.NET, Course, TDD | No comments

1024 Tests

I love Unit Tests, and I feel very confortable when the number of tests is high :-)

1024

Posted in Design, Resharper, TDD | No comments

Working with Legacy Code

I give special attention to code readability and good design when I write programs, these are two metrics that I care about. I like the idea that the team members can read code and understand what the code does.

Today I spent two hours to find a silly bug. I dig with the debugger until the code near the bug, and in that code I have this instruction: 

collection.Add(currentKey, newValue);
 
The name of the method talk for it, the parameter are clear and so I didn’t step into the method to view what happens thinking that the error was in another location. Then after 1,5 hour of search without result I decided to step into the Add method and this is what I found: 
public void Add(String key, MyObject value)
{
  if (value == null)
  {
    Remove(key);
  }
  else
  {
    if (ContainsKey(key))
    {
      this[key] = value;
    }
    else
    {
      _base.Add(key, value);
    }
  }
}
The big problem here is that Remove that live in an Add method!
This paradoxical situation create a big headhake, why an Add method should remove one element from the collection? If you decide to call it Add there will be a reason, why?
 
It is one of most important things to  remember when you write code: the name of a method must meet it’s implementation! It’s simple but very valuable!
 
 
Posted in Design | No comments

Next Page »