My Thoughts on ORM comparisons

22. August 2009

I am a bit late to the party but there we go.

Last several days, there have been a hot debate on the performance and capability of NH vs some other commercial/noncommercial ORMs. This issue has been discussed both in NHibernate Developer List and in Ayende’s blog. I have recently noticed another benchmark between NH and EF, which I hope to address, too.

Fallacies of benchmark

What I have seen in those benchmarks is the wrong use of ORMs. This statement has two aspects: Wrong use of ORM and wrong use of NH itself.

In ORM, you don’t use it to do bulk operations. And 0.001 second difference will not differ anything in your application. If it does, you don’t also use RDBMS, you use something else.

There is no point on making a loop of thousands of iterations which saves an entity. Davy has well pointed out that this has a lot of implications in NHibernate, unlike some other ORMs. First of all, NHibernate first-level cache will be in action and it will fill the cache with each item saved. Secondly, as NH makes use of POCO it has no mechanism of things like INotifyPropertyChanged, it has to compare the old to the new value. As you may guess, the more entity you have, the longer it will take. No exception. If you want to leave first-level cache out of the game, you use StatelessSession feature of NHibernate, no exception. Actually when you check Fabio Maulo’s post you’ll see it can even become faster without Stateless Session.

Another point I have noticed in both benchmarks is that they are/were not fair. If I compare it to EF, lets say, ctx.SaveChanges() will batch the chages and send the query to the database in one go. NH has this feature, as Ayende already pointed out, since 2006. However, NH by default doesn’t make use of it, and this is not a bug, it is a feature. You have to use setting to enable it.

Benchmark the community, too

NHibernate has a big community, and great minds as committers. It really does matter. Let me give you some statistics about NHibernate development and its community

Here is the commit statistics.

image 

It is one of the most active projects in .net environment. The image above doesn’t include the contrib projects. A great kiss goes  to Fabio Maulo for his massive efforts.

Let’s look at discussion group, shall we?

image

Do you know any other group with that activity? I don’t know.

 

In addition, NHibernate gives you more than _ANY_ ORM can give. It gives you a lot of extensibility points which can be used in a lot of scenario. Validator, Search, Spatial, Shards to name a few.

In conclusion

NHibernate is the obvious winner.

Even Developers Make Art

12. August 2009

poster1ciktigh6

Found this today last month. If you click on the picture, you’ll see that there are parts that are composed of other images.

I prepared a folder with full of small pictures, and a preprocessor scanned all files in that folder, took their R G and B averages and saved it to a database.

I then divided the big picture into small chunks (the small, the better, but also requires more photos in order not to have repetitions). I took R G B averages of each part and computed the distance from each of the items stored in DB(for efficient access, they are fetched to memory). The distance formula is simply the Pythagoras theorem.

clip_image002[6]

The closer it is, the better it fits to the place. However, there is one problem. Neighbor parts tend to have a correlation (they share similar colors), and if we use the same picture for neighboring cells, it doesn’t look good(above probably left from an early version). What I did was to take closest 10 and select randomly.

The rest is a bit of Image processing(not processing but replacing, lets say)

I had fun doing it :) Art is everywhere even if I don’t think I like it :)

YAGNI in Real Life

7. August 2009

One of my friends wanted to have a cheap SVN hosting (actually wanted to install svn to his hosting, but this part is irrelevant to what I am going to say). I offered him some alternatives including Assembla.

Then the topic came to OpenSource SVN hosting, and he believed SourceForge is superior to Google Code. While I can understand his claims, I have objections to it. As I am contributing to various opensource projects, and being an active user of opensource, I have a bunch of projects in my “OpenSourceProjects” folder. Most of them use SVN, rarely CVS. Most SVN projects was hosted under either Google Code or Sourceforge, some Codeplex.

To begin with, having used’em all, I have pretty much experience with both, at least as a user.

One argument that my friend used that SF has many features. Looking at google code interface, I have to admit that this is true. However, those blown features are not at my center of interest. When I develop the project, I want speed. SF doesn’t give me that much smooth experience, I remember having to update a project 5+ times just to download, and less frequently trying to commit 2+ times. Google, on the other hand, didn’t cause any problem regarding to its SVN usage.

Another problem that we faced recently is that the download counts of NHibernate.Linq project was shown as 0 a week after we released it. I am pretty sure (:) ) that it had thousands of downloads since then, but it is not seen on SF.

To sum up what I have said, I prefer quality of service over the features provided most of the time. Having features that I perhaps will never ever use is “relevant” to this story, it is YAGNI.

DELL increases the Fan speed to hide problems - Yet Another Dell Fail?!

7. August 2009

I got my laptop repaired, thankfully, with the help of the Customer Care (Thank you Mustafa!)

It seems like my laptop suffered from the same problem many others faced. I had my warranty information disappearing from time to time. Because of this reason, I had chance (?) to make phone calls to the USA DELL, and learnt at that time that the issue occurred due to non-updated BIOS. I thought it was something different but now I see that that new BIOS version just increases the fan speed in order to postpone the problem, perhaps till the warranty expires. I am not an expert on Ethics but I believe that this issue is non ethical as they try to hide the real problem instead of fixing it. Another drawback of increased fan is the increased power consumption and therefore less battery life.

As a result of many many complaints, DELL decides to add 1 year extension to limited warranty. Mine still shows 2010 but I hope i’ll figure it out.

Dell lost my respect, even if this is NVIDIA’s fault, Dell’s attitude toward customers is not acceptable.

I hope that I won’t have to buy DELL in some near future.

, ,

Making Transient as Default Lifestyle in Castle Windsor

6. August 2009

This is actually an answer to fellow blogger Jak Charlton, but I see a benefit in sharing it.

Casey pointed out that the default lifestyle should be transient. Even though I understand his reasonings, I am used to this way.

There is a solution for those who wants Transient as the default.

You know what? Yes, the events ! Here is how.

container.Kernel.ComponentModelCreated += new ComponentModelDelegate(Kernel_ComponentModelCreated);


void Kernel_ComponentModelCreated(Castle.Core.ComponentModel model)
{
	if (model.LifestyleType == LifestyleType.Undefined)
		model.LifestyleType = LifestyleType.Transient;
}

, ,