Created
July 29, 2018 15:37
-
-
Save raulmoyareyes/b5912a99f1cc8e521e458fcd479e7a14 to your computer and use it in GitHub Desktop.
[ Wrong ] - Open / Closed Principle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pdf { | |
constructor(name, size) { | |
this.name = name; | |
this.size = size; | |
} | |
// ... | |
} | |
class Png { | |
constructor(name) { | |
this.name = name; | |
} | |
// ... | |
} | |
class Printer { | |
function printFile(file) { | |
if (file instanceof Pdf) { | |
// Print Pdf... | |
} else if (file instanceof Png) { | |
// Print Png... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment