Skip to main content
added 293 characters in body
Source Link
Oded
  • 53.7k
  • 19
  • 168
  • 181

One way to do this is have one interface with the three methods, and implement it in a few abstract classes (these would be the base classes for the full implementations).

These abstract classes would only implement methods that are not needed and would implement them as no-ops (empty methods that do nothing, or return a null, for example).

Your actual implementation classes would inherit from these abstract classes and only implement the needed subset of operations.


Another option is to adhere to ISP (Interface Segregation Principle) and have a number of interfaces - one for each behaviour needed.

Update:

This second option would suit the requirement to not have certain methods show up in IntelliSense. It does, however, mean that you would not be able to use a single inheritance tree, but segregate it (which, from your description of the model, is probably the correct solution).

One way to do this is have one interface with the three methods, and implement it in a few abstract classes (these would be the base classes for the full implementations).

These abstract classes would only implement methods that are not needed and would implement them as no-ops (empty methods that do nothing, or return a null, for example).

Your actual implementation classes would inherit from these abstract classes and only implement the needed subset of operations.


Another option is to adhere to ISP (Interface Segregation Principle) and have a number of interfaces - one for each behaviour needed.

One way to do this is have one interface with the three methods, and implement it in a few abstract classes (these would be the base classes for the full implementations).

These abstract classes would only implement methods that are not needed and would implement them as no-ops (empty methods that do nothing, or return a null, for example).

Your actual implementation classes would inherit from these abstract classes and only implement the needed subset of operations.


Another option is to adhere to ISP (Interface Segregation Principle) and have a number of interfaces - one for each behaviour needed.

Update:

This second option would suit the requirement to not have certain methods show up in IntelliSense. It does, however, mean that you would not be able to use a single inheritance tree, but segregate it (which, from your description of the model, is probably the correct solution).

Source Link
Oded
  • 53.7k
  • 19
  • 168
  • 181

One way to do this is have one interface with the three methods, and implement it in a few abstract classes (these would be the base classes for the full implementations).

These abstract classes would only implement methods that are not needed and would implement them as no-ops (empty methods that do nothing, or return a null, for example).

Your actual implementation classes would inherit from these abstract classes and only implement the needed subset of operations.


Another option is to adhere to ISP (Interface Segregation Principle) and have a number of interfaces - one for each behaviour needed.