My code can go on 8 branches. Those. For example, the same method should take 2 parameters of type Encoding, only the first overload works with System.Text.Encoding.ASCII and System.Text.Encoding.Unicode, and the second with System.Text.Encoding.UTF8 and System.Text. Encoding.Unicode. How to implement such a construction without a cloud if-s or switch-case?
1 answer
The same Fowler advises to get rid of switch and if using polymorphism (here's an example https://refactoring.guru/ru/replace-conditional-with-polymorphism ). Maybe this is your option.
|
MethodAsciiUnicodeandMethodUtf8Unicode. - Alexander Petrov