this is code from
refactoring
I just have one question. Does this violate OCP?
If yes, why he just write it like this?
else WHY it will be no I don’t understand
class Application is
field dialog: Dialog
// The application picks a creator's type depending on the
// current configuration or environment settings.
method initialize() is
config = readApplicationConfigFile()
if (config.OS == "Windows") then
dialog = new WindowsDialog()
else if (config.OS == "Web") then
dialog = new WebDialog()
else
throw new Exception("Error! Unknown operating system.")`
New contributor
Ahmed Abdelaziz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.