Firstly, I have read, and searched ways to refactor conditional logic - seems that 3 main approaches are suggested : Polymorphism (haven't tried, but don't think I can apply it this situation), Enums (have used) and The Strategy Pattern (I have used several times and like it).
However I have about 6-7 boolean conditions to check, and depending whether each one is true/false I want to do something different i.e.
true, false, false, true
false, false, true, false
true, true, ... you get the picture..
The boolean values are set by different preferences, that are all related in someway, but I need to handle differently depending on which ones are true or false.
I know I can use The Strategy Pattern here, but not without a lot of conditional checks first (which I'm trying to avoid).
Any suggestions how this sort of conditional logic, based on multiple conditions (6/7+), can be refactored so it wont look like a behemoth of ugly code.
Aucun commentaire:
Enregistrer un commentaire