Ok, I have this class the should capture and send audio, I have a "capture" and "send" button, let's call this class "AudioCapture".
Where should I include all the networking stuff? At first, I thought I should make another class (Let's call it "Program") that sets up the networking then make an AudioCapture object each.
But then I thought, when I click the "send" button, and send() is called from the audio object, how will I be able to include the new parameters (streams and/or sockets) that will enable my send() method to work as it should?
I guess I could set up the networking and do all the capturing/sending in one class, but would that be the correct approach?
Joined: Jan 29, 2003
It's good to have a class do only one thing, or as Robert Martin puts it, to have only one reason to change. If a class did capture and send it might change because the capture source changes or because the network stuff changes, so that's a hint to make two things.
It's also good to tell objects to do things for you rather than ask them for data. Maybe you'd have something like:
All the capture logic is in the Capturer. All the storage is in AudioClip. Maybe someStream could go to an audio player or a network connection to a peer. Does that give you any ideas?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Jul 21, 2007
Well, doesn't it make sense to have the capture and the send methods in the same class? After all, the "audio" class launches a form with buttons on it, including "send" and "capture", are you still suggesting I put my send() method in another class?
Also, when I asked my original question, I totally forgot that I can use instance variables, don't ask me why O_o