July 2019
Intermediate to advanced
410 pages
10h 32m
English
The open/closed principle, the O in SOLID, is represented by the different InventoryCommand classes. Instead of having an implementation of the InventoryCommand class per command, the team could have defined a single class containing multiple if statements. Each if statement would determine what functionality to execute. For example, the following illustrates how the team could have broken this principle:
internal bool InternalCommand(string command){ switch (command) { case "?": case "help": return RunHelpCommand(); case "a": case "addinventory": return RunAddInventoryCommand(); case "q": case "quit": return RunQuitCommand(); case "u": case "updatequantity": return RunUpdateInventoryCommand(); case "g": case ...Read now
Unlock full access