Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

16
  • 3
    This is really a very interesting question. I have a feeling the correct answer might involve Attributes or an IL hack. Generally, I'd assume that attempting it is a wrong choice, because each implementer should be able to throw their own types of exceptions, but it's still conceivably useful. Maybe you'd just use an abstract class with a template method? Commented May 1, 2014 at 21:12
  • 15
    Technology doesn't solve people problems. If people violate the interface, hit them with a stick until they stop. Commented May 1, 2014 at 21:16
  • 1
    @Telastyn Maybe I should build a program that beats people with sticks instead. Commented May 1, 2014 at 21:17
  • 2
    @Doval: So how does the Interface know whether a valid user exists or not without an implementation backing it? Commented May 1, 2014 at 21:20
  • 1
    @matthew - then your program would have to infer "until they stop" properly, which leads back to the whole halting problem thing (if your stick wielding program could tell that people were violating its interface or not, you wouldn't need it). Commented May 1, 2014 at 21:22