Lorenz Cuno Klopfenstein

Articles from January 2010

I have been tinkering around my "home brewed" dependency injection library, as I mentioned in my last post. Since most of the code revolves around instantiating objects (well, and keeping them orderly registered), I figured it couldn't hurt to check out which is the best (i.e. fastest) way to dynamically instantiate objects in .NET.

There are essentially two ways you can register objects to my IoC container: using a delegate or using the type. The delegate is a really nice method, also used by Autofac (any comparison between my library and Autofac is probably an insult to Autofac  :)). It works like this:

container.Register(c => new Implementor());

In this case the delegate simply instantiates an instance of a class that implements the IInterface interface. Pretty slick and also very fast: calling the delegate is exactly one method call slower than calling the new operator, so that shouldn't be a problem at all.

Problem is, sometimes you can't register a delegate (for instance when you're registering dynamically loaded plug-ins to the container). In that case you need to manually instantiate the objects: .NET provides a lot of different ways to do that, and some methods can be compiled to dynamic methods or to delegates which probably should improve their performance.

There's a pretty complete blog post by Haibo Luo, but it's 5 years old and might not be accurate (it also misses the methods that use System.Linq.Expressions).

More...

Posted on Monday, January 11, 2010
594 Views
3 comments posted

This is an update over an old post about running Lucene.Net on a medium trust web hosting service with NHibernate.Search.

Lucene logo

After more than one year, the full-text search library has changed a bit: most notably, Lucene.Net has exited the "incubation" stage and is now an officially featured project of the Apache foundation. That's great news. Unfortunately, the project's homepage hasn't been updated and that caused a bit of confusion on my part. The updated SVN repositories are now here:

https://svn.apache.org/repos/asf/lucene/lucene.net/

and the stable binary packages are way outdated. I suggest you build your Lucene.Net dll from source code.

The NHibernate.Search source code has changed as well and includes several improvements. For instance, the issue I was reporting in my original post has disappeared (I'm not sure if this depends on a fix in the library or in my code, but the deadlock is gone) and the Optimize() method actually performs the optimization of Lucene's index files.

More...

Posted on Wednesday, January 20, 2010
706 Views
6 comments posted

A fondue prepared with Italian cheese.

Today's post is somewhat unusual: a cooking recipe for a tasty fondue prepared with italian cheese.  :)

Ingredients for 4 people:

  • 500g Asiago
  • 300g Parmigiano
  • 100g Gorgonzola
  • 3dl white wine
  • 2 soup spoons of potato starch
  • 2 spoons of grappa or Kirsch
  • One or two cloves of garlic and shallot onions
  • Some nutmeg
  • 400g of bread

First of all, prepare the caquelon and rub the garlic on it's whole surface (if you can't stand garlic, skip this step safely). Then start preparing the cheese: Asiago is a soft, mild cheese that can be easily cut in slices and thrown into the caquelon. Parmigiano on the other hand is extremely hard and will need some grating (this can take a lot of time if you're preparing fondue for many people).

Start melting the Asiago and Parmigiano by putting the caquelon on low heat. Keep stirring energetically and sprinkle the potato starch in the mixture. Add in the shallot if you like (just for flavor) and add the white wine. As soon as the cheese is fully melted (emulsified would be the right word), mix in the Gorgonzola and the grappa.

Keep stirring in order to make sure the cheese doesn't burn to the caquelon and keep on medium heat. Ensure the heat isn't too low, or the cheese will solidify in big clumps. When the cheese has reached the right density, grind some pepper and grate some nutmeg to add flavor. In the meantime, slice the bread in small cubes.

Serve the caquelon by placing it on a heater on the center of the table. Keep stirring while eating, but do not scrape the bottom of the pan because that might loosen parts of burnt cheese.
Enjoy!

The ingredients used for the fondue.
The ingredients: Asiago, Parmigiano and Gorgonzola.
Posted on Thursday, January 21, 2010
Tagged as
184 Views
0 comments posted
Nike+iPod sensor

Being a satisfied iPod touch owner, I've used it a lot of times to go jogging and listen to some music in the meantime (and to keep track of time using the standard iPod alarm clock). A couple of months ago I bought a very cheap Nike+iPod sensor but didn't have a chance to use it... and anyway, it was way too cold to go out running!  :)
Today I finally had the time (and incredible courage) to test it.

The iPod touch can directly connect to the sensor, since the receiver is already integrated (I guess it uses bluetooth) so there's no need to get the whole set (which you need if you have an iPod nano). Just get the sensor, which is really really cheap (like 12? or something).

Nike+iPod

Speaking of cheap, I didn't buy the expensive Nike+ shoes of course but still use the same ultra-cheap running shoes as always. The Nike+ shoes provide an apposite slot where you can put the sensor while running. For "normal" shoes, there are a couple of straps on Amazon that should do the same thing, but I figured that putting the sensor behind the shoe strings would be pretty much the same.

The Nike+iPod sensor on my running shoe.
The sensor firmly in place. Ignore the ugly silvery shoes.  :)

And in fact, it worked: just stick the sensor in a point where the strings cross twice and you shouldn't risk losing the precious electronic gadget. After my first test run the sensor apparently had moved a bit, but wasn't about to fall out. Even if that happens, the Nike+iPod should warn you when it loses contact with the sensor and you'll be able to go back and hunt for the thing...  :D

More...

Posted on Monday, January 25, 2010
Tagged as
276 Views
0 comments posted
Back to Klopfenstein.net
Clemens Klopfenstein Serena Kiefer Lukas Tiberio Klopfenstein Lorenz Cuno Klopfenstein
English German