July 2019
Intermediate to advanced
410 pages
10h 32m
English
One approach to handling commands with and without parameters would have been to define another method, GetParameters, on the InventoryCommand abstract class, and for those that do not require parameters to just return true to indicate that all, in this case no, parameters have been received. For example, the QuitCommand, HelpCommand, and GetInventoryCommand would all have an implementation similar to the following:
internal override bool GetParameters(){ return true;}
This would work but it does break the interface segregation principle (ISP), which states that an interface should only contain methods and properties that are required. Similar to SRP, which applies to classes, ISP applies to interfaces ...
Read now
Unlock full access