Two things in combination help me fairly well in that regard.
1. Keep It Super Simple (KISS).
Implement the solution which works the easiest first. Copy-pasting code is ok at this point. So if an "if" will do it, use an "if". (Don't start with a BaseClass with an empty default method and a specialized class which overrides it).
Once you have something working (hopefully with some automated tests?) you are allowed to refactor and abstract. But see next point.
2. The Power of Three!
You are only allowed to abstract code once you have copy-pasted it in at least three places. If you only have two, you must resist the urge and move on. Maybe add a comment saying "this is very similar to this other part, consider abstracting if a new case appears".
After abstracting stuff, run tests again (even if they are manual) to make sure you have not broken anything.
Be warned that this method is not guaranteed to produce the "best possible code for future you". If you keep doing this long enough, you might get stuck at "local maxima" in design. Future you might need to do big refactors. Or not. That is the nature of programming IMHO.
1. Keep It Super Simple (KISS).
Implement the solution which works the easiest first. Copy-pasting code is ok at this point. So if an "if" will do it, use an "if". (Don't start with a BaseClass with an empty default method and a specialized class which overrides it).
Once you have something working (hopefully with some automated tests?) you are allowed to refactor and abstract. But see next point.
2. The Power of Three!
You are only allowed to abstract code once you have copy-pasted it in at least three places. If you only have two, you must resist the urge and move on. Maybe add a comment saying "this is very similar to this other part, consider abstracting if a new case appears".
After abstracting stuff, run tests again (even if they are manual) to make sure you have not broken anything.
Be warned that this method is not guaranteed to produce the "best possible code for future you". If you keep doing this long enough, you might get stuck at "local maxima" in design. Future you might need to do big refactors. Or not. That is the nature of programming IMHO.