Corey D
Corey D

Reputation: 4689

XML vs Hardcoded interface?

I'm working on a flexible GUI application that can have ~12 varied layouts. These layouts are all well-defined and won't change. Each layout consists of multiple widgets that interface with a DLL using bit patterns. While the majority of the widgets are the same, the bit patterns used vary depending on the interface type being presented.

My gut instinct is to use inheritance: define a generic 'Panel' and have subclasses for the different configurations. However, there are parts of the interface that are user-defined and are spec'd to be specified in an XML file.

Should the entire panel be defined in XML, or just the user configured sections?

Upvotes: 5

Views: 400

Answers (2)

Rik Heywood
Rik Heywood

Reputation: 13972

My feeling is that you should do whatever will give you the greater flexibility to change your mind, add new features or adjust the layout in the future.

Upvotes: 1

Welbog
Welbog

Reputation: 60418

YAGNI: Design your screens for the current requirements, which you specifically state aren't going to change. If a year down the line more customization is needed, make it more customizable then, not now.

KISS: If using XML results in less overall code and is simpler than subclassing, use XML. If subclassing results in less code, use subclassing. Experience tells me subclassing is simpler.

Upvotes: 10

Related Questions