How should interface implementations handle unexpected internal exceptions of types callers might expect?

An Interface's job is to define the members (and their signatures) that a class must have, not how they should be implemented. Therefore I would say let the exception bubble up the stack. If you really want to define the contract and control some of the implementation (such as error handling) then you should make a base class (I would lean towards a MustInherit/Abstract class in this situation) with MustOverride Methods that the base class calls from its methods (in your situation in a Try Catch so you can do your special error handling).

An interface doesn't define how the members should be implemented, but in practical terms, interfaces are supposed to be associated with behaviors described in their documentation. If something implements IList, it's supposed to behave like an addressable collection. Calling Add(5) should put another item in the collection with value 5; it shouldn't e.g. Increase the value of all items in the collection by 5.

It would seem that the exceptions that may be thrown by an interface method should be considered part of its behavior. – supercat Jul 26 at 21:09 1 I think what @NoAlias is trying to say is: An interface is a way to define the required structure of an object, while a base class is how you would code those requirements.So you name the function in the interface, and then code it's most basic or required processes within the base class. Yes, you can have an "error" struct within the interface, but the actual error handling and population of the struct should be coded in the base class.

– Jim Jul 26 at 21:50 MSDN, (remarks section): An interface defines a set of members, such as properties and procedures, that classes and structures can implement. The interface defines only the signatures of the members and not their internal workings. Msdn.microsoft.

Com/en-us/library/h9xt0sdd. Aspx – Jim Jul 26 at 21:50 "interfaces are supposed to be associated with behaviors described in their documentation" - YES, but think of all the crappy implementations of Google or Twitter's Public Interfaces that exist out there. Thankfully, they don't over complicate their interfaces to compensate for edge case errors or bad programming though.

I think you're trying to extend the inteded functionality of an Interface too much and will only complicate things. Make a base class or leave it up to the consumers of the interface to deal with is what I recommend. – NoAlias Jul 260 at 13:08.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions