Friday, December 8, 2006

42 is the answer to any problem

I can now officially state and prove that solution to any problem is 42!

Let me run my solution by you. Lets assume that the problem is represented by a variable: X
My prove:
1. if x * 0 = 0
2. if 42 * 0 = 0
3. then (x * 0) = (42 * 0)
4. divide both sides of the equation by 0: x * (0/0) = 42 * (0/0)
5. since both sides of the equation contains (0/0) we cancel it out of the equation and end up
with x= 42!

Since any problem can be expressed mathematically, I can now say that the solution to any a problem is 42!

My special thanks to Dr James Anderson, from the University of Reading's computer science department, that made my prove possible.

Of course anyone with any basic math skills may point out that we are not allowed to divide by zero since it is undefined operation. In the computer world we know that division by zero produces a NAN (Not A Number) but thanks to a new number "nullity" (-0-) that Dr. Anderson proposed we can now safely divide by zero to solve all kinds of the problems!

I found his lecture extremely interesting and I have enjoyed people's responses to his solution to 1200-year-old problem. I can not wait to talk to him on December 12th

Monday, December 4, 2006

"the error code 2869" while running installations in Vista

I have run into interesting problem in Windows Vista, while I was installing Web Service Software Factory and GAT I kept getting 2869 error code, followed by a few empty 'OK' prompts.

It looks like this error is due to the installation package requiring administrative rights. In my case installation package was denied contact with Visual Studio 2005.

There are several ways to fix this problem:
1. create a batch file containing msi package, and run it as Administrator
batch file will contain following line: msiexec /i {package.msi}

2. run msi from the with elevated privileges command prompt.
Find your "Command Prompt", typically located in: %SystemRoot%\system32\cmd.exe (or just search for Command Prompt); right click on it and select "Run as Administrator", and then navigate to your msi file

Saturday, December 2, 2006

Register for CodeMash

This is a great opportunity for developers to get together and exchange ideas and learn what is going in different branches of technology. I am looking forward to the event.

CodeMash – I'll be there!

Wednesday, November 29, 2006

NHibernate repository variation on the Criteria

After reading Dave Donaldson post on NHibernate repository, I was pleasantly surprised on how similar our implementations are. By 'our' I mean Kevin Spargue and I; we are using NHibernate on one of our projects. This is my third NHibernate project and this time around we have enough time to sit down and make corrections to hard learned lessons of using NHibernate. One of those days I will get around publishing our version of the NHibernate repository, but for right now I would like to add our variation on dealing with criterias.

Originally we started with the similar implementation as in Dave's repository:
public static Collection FindByProperty(string property, object value)
with an overload
public static Collection FindByProperty(string[] property, object[] value)

but then we have decided against it, and end up with creating a class wrapper that have included property value, name and operator. This implementation helped us to reduce the number of methods we need to maintain and have provided us more flexibility when it comes to & finding/filtering data.

Repository methods
public static IList Find(QueryValueCondition[] queryValueConditions, QueryOrCondition[] queryOrConditions)
where T : IPersist
{
if (queryValueConditions == null) queryValueConditions = new QueryValueCondition[0];
if (queryOrConditions == null) queryOrConditions = new QueryOrCondition[0];
IList results = new List();
Type type = typeof(T);
IList list = Find(type, queryValueConditions, queryOrConditions);
foreach (T item in list)
results.Add(item);
return results;
}

public static IList Find(Type type, QueryValueCondition[] queryValueConditions, QueryOrCondition[] queryOrConditions)
{
IList results = Accessor.LoadList(type, queryValueConditions, queryOrConditions);
return results;
}

Accessor implementation (Helper class consists of a few static methods that help us final query assembly.)

public static IList LoadList(Type type, QueryValueCondition[] queryValueConditions, QueryOrCondition[] queryOrCondition)
{
IList results = null;
ICriteria criteria = NHibernateSession.CreateCriteria(type);
foreach (QueryValueCondition valueCondition in queryValueConditions)
criteria.Add(Helper.GetCritria(valueCondition));
foreach (QueryOrCondition orCondition in queryOrCondition)
criteria.Add(Helper.GetOrExpression(orCondition));
results = criteria.List();
return results;
}

I will not dive into the details of the methods, but I do want to talk about: QueryValueCondition and QueryOrCondition.

QueryValueCondition class consists of properties wrapped around fields:
string _propertyName = string.Empty;
object _propertyValue = null;
Operators _operators = Operators.Equals;

Operators is a simple enumeration
public enum Operators
{
Equals,
GreaterThan,
GreaterThanEqualTo,
LessThan,
LessThanEqualTo,
Like,
IsNull,
In,
IsNotNull
}

This class allowed us to group a set of data into a logical unit, that contains everything we need to be able to retrieve data on a passed property value.


QueryOrCondition class contains wrap around properties for following fields:
QueryValueCondition _leftCondition = null;
QueryValueCondition _rightCondition = null;

Just an additional class that allow to group multiple properties into OR condition. So now we can use one Find method to get data by one or more properties and we have a power of matching it by various conditions.

Tuesday, November 21, 2006

Installing Team Build

After finishing the installation of TFS, one may notice that Team Build is not installed with it. It is a separate installation. Depending on the version of the TFS it may be located in a different folder, typically it will be located under \build or \bb folders. By the way bb abbreviation is for 'Big Build' code name for the Team Build.

Anyway, once you start setup, you should see title: Microsoft Visual Studio 2005 Team Foundation Server (build) Setup. Just go through normal setup procedure.

MSDN has a great reference on TFSBuild Commands that can be handy for batch processing, like starting a build. I commonly use following:
TFSBuild start {http://TFSServerName:8080} {TFS Project Name} {TFS Build Name}

Obviously, one will have to create a build prior to using tfsbuild from command line.