I have a class A
that has total 10 streams and user can request any stream to start, I am trying to figure out what is best way to design this. Each stream requires a call back.
I am taking example for 3 :
pattern 1: (Take all callback in constructor)
class A:
def __init__(self, default_callback, S1=None, S2=None, S3=None):
....
def start_stream1(self):
....
def start_stream2(self):
....
def start_stream3(self):
...
def start_stream(S1=True, S2=False, S3=False): # general function to start multiple stream
...
pattern2:
class A:
def __init__(self, default_callback):
....
def start_stream1(self, stream_specific_callback=None):
....
def start_stream2(self, stream_specific_callback=None):
....
def start_stream3(self, stream_specific_callback=None):
...
These are the two I can think of Is there any better way to do it.
Aucun commentaire:
Enregistrer un commentaire