Object Oriented Programming – how to avoid duplication in processes that differ slightly depending on a variable

Something that comes up quite a lot in my current work is that there is a generalised process that needs to happen, but then the odd part of that process needs to happen slightly differently depending on the value of a certain variable, and I’m not quite sure what’s the most elegant way to handle this.

See a few different approaches -> stackoverflow