Craig,

I did alter the interface but now that you mention the extension method idea...

After thinking it through again, I think however that this is pushing things too far for too little benefit and I think I'll stop at improving the xml docs.

Yet another option would be to provide extension method for
container.RegisterComponent(x => x.For<IFoo>().AndSoOn())
container.RegisterComponents(x => x.FromThisAssembly().AndSoOn())

It is a bit more discoverable and less hack-ish but has it's own drawbacks too, like what I call "lambda tax" (x =>x)


On 19/04/2011 10:27 PM, Craig Neuwirt wrote:
Krzysztof,

   I think that's a great idea and very clever too :-)  Did you actually alter 
the interface or implement this using extension methods?

On Apr 19, 2011, at 5:30 AM, Krzysztof Koźmic wrote:

One of the most common complaints I'm hearing from people who want to start 
with Windsor is that our registration API is hard. That they go type 
container.Register and they get this:
<moz-screenshot-30.png>
if they have ReSharper, or this if they use bare VS:

<moz-screenshot-31.png>

And then they get lost hunting for what this IRegistration creature is and how do I get 
one. And they hunt for implementation and see classes like BasedOnDescriptor etc which 
confuse them even more. They don't know where to start, and even though the comment says 
"Use Component.For or AllTypes.FromAssembly" they don't see it because it 
doesn't jump out at them from intellisense.

So I did a small experiment, and did some changes so that the intellisense 
experience is the following:
<moz-screenshot-32.png>
And then when we get to pick actual overload:
<moz-screenshot-33.png>

With ReSharper it's obviously much nicer:

<moz-screenshot-34.png>

The way this works is I created the two additional overloads that have the 
entry types in their signatures (AllTypes and Component respectively) to give 
the user a hint about where they might look to start. I would update the 
tooltip help to be more helpful.

The drawback of this is that if user tries to instantiate AllTypes or Component 
or look for types that inherit from then they'll be disappointed. The types are 
abstract with private constructor to ensure no one inherits from them (which 
would be pointless anyway). This also means that the two additional overloads 
will never get invoked.

So my question to you is - what do you think about all of this? Does it help? 
Is it worth the effort (having two more overloads for mere benefit of some 
intellisense hints)? Do you have any better ideas?

Krzysztof



--
You received this message because you are subscribed to the Google Groups "Castle 
Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Castle 
Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to