Bad practice: exposing an event in an interface?

Is it a bad practice to propagate events in .net interfaces?

I have found very few .net interfaces that display events.

thanks

+5
source share
7 answers

Well, in particular, there is one interface, which is probably one of the most important interfaces in .NET, and it provides one event ... INotifyPropertyChanged. :)

I have never seen any recommendations against FxCop or Framework Recommendations, and I do not understand why this would be. The only thing you need if you explicitly implement the interface becomes a pain in the butt to implement the event, since you need to use explicit add / remove accessors.

+7
source

, , .

, , , ( ), , .

.

. COM WCF, , , , .

+3

. , , , .

, . , , .

+2

. "" .

, IBindingList ListChanged.

. , .

+2

, , .

, Java. .NET, , , , .

, , , , , -, .

.

0

, , !

0

I do not think this is bad! I defined an interface so that I could separate the main application from the component that I need to update frequently and thus dynamically instantiate and invoke at runtime. To tell the status of what the component is doing, I have defined several events in the interface contract so that the main application knows what to subscribe and the component publishes exactly what the main application needs.

0
source

All Articles