Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am designing a WinForms application in C# and wanted to get a design check by you guys. I am fairly new to programming and have been reading some material, so please excuse my mis-usage of words or 'computer science' terminology if need be.

The Design

I have a MDI application with MAIN as my parent form and various other CHILD forms. Now whenever an exception occurs, whether in MAIN or a CHILD form, it needs to be logged into a LOG window, which itself is a child form of MAIN.

Reading material over the web, a lot is said to have loosely coupled classes. Now my thinking is that I will have a non-form class, called Log Collector Class which will basically be the "middle man" between all non-log window forms and the window form. Any exception, or update in general to the log window, will need to go through this middle man class. In turn, there will be a custom event in which if this Log Collector Class is updated, the listener, aka the Log Window, will update whatever control it needs to update to display the exception.

An image for visual people:

enter image description here

Any comments on this would be great, especially if I am doing things correctly (or in-correctly).

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

That's a pretty good approach. You can have as many objects as you like raising exceptions, informing your middle-man, and as many listeners as you like waiting for an event to be raised. And no object needs to know about the full structure of any other object, they just need a thin interface by which to communicate. This is good decoupling.

But it's not an example of MVC. It is an example of the mediator pattern.

share|improve this answer
    
Thank you for the reply, design-check and what type of pattern this design is. Just got done reading the link and it was quite informative. –  brazc0re May 24 '12 at 16:00
    
I'm not sure if this is StackExchange etiquette, but I had another question on this design as I was coding. Should the Log Collector Class be a singleton design pattern? Should it have an interface? I am asking because all forms need to implement this Log Collector Class –  brazc0re May 24 '12 at 17:15
    
@brazc0re: If you have a different question, ask it as a different question. I am one of very few who will see comments here now, because you've accepted an answer. –  pdr May 24 '12 at 17:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.