What design pattern do you use to support graceful fallback on old platforms?

Posted by JoJo on Programmers See other posts from Programmers or by JoJo
Published on 2012-05-31T21:00:04Z Indexed on 2012/05/31 22:50 UTC
Read the original article Hit count: 256

Let's say I need to add a drop shadow behind a box. Some old platforms do not support drop shadows, so I have to fake it by putting an image behind the box. Here's the pseudo code of how I'm currently handling this fallback:

if (dropShadowsAreSupported) {
    box.addDropShadow("black");
} else {
    box.putImageBehindIt("gaussianBlur.png");
}

Is this the right way to handle it? It seems too amateur to me. Is there a better design pattern?

© Programmers or respective owner

Related posts about design-patterns

Related posts about cross-platform