jeudi 24 décembre 2015

how to think about this... (design pattern)

I am building a multimedia organizer to track the media that i have

here is the object hierarchy:

-MediaObject (root parent)

--EpisodeSequence:

---Season

---Show

---Arc

--Episode

The above interacts differently with other MediaObject. e.g. a Season can have an Arc as it's child, but can't have a Show. e.g. a Show can have any MediaObject as it's child:

enter image description here

in addition, a specific MediaObject can be initiated in different ways. You can add the file directly (as a file path), add a virtual file (tracking things that you are watching online), or even generate the file name automatically from the "last watched" index.

enter image description here

i want to enforce these rules and i don't know how to do this.

my best guess is to use a factory to create (or reject the creation of) whatever MediaObject i want and pass the factory a MediaObjectSC (Media Object Search Criteria) that contains all the info i will ever need to create whatever MediaObject. The downside is that MadiaObjectSC will look like an abomination (with a lot of useless fields) and the factory will be too complicated (in my opinion)

from the above, i can see that i am missing a lot of insight on the matter. Any further guidance is much appriciated.

Aucun commentaire:

Enregistrer un commentaire