Ayende @ Rahien

Unnatural acts on source code

More On Binsor: Natrual Component References

Well, I just added the last piece in what I consider the major features to Binsor, which is component references. I'm a big fan of decorators and chains of responsabilities, which mean that I tend to create a lot of references between objects.

In Binsor, it is as natural as this:

import Rhino.Commons

 

Component(defualt_repository, IRepository, NHRepository)

 

customer_repository = Component(customer_repository,

       IRepository of Customer, 

       CustomerValidationRepository of Customer)

#notice that I'm using @ here for compnent reference

customer_repository.inner = @defualt_repository

Just by defining the component, it is automagically expose it for references as @component_name. You can also define it in the Component itself as a compiled literal string, instead of a string. I can even use generic types there (which is a weakness in Boo), although not in a very nice syntax.

Update: The syntax weakness in generics in Boo was fixed (about 12 hours from the moment that I posted it), so the code above is very clean again. I know why I like OSS now!

With this done, I'm not in that blissful world where you got what you wanted and everything is fuzzy around the edges. I got three major things done in the last 12 hours, Windosr's IOC-29, Binsor (which required IOC-29, and NHibernate batching. I haven't done this amount of coding in what feels like ages.

Damn, that feels good.

The source can be found here

Comments

No comments posted yet.

Comments have been closed on this topic.