-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOCP2.php
More file actions
45 lines (42 loc) · 1.39 KB
/
Copy pathOCP2.php
File metadata and controls
45 lines (42 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
class Movie
{
public function renderMovieInformations(){
//...
}
}
class TvShow
{
public function renderShowInformations(){
//...
}
}
class Song
{
public function renderSongInformations(){
//...
}
}
function renderInformations($medias){
// starts to be messy to see and to handle
// whatevere you do in the three render methods shold be compatible with the rest
// every different media we add we shold add a condition to the if or switch
// making this function not closed to changes
// moreover in a real world applicatio this kind of mechanism could be spread all over the application,
// making it necessary to check wherever we try to render some media information and then add the
// new media to that case
// Rigid: because it leads to many changes every time we a dd things
// Fragile: it's easy to break since we keep adding new things ll linked
// Immobile: we can't tae this funciotn anywhere else without taking TvShow, Movie and song classes with us
foreach($medias as $media){
if(get_class($media) == 'TvShow' ){
$media->renderShowInformations();
}elseif(get_class($media) == 'Movie'){
$media->renderMovieInformations();
}elseif(get_class($media) == 'Somg'){
$media->renderSongInformations();
}else{
// ...
}
}
}