.net - How should messages (not exceptions) be passed from the Model/Business Object layer to the UI? -
using vb.net 4.0
i have winforms application loosely based on mvvm. i'm looking easy way layer (even ui has no reference to) pass messages ui display user.
i have accomplished in past creating "communicator" class in "common" assembly every other assembly reference.
public class communicator public shared sub notifyuser(message string) raiseevent sendmessage(message) end sub public shared event sendmessage(messagetosend string) end class the ui subscribe sendmessage event @ program startup. class wanting pass message user call shared notifyuser method , communicator class relay given message ui through sendmessage event.
the upside method is trivial implement , super easy use anywhere in code.
i suppose downside calls notifyuser spread throughout code, making many classes dependent on communicator class , shared method. reason, feels wrong.
so, question is, typical ways achieve same effect without significant increase in complexity?
honestly events fine (with downsides pointed out). option mediator pattern, more or less sounds you've implemented, without events.
Comments
Post a Comment