Embracing the DRY principle in XML -


we have product each customer has xml config file containing sets of ui options , sub-options. example, 1 type of users (call them a's) have 1 set of options , type of users (b's) have different set of options.

the problem have , b share of options, though when share option, 1 or more of sub-options differ.

now we're getting customers with, instead of 2 types of users, 30 types of users, , customer's config files bloated same piece of information repeated 30 times, creating maintenance nightmare development.

which ways recommend apply dry principle situation?

you need implement form of inheritance, inheritance in object-oriented programming languages or css, in start set of common options, , allow overridden other options in more specific sets.

you establish hierarchy of sets of options, starting @ top options common users, sets of options have identified being common many types of users, , user-specific options. needs represented tree in xml configuration file, giving each set of options name , parent. @ bottom of tree sets of options named after specific types of users (as, bs etc.).

in program need read file , assemble tree in memory. then, move through top bottom collecting options , overriding them go. when reach user-specific options @ leaves of tree , perform last overrides, finished.

when factoring options, may find sets need have more 1 parent, because combine options more 1 set. if case, tree becomes dag, , need topologically sort before traverse it.

i realise complex solution, can assure flexible way of dealing multiple configurations have common elements. have implemented in order configure several e-commerce web sites used same back-end.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -