I have a
WifiComponent in my
Camera in my client application. It's responsible for handling the Wifi-related functionality of the Camera. The Camera represents a real world camera.
WifiComponent can either be enabled (in which case I can do things with it, like checking connection status and scanning) or disabled (in which case you can't do anything with it at all, other than asking whether it's enabled).
When creating a
Camera in my client application, I ask the camera whether its
WifiComponent is enabled. Then I construct the appropriate subclass of
wifiScan() methods are easy. The
NullWifiComponent doesn't support any types, is instantly done with scanning and finds no results.
But now I have to implement a
bool connect(WifiNetwork network, String password) method.
I want to say that I failed to connect... But I don't even support the
WifiEncryptionType provided in the
WifiNetwork! The real implementation throws an
IllegalArgumentException if you pass it an unsupported
WifiEncryptionType wifi network.
IllegalArgumentException, because I don't support the
- Silently fail to connect (
return false), no matter what's provided?
If the real implementation fulfills a contract, and part of this contract is to throw exceptions for certain inputs, should a null-implementation prioritize its neutrality or the contract?