Open michaelleejl opened 2 years ago
Actually, we do need classes. We need to store information like the IP address of the device, the device name, and other identifying information.
What's interesting is I think we also need a mechanism to distinguish state associated with the virtual device with state associated with the physical device.
For example, let's say we define a ColouredLight class. We need to find a way to distinguish colour - which is state associated with the physical light, and does not need to be initialised - and name - which is state associated with the virtual device and needs to be initialised on instantiation.
Something that's been on my mind recently is whether or not we need classes, or whether only interfaces will suffice.
The pros for having an interface only system
The cons
So I guess I'm thinking - how bad are the cons? When might a user need a class and not an interface? When you want to define a state common to all types of devices.
Recall that our devices are in effect virtual devices, so any state we talk about is associated with the virtual and not the physical device. "The colour of the light" shouldn't be thought of as a situation where we need state, because the colour of the light is associated with the physical light, and is therefore retrieved through a/several interface(s). The user doesn't need to create state to do this, at least, not state associated with the virtual device. Further, I don't see a scenario where the user will be asked to define custom classes with custom state. 99.99% of the state will be bounded by and correspond to some physical property of the actual device, and therefore should be represented by the API. Perhaps the only scenario I see where the user might want to keep track of state not associated with the physical device they are managing is that of ownership.
With this in mind - do we really need classes? Do we need a mechanism by which users can define custom state associated with a virtual device?