This is a classical example of how people decide to violate the Liskov Subtitution Principle. I strongly discourage it but would encourage possibly a different solution:
- Perhaps the class you're writing doesn't provide the functionality the interface prescribes if it doesn't have use of all the members of the interface.
- Alternatively, that interface may be doing multiple things and could be separated per the Interface Segregation Principle.
If the first is the case for you, just don't implement the interface on that class. Think of it like an electrical socket where the ground hole is unnecessary so it doesn't actually attach to ground. You don't plug anything with ground in and no big deal! But as soon as you use something which needs a ground - you could be in for a spectacular fail. Better off not punching a fake-ground hole in. So if your class doesn't actually do what the interface intends, don't implement the interface.
Here are a few quick bits from wikipedia:
Liskov Substitution Principle can be simply formulated as, "Don't strengthen pre-conditions, and don't weaken post-conditions".
More formally, the Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called (strong) behavioral subtyping, that was initially introduced by Barbara Liskov in a 1987 conference keynote address entitled Data abstraction and hierarchy. It is a semantic rather than merely syntactic relation because it intends to guarantee semantic interoperability of types in a hierarchy, [...]
For semantic interoperability and substitutability between different implementations of the same contracts - you need them all to commit to the same behaviours.
Interface Segregation Principle speaks to the idea that interfaces should be separated into cohesive sets such that you don't require an interface that does many disparate things when you only want one facility. Think again of the interface of an electrical socket, it could have a thermostat also, but it would make it harder to install an electrical socket and may make it harder to use for non-heating purposes. Like an electrical socket with a thermostat, large interfaces are hard to implement and hard to use.
The interface-segregation principle (ISP) states that no client should be forced to depend on methods it does not use.[1] ISP splits interfaces which are very large into smaller and more specific ones so that clients will only have to know about the methods that are of interest to them.