Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

If you are looking in a design perspective, where you must write a

program in C# that needs to do something else when an event appear (callback). How would you then prefer to make the archittecture ? With Delegates or virtual functions ?

  • 2 weeks later...
  • *Gurus*
Posted
A common and recommended design pattern in .NET is to have events raised by On[eventname] functions in the class. These routines should be virtual, so one can hook events externally or actually derive from the class and override. One can also then not call the base method and avoid the overhead of the delegates being called.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Thanks !

 

Do you know any good book about observer pattern, that you could recommand. I does not matter whether it is written in C++ or C#.

  • 2 weeks later...
Posted
I have now been reading this book. All along I have been looking into many things and have decided that a baseclass and a container class with some event was the best solution. Until I read this book. Here they recommand to use Observer pattern with delegates and event instead of a base class and an observer interface if you only have single inheritance. Furthermore they write there is no need for Subject, Subjecthelper and observer because the common language runtime makes them obsolete. This means that the subject that is a baseclass goes out !!!!! I do not get it!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...