The Inquisitive Coder – Davy Brion's Blog

Trying to walk that thin line between intelligence and ignorance

Can You Come Up With A WHY Comment For This Code?

Posted by Davy Brion on February 18th, 2010

I just had to write the following code:

    public class MyReleasePolicy : Castle.MicroKernel.Releasers.LifecycledComponentsReleasePolicy

    {

        public override void Track(object instance, Castle.MicroKernel.Burden burden)

        {

            if (!instance.GetType().FullName.StartsWith("NServiceBus"))

            {

                base.Track(instance, burden);

            }

        }

    }

 

and then this:

            IoC.Container.Kernel.ReleasePolicy = new MyReleasePolicy();

 

to make a problem go away.

Can you come up with a WHY comment? (the category of this post is another hint)

5 Responses to “Can You Come Up With A WHY Comment For This Code?”

  1. Szymon Pobiega Says:

    Yeah I can, but I think this would be cheating;-)

  2. Davy Brion Says:

    did you run into the same issue or are you talking about this hack when you say ‘cheating’? (which i’d certainly agree with :p)

  3. Krzysztof Koźmic Says:

    That’s interesting.
    I don’t know NServiceBus, but I would guess it somehow either takes care of managing its own dependencies, or for some reason is incompatible with Windsor’s life-cycle management.

    Do you plan a follow up post detailing the issue you’re working around here?

  4. Davy Brion Says:

    @Krzysztof

    “Do you plan a follow up post detailing the issue you’re working around here?”

    by now you should know me well enough to know the answer to that question :)

  5. Szymon Pobiega Says:

    I mean I know NSB’s ObjectBuilder from the inside and I am aware of this leak in it’s abstraction system — its dependency resolver abstraction has no notion of releasing components. Btw, it is Krzysztof who first turned my attention to this issue, in context of MetaContainer:)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>