❔ How would you refactor something like this? Is there a pattern that could help me?
Is there a way to clean something like this up? I've got a lot of evaluations to perform based on a bunch of different bool settings
7 Replies
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
This is interesting, I'll give it a shot. I had the idea of making it a class of its own but I wasn't sure if the RulesEngine approach would work
the answer is obviously
CallerArgumentExpression
lmaoReason being that some of these "rules" short circuit the evaluation and I don't want to evaluate the rest
(joke)
Something like this maybe? (Obviously not gonna copy paste)
https://yiniski.medium.com/rule-engine-pattern-8a3f0e0c2d81
The business idea is that: I'm trying to build something (I guess a rule engine) that determines whether something should be done. Got a whole bunch of configurations
So something e.g. MasterSwitchThatShutsDownTheEntireOperation will stop and short circuit the rest but e.g. ConditionOneThatNeedsToBeSuccessfulAlongWithOtherConditions will need to continue evaluating other conditions
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.