Far Away Developer

Sebastien Lachance

Archive for the 'Project' Category


I am now available to hire !

Posted by Sebastien Lachance on March 3, 2008

I am now available to work on small contracts for now. I also want to work remotely. If you are interested, just let me know via the contact form.

HIRE ME !

Posted in Blogging, General, Programming, Project | No Comments »

WHILSOF : ReadOnlyCollection<T>

Posted by Sebastien Lachance on February 26, 2008

Problem :

I have a collection of entities in my repository. Those entities are not supposed to be visible to the outside world. But, In a test I am supposed to see if all objects are still there and I can’t use the GetAll method because it goes to the database and return everything, not just the collection of entities in my repository.

Solution :

I could expose the collection but how can I be sure that nothing will be changed. I could create a copy of the collection but that would not reflect the “Entity” concept. I know that Java has support for returning a read-only collection. A little bit of search and I found the class ReadOnlyCollection<T>. This is thread-safe and any changes to the original collection will be reflected in it since it is only a wrapper.

public static IList<IRecipe> _identityMap = new List<IRecipe>();

  public IList<IRecipe> IdentityMap
  {
      get { return new ReadOnlyCollection<IRecipe>(_identityMap); }
  }

Could not be easier!

Posted in .NET, Learning, Project | No Comments »

WHILSOF : What Have I Learn SO Far

Posted by Sebastien Lachance on February 22, 2008

I have been pretty busy lately. I have so much fun working on my project, that I have neglected my blog a little. As part of my “Building a New Application Series“, I will introduce another series under it, the “What Have I Learn SO Far”. As you may know, I started this project as a challenge (The “What I can do in the next 6 months to become a better developer ) to learn more. This series will consist of various knowledge I acquired during the course of the project. I have already learn a lot and I have multiple items on my list to blog about. Various stuff about application architecture, xUnit, NHibernate, Domain Modeling, etc. I’ll try to deliver great content. 

Posted in Blogging, Programming, Project | No Comments »

Setting up a basic continuous integration server with TeamCity

Posted by Sebastien Lachance on February 6, 2008

What is TeamCity? It’s a software that you would use to do continuous integration. Continuous integration is very important and it should never be an option on a serious project (that’s is my opinion and I strongly believe in the values it provide).

If you have followed the Building A New Application Series, you may be wondering why I would want to do that after setting up a complete integration server with CruiseControl.NET. Well, I was skeptical when I first heard about all the fuss surrounding this JetBrains project. After all, CruiseControl.NET was doing everything I wanted and more.

So the reason I made the switch is because of the time it take to set it up : 20 minutes. Everything was fully functional in under 20 minutes. I absolutely got no error at all. I just got through all the step of the wizard and then : done. Unit testing, code coverage, build, reports, etc… And it’s absolutely free for small team.

The big downside for me was the lack of support out of the box for other unit testing framework (other than NUnit and MSTest). My project is using MbUnit so I will need to do some more research to integrate it in my build process. But it is possible if you want to invest time in doing so.

So let’s get started with this little tutorial :

1. Download TeamCity.

2. Start the installation.

Just follow all the steps. I encountered a slight problem due to something already on port 80, so I used the port 8080.

TeamCity_001

TeamCity_002

TeamCity_003

TeamCity_004

TeamCity_005

TeamCity_006

TeamCity_007

I left everything intact in this screen, but this is where you specify some default folder used bu the build agents. The tempDir and workDir will be used to store your application artifacts and even your source file before the compilation if you don’t give it one in the configuration (later).

TeamCity_008

TeamCity_009

TeamCity_010

That’s it, you have installed TeamCity. Now let’s add our project to it.

3. Open TeamCity !!!

TeamCity_011

TeamCity_012

Nothing too complicated here, just enter the username/password you want for the administrator account. The email will be used to sent important information the build server would want you to know..

TeamCity_013

What I like is that you will be taken by the hannd for the rest of the steps. Click on the Create Project link.

TeamCity_014

Name of the project and a description. It will be useful if several projects are on the same build server.

TeamCity_016

Now click the Create build configuration link. You can have multiple build configuration by project.

TeamCity_019

In the build configuration window, you can change the way the build number are generated and the default behavior when the build fail. You can also specify that you want to start with a clean project.

TeamCity_020

There, you can decide how you want the project to be retrieved from the source control repository and where to put him. You can also decide when to label your build. If you do not want a label on a failed build, you can do so. Next, click on Choose build runner.

TeamCity_021

TeamCity is not only for .NET project. Several build runner are included such as MSBuild, NAnt, sln2003, sln2005, sln2008, Ant, Maven2, etc… Because I am using MbUnit as a testing framework I have decided to stick with MSBuild. But if you are using NUnit or MSTest you may want to use sln2003, sln2005, sln2008 as they can run your unit tests and tell the coverage of your assemblies. You need to fill in the Solution File Path field with the name of your .sln, it’s relative to your project structure (if it’s in the root, enter only the name of your solution file. Fill the rest of the field if you are using NUnit or MSTest.

TeamCity_022

Last step! Go to the Version Control Settings tab and click Create and attach new VCS root. Give it a name and choose the version control system (VCS) you want to use. Fill in the required field.

Save, and you’re done!

This is the most basic setup you can have. Of course, there is a lot of other things to configure to your specific needs. You can even have integration inside Visual Studio or Eclipse. As I said before the only downside I found is the lack of support for MbUnit, but I will work something to bypass that.

I may do another post going more in depth if I have time. Or maybe a screencast, that would be a lot of fun. If you’re interested, just leave a comment and I will consider it.

Posted in Agile, Continuous Integration, Learning, Project | 5 Comments »

NHibernate - SaveOrUpdate does nothing?

Posted by Sebastien Lachance on January 23, 2008

Of course it does something, just make sure you call the Flush method on your session…

I have just started playing around with NHibernate for a personal project (the one I use for the Building a new application series) and I’m liking it. This make all the data access seems so easy. Maybe I will change my point of view after dealing with some collections and relationships.

Posted in .NET, Design, Learning, Project, Tools | No Comments »

Setting up a Subversion server (using svnserve)

Posted by Sebastien Lachance on November 29, 2007

(Index of the whole series)

I got hold of an old computer that I will be able to use as a continuous integration server and Subversion repository. This weekend, I got some free time and decided to set-up Subversion on it. I was surprised on how much it was easy. The documentation is all but superfluous and it was very instructive. So here is how you can do it.

Downloading and installing subversion

You can find the latest version here. I used the svn-1.4.5-setup.exe one. Just install it like any other program, there is no additional things to modify in the setup.

Setting up a repository

You may want to create a repository right now to make sure that you can make some test later. I recommend using TortoiseSVN for that, unless you want to learn all the command to use Subversion (not so hard to do). To do that, you simply need to create a folder that you want as a repository (this folder will hold all your files and every change made to them), and right click on it. Select the TortoiseSVN\Create repository here menu items and select the Native File System (FSFS) radio button. You now have fully working repository. For a comparison of Native File System versus Berkeley Database, take a look at this link.

createrepository

svnserve

You then have two choices to use Subversion remotely. First one is to use the Apache HTTP server and the second one is to use svnserve. I have decided to use svnserve because it’s a lightweight server program and I don’t need encryption and logging. Also svnserve is a lot faster and it’s the best options for small teams. You may want to make sure you are able to access it. Open a command prompt and type svnserve. You should see the following :

svnserve-commandprompt

If you still planning to use svnserve right now, you have two choices : install it as a service or open it each time you want to access a repository.

If you are planning to open it each time you want to access your repository, launch a command prompt and type svnserve -d. You have access to all the repositories you may have created on the server.

If, however, you decide to use it as a Windows Service (it will reopen automatically each time you start the server), Use this at a command prompt :

C:\> sc create svn binpath= “\”C:\program files\svn\bin\svnserve.exe\” –service -r C:\nameofyourrepository” displayname= “Subversion Server” depend= Tcpip start= auto

Controlling access

If you attempted to use this right now to make a check-in, you will find that you don’t have Write access. This can be changed by editing the svnserve.conf found in your repository folder. You need to find the # anon-access = read and change it to anon-access = write (don’t forget to remove #). This will grant write access to all anonymous users. This is not the ideal, but in a single programmer scenario it works perfectly. However, note that if you need a more robust authentication solution, it’s totally possible. I will not cover it right now, but the full procedure is described in the TortoiseSVN documentation (Section 3.2.4).

svnservedotconf

 

Accessing the repository remotely

Open the repository browser (shown below) and type svn://nameofyourserver/nameofyourrepository. Can it be more easy?

access

Posted in Agile, Project, Tools | No Comments »