A software design pattern to model runtime-dependent behavior

application-designdesign-patternsengineering

In a interview I was asked,

Suppose we are going to create a software that runs on both desktop machines and smartphones. Name a software design pattern that could be used to enable the application to create different classes for display at runtime depending on the platform.

I know there are simple solutions to implement this feature in the actual code. For example, in Java I can check the display size and create the suitable class (MobileDisplay or DesktopDisplay class) for that display.

But I don't how this is related to the software design; in my opinion, creating suitable class based on runtime platform is an implementation concern rather than a software design issue.

Best Answer

I think the interviewer was expecting the Abstract Factory pattern. http://www.vincehuston.org/dp/abstract_factory.html And I also think that you are missing the point of software design. Ultimately software is about implementation, but a little thought and design patterns make the implementation easy to follow.

Related Topic