lundi 14 septembre 2015

Common View Functions in OOP - Design Patterns PHP

I am currently programming a Playlist system and I want to list the songs. So far, I have created a Song class and a Playlist class with a "getSongs()" method which returns an array of the song IDs. I thought about writing a separate function (not inside the class) which lists the songs and mostly contains the view code. e.g listSongs($ids). I created a function for a dropdown menu for adding songs in playlists the same way.

I consider it to be not the best solution and I wanted to ask how professionals handle it, especially in the object-oriented world.

I would like to add this dropdown menu in every movie-listing for each song. Should I add a method in the Playlist class for this purpose? But then I have elements of the View in my class..

Or is there a special Design pattern for this case? It would be really helpful if someone could give me a little example.

Regards, Bob

Aucun commentaire:

Enregistrer un commentaire