I need to refactor a class that became too messy. The class has a method that reads some raw data from one of our repositories, and another that "filters" it:
The data is in the form of
on/off, for each X*Y of the units we have.
The filtering process lets some of the data pass in the raw form, changes a small amount from on to off, or reduces the level, and some is just blocked in this stage.
And this stage there a already quite a lot of rules, but none of them is general enough to apply to all units, so we have a lot of
if/else statements that are hard to follow and can cause bugs.
I'd be happy to redesign it in a more readable and easier-to-maintain form.
I can't provide a code snippet, but a pseudo code will look like this:
for x in X:
for y in Y:
if data[x] == ...
if data[x][y] == ...
copy as is
manipulate data and copy
disable this data
else if data[x] == ...
Is there a known design pattern for this scenario? I was looking at the filter pattern but I don't know if my criteria are unified enough