Let's assume that we have a set of valid results, ex.
"Apple, Banana, Kiwi, Pear, ...".
(In reality, it’s not fruits but complex objects)
Now we need to pick the best result according to some simple prioritization. For example, let's say this prioritization is simply an arbitrary order of preference determined on how well I like the
Apple: 1 Banana: 3 Kiwi: 2 Pear: 4
It is easy to design and implement a simple prioritization list to achieve this.
However I know that in a foreseeable future, we’ll need to use a much more complicated prioritization, which may rely on factors such as:
- What other fruits are in the result set?
- What other fruits aren't in the results?
- Does a fruit have a dirty specks or not?
- Was some fruit already picked in the past days?
- Any other prioritization criteria
What approaches and design can be used for achieving such a flexible multi-criteria prioritization in a maintainable way, ie without relying on a big messy code with tons of edge cases?