Sep 26, 2011 at 6:51 AM
Edited Sep 26, 2011 at 7:14 AM
I'm just getting started with Simple MVVM Toolkit. Looks very promising so far.
I'm curious about one thing, though: why restrict the message bus token to a string? It seems like an enum would be a better fit.
public enum MessageToken
Class of string constants:
public class MessageToken
public const string Next = "Next";
public const string Previous = "Previous";
public const string Up = "Up";
public const string Down = "Down";
Besides having to type "public const string" for each token, every string field needs to be "double-named" (i.e., you need to enter a name for both the field's name and value). This makes refactoring more work and more error prone, since you can't just do
a simple refactor/rename operation, you have to also change the string's value. (Admittedly, the consequences of forgetting to rename a string are not likely to be catastrophic, but it could cause confusion during debugging if your message token is not what
you expect.) With an enum, you just have to type the name of each token, and refactoring is a breeze.
There may be occasions where an enum won't work, so I wouldn't remove the possibility of using a string altogether, but it would be nice if enum where a possibility. Also, uniqueness of each value is guaranteed, so you won't end up sending a message that
gets picked up by an unintended receiver.
If you were to implement this feature, you could make a generic version of the MessageBus class that allows specification of a particular enum for tokens.
Meanwhile, I'm thinking of doing something like this as a workaround:
public void Save()