You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
so that there is only ever one instance of any pin as they are remembered by the factory
That makes sense to me since only one instance of the physical pin exists anyway. I'm not yet convinced it's totally necessary (will have to think on this) but it certainly seems useful.
Might make it more difficult to switch a pin from an input to an output pin. Primary key would have to be number + direction rather than just number.
I honestly don't think this will be very common. If you really need a pin to read and write data at different times you should probably be using a protocol like I2C, SPI or 1 Wire which can coordinate that switching with the other component(s) you're wired up to. And I think Raspberry Pi handles those with kernel modules separate from GPIO (unconfirmed).
Because I personally wouldn't be switching pin modes in my projects, I don't have a strong preference on how it handles people creating input and output pin objects for a single physical pin - it can either allow it or throw a big exception for all I care :)
Memory and performance differences could be insignificant
I wouldn't be too worried about the memory footprint of the objects themselves, but could having so many streams cause performance issues? If so then I think a flyweight could definitely help there.
Should the flyweight pattern be used (so that there is only ever one instance of any pin as they are remembered by the factory)?
For
Against
Again - interested to hear thoughts?
The text was updated successfully, but these errors were encountered: