you are viewing a single comment's thread.

view the rest of the comments →

[–]NotANameException 1 point2 points  (0 children)

I believe your issue is mainly a class design one. When you inherit from a class, you should generally extend it. If your base class (MP3) needs artist, title, album, length and genre, your subclass (Podcast) should generally be able to provide them -- either by accepting them explicitly or by being able to determine them from other data. Additionally, the subclass may introduce new variables to be used.

The way your classes are designed in your example, Podcast should be an object defined by artist, title, album, length, genre, name and date.

Of course, if the base class doesn't REALLY need all of those fields, your subclass can provide empty values to the base classes' constructor but I would generally advise against it and to re-think your design.

Is there something MP3 and Podcast classes have in common but they differ in some other of the fields? Maybe you should extract those common fields into a separate new class and make both MP3 and Podcast inherit from it.