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:

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

1 Answer
1

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.

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.
– brazc0reMay 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
– brazc0reMay 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.
– pdrMay 24 '12 at 17:30