File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Design question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Design question" Watch "Design question" New topic

Design question

ranjan Khaba

Joined: Jan 16, 2008
Posts: 22
Hi all,

Problem description:

Let's say there is an xml file called first.xml which contains some information about a device.
name = test1
location = L2_first

In the next release, some more new parameter are introduce for the device.
To support the new device version, create a new xml file called second.xml
name = test1
location = L3_second
size = 23
output = 5

Since the application has to support both the version of the same device, two xml files are maintained.
As we move on, we have to maintain many xml files which has almost same contain since the changes from one version to another version is very minimal.
Suppose if there is only one changes, even then we have to maintain different xml files.

What I want is something to have like mother.xml files.


<common parameter for all the version of a device>
common1 = same
common2 = same
common3 = same
</common parameter for all the version of a device>
<different parameter>
</different parameter>

And there are many device available.

So, in this current scenario, if there are 20 device with 5 version, then there are 100 xml files with almost same contains, maintaining this files is a nightmare.

The application is using java.
I would to develop a java API which will solve the above problem.

My suggestion:

An interface with API

Method signature: getDeviceXML( param1, param2)
param1 = device name
param2 = version no.
Return type = xml object

Method implementation:
1. Based on the device name read the xml file
2. Construct the xml file for the common parameter
3. Append the different parameter section of the version in the xml file.
4. Return the constructed xml version.

Please let me know if there is any improvement which can be done in the above design concept.
By doing this we can reduce the no. of xml files to 20.


Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
I would to develop a java API which will solve the above problem.

Your problem is not related to programming, it stems from the design of the XML-based language that you are attempting to create. Currently, your have a poor design which is not flexible enough to describe all of the information in an efficient way (in a single document.) Ideally you should only need to have a single XML instance file and a single XML Schema or DTD.

Aside, effective markup language design skills are not easily acquired and this is not something you can "find" by searching Google search results.
Gopi Chella
Ranch Hand

Joined: Apr 26, 2010
Posts: 53
Hi Ranjan,

As per your issue you have 20 devices and each device has 5 version, so 5 xml files for each device(just example it may have 3 xml or 2 xml). So what you do is you merge all the xml files into one then validate the consolidated xml against xml schema or parse the consolidated xml and validate.

SCJP 1.5
I agree. Here's the link:
subject: Design question
It's not a secret anymore!