Thursday, 16 December 2010

Commands and Selections

I'm turning my commands outside in.

I say it this way as they were the wrong way around.
I was passing Selections into Commands, when it should really be the other way around.

The selection should apply the command to itself. In this way it can traverse its internal collection in its own way. E.g. if the selection has a cursor on a database instead of an in memory collection.

Why am I calling them Selection instead of Collections? Well it's because I don't want to expose a whole Collection interface. Think of a Selection as the model for a multi select list box. It has a collection of items, and a collection of which of which items are selected.

I think Commands should only operate on the selected items in the Selection. I'm breaking that rule at the moment!

No comments:

Post a Comment