For the sake of the example, let's say I have a basic LED class that can blink different patterns on an LED. The LED would have a few attributes describing it's state at any given point in time such as blink pattern, color, current state. Let's also say there are few other attributes that are used by the class for things like timers, pattern counters/iterators, etc.
I want the consumer of the LED class to be able to ask it for it's state info which would include the first list of attributes but not the second.
My question is could someone explain the best practices for storing and returning this kind of state information?
Some thoughts:
- I would think we want all these attributes to be private since we want others to interact with the LED class through a known API
- I would want to be able to return all the common state variables in a single "get_state()" call rather than having to access each individually
- Is there any benefit to having a logical grouping to these attributes in the class or do I just declare each individual one in the constructor?
I'm coming from a C background and trying to stop thinking in structs and do things the Python way.