Embracing the DRY Principle in XML

We have a product in which each client has an XML configuration file containing sets of user interface parameters and subparameters. For example, one type of user (call them A) has one set of parameters, and another type of user (B) has a different set of parameters.

The problem is that A and B share most of the parameters, although sometimes, when they have an option, one or more sub-parameters are different.

Now we get clients instead of two types of users, 30 types of users, and client configuration files are bloated with the same information that is repeated up to 30 times, creating a nightmare for maintenance for development.

In what ways would you recommend applying the DRY principle to this situation?

+3
source share
2 answers

You need to implement a form of inheritance, as well as inheritance in object-oriented programming languages ​​or CSS, in which you start with a set of general options, and then allow you to override other parameters in more specific sets.

You establish a hierarchy of parameter sets, starting from the top, with parameters specific to all users, and then sets of options that you have defined as common to many types of users, and finally, to user parameters. This needs to be represented as a tree in the XML configuration file, indicating each parameter set with a name and a parent element. At the bottom of the tree are sets of parameters named after certain types of users (As, Bs, etc.).

. , . , .

, , , . , DAG, , .

, , , , . , - , .

+2

, Ant: , .

( Ant ):

<project ... >
  <path id="project.class.path">
    <pathelement location="lib/"/>
    <pathelement path="${java.class.path}/"/>
    <pathelement path="${additional.path}"/>
  </path>

  <target ... >
    <rmic ...>
      <classpath refid="project.class.path"/>
    </rmic>
  </target>

  <target ... >
    <javac ...>
      <classpath refid="project.class.path"/>
    </javac>
  </target>
</project>
+1

Source: https://habr.com/ru/post/1775009/


All Articles