пятница, 27 апреля 2007 г.

Test or not to test first

As soon as I had more or less clear idea of what should be done I started creating the application. During last few years I was one of the fans of agile methodologies and integrated them on all projects I participated into. I was so eager to start that ignored practices of TDD and start coding to gain immediate results (Honestly, haven’t done it on production projects for the last years). I did write tests – initially I created no UI, and used NUNit to run simulations (I do it even now). And after having first results very fast (like having simulation for several creatures “fighting” with each another) I recognized that some nasty bugs appeared there. In most cases it caused incorrect results and incorrect statistics of simulation. Code did compile and some results were produced – but I had to spend type debugging more and more each day.

I had no other choice (at least a reasonable one) than cover existing code as much as possible not to miss any possible bug and save my time further. I downloaded NCoverExplorer and started measuring coverage. Well, it was not so bad even initially (~50%) but I forced me to write tests at the same time (I know that classical way is to write tests first but another approach works for me so far) as writing functionalities and measure coverage all the time. Well, it was event pleasant seeing how the coverage grows…

As a conclusion – write tests, check the code coverage(and keep it high) ,don’t skip good practices, even if you’re making something for yourself – otherwise you’ll loose your time that you could spend for something interesting

Regarding writing tests first – personally for me it is almost the same if I keep in mind what I am going to achieve while writing them

суббота, 21 апреля 2007 г.

Starting C# project

Well, I was happy to start a project for my own excitement (I participated in some during last seven years for different companies though). About a year ago I found myself a new hobby – playing D&D miniatures http://www.wizards.com/default.asp?x=dnd/minis.

At some point it appeared that many people are consider themselves as experts (it's locally in my country, Belarus) in such topics like forming proper bands, deciding what figurer better than another, etc. I found many opinions useful for developing my playing skills. However, I thought that some mathematical/modeling background would be useful for me. And I was right – after running a few simulations I made myself much better band and won that expert who was enforcing his thought. Indeed, only modeling wouldn’t ever allow to win easily – but it helps you understanding how statistics for each figure in a specific band is laid down. Well, as any D&D played knows – if you roll the dice well, it’s much easier for you to win, but if you have a poor band – you have no chances against overwhelming opponent.

The initial idea was:
- Create an application that would allow to model different situations on D&D miniatures’ board and allow gathering statistics for different bands, maps, strategies.
- Enhance own programming and modeling skills as well as learning new technologies
- Bring myself as much joy as possible to recreate a little from leading another production project (meaning that I had not too much time for development)

I had two main choices for possible programming languages/platforms:
- Python
- .Net/C#

I spent some time programming Python 3 years ago but didn’t advance too far, honestly. Thus to improve myself I could pick Python and make everything using it.

Last 4 years (may be more, I need to check my CV for details :) ) I programmed (or leading) projects based on .NET framework. Thus I gained some skills there.

Initially I started playing with Python to evaluate how is going for me. Well, I managed to write a few simple applications but figured out that my performance wasn’t too high though. Thus I switched to .NET and started the application there.

To make myself more aware about different technologies that I had been using before I downloaded a few programs that I wasn’t used often before:
- SharpDevelop 2.1
- SVN plus TortoiseSVN
- NCoverExplorer
And more tools that I was familiar with:
- NUnit 2.9
- FXCop 1.35

So I was more or less prepared and started making the model.