0

Say, I have 2 classes which are Audio and AudioManager. My question is, should these functions

void Play();
void Resume();
void Pause();
void Stop();
void Load();

be within Audio class or AudioManager?

Well, what I did is put them all into AudioManager class, but I'm not so sure about it.

Mohsen Heydari
  • 7,256
  • 4
  • 31
  • 46
Xeon
  • 246
  • 3
  • 15

1 Answers1

0

Think about them as if they were real word concepts. In fact they are. If you insert your CD to a CD Player will you tap the CD or the Player? Of course the Player. The functions you listed belong to the player.

I think that the name AudioManager does not describe its task. In general the use of the name Manager is discouraged since it is a broad concept. In your case Player would be better.

Audio in your case is just a data structure and should not have those functions.

Just a remark: most of the functions in your post are straightforward but Load is somehow confusing. Does It load a track or it loads the CD into the player or?

Adam Arold
  • 29,285
  • 22
  • 112
  • 207
  • Yes! That's exactly what I thought! (except for the example, I think I will use your way whenever I encounter similar problems). Well, as for Load(), it loads a "Track" to the "CD" – Xeon Sep 29 '13 at 16:43
  • and thanks for the audio manager to player suggestion. Will change it. – Xeon Sep 30 '13 at 03:08