The hoard of clutter within someone's memories

Some of it is useful

Any AI version of Marie Kondo should just give up!

Most have the impression that software works by having the user manually input data into it, such as the way most people use spreadsheets. Quaint but it is tiresome to the point that the user often gets carpal tunnel problems. That's not the way things should be. Savvy users prepare their data in a file beforehand, this allows double checking that the input is correct and removes the urge to check or look at some GUI. Just point the software to the correct file and then relax and have a cup of tea. If the text needs to be formatted in a certain way, a simple piece of software can often be created to take simpler text files and create what is needed. It's an old-school method that is hard to beat.

I am deciding on the data format for this Java project and have narrowed it down to 3 options:

  • XML
  • SQL
  • Some text in a file without fancy format

Each have their pros and cons but rather than go through the tedium of listing them all, I have decided on using XML. The main pros are that the set-up is simple and the file can be used for other things as XML is useful if I wish other things to use the file. Java has XML parsing capability, so there should be no complications when pulling out the necessary data.

Here's the file that I have been playing with:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE framework SYSTEM "framework.dtd">
<framework>
    <title>Test Framework 1</title>
        <joints>
            <rigidjoint>
                <id>0</id>
                <xcoord>0</xcoord>
                <ycoord>0</ycoord>
            </rigidjoint>
            <rigidjoint>
                <id>1</id>
                <xcoord>0</xcoord>
                <ycoord>3</ycoord>
            </rigidjoint>
<!-- Sliding joints can be defined such as the following
            <slidexjoint>
                <id>2</id>
                <xcoord>4</xcoord>
                <ycoord>3</ycoord>
            </slidexjoint>
OR
            <slideyjoint>
                <id>2</id>
                <xcoord>4</xcoord>
                <ycoord>3</ycoord>
            </slideyjoint>
-->
            <simplejoint>
                <id>2</id>
                <xcoord>4</xcoord>
                <ycoord>3</ycoord>
            </simplejoint>
        </joints>
        <strmems>
            <strmem>
                <id>0</id>
                <startjoint>0</startjoint>
                <endjoint>2</endjoint>
            </strmem>
            <strmem>
                <id>1</id>
                <startjoint>1</startjoint>
                <endjoint>2</endjoint>
            </strmem>
        </strmems>
        <forces>
            <force>
                <jointid>2</jointid>
                <magnitude>600</magnitude>
                <angle>180</angle>
            </force>
        </forces>
</framework>

The above lists 3 joints, two rigid joints that don't move and a simple connecting joint. It also lists two structural members and a downward force at the simple joint. This is a very basic statically determinate truss that will be used as a testing example.

The XML file makes a reference to a dtd file, this is used for checking XML file structure.


<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT framework (title, joints, strmems, forces)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT joints (rigidjoint*, slidexjoint*, slideyjoint*, simplejoint+)>
<!ELEMENT rigidjoint (id?, xcoord?, ycoord?)>
<!ELEMENT slidexjoint (id?, xcoord?, ycoord?)>
<!ELEMENT slideyjoint (id?, xcoord?, ycoord?)>
<!ELEMENT simplejoint (id?, xcoord?, ycoord?)>
<!ELEMENT strmems (strmem+)>
<!ELEMENT strmem (id?, startjoint?, endjoint?)>
<!ELEMENT forces (force*)>
<!ELEMENT force (jointid?, magnitude?, angle?)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT xcoord (#PCDATA)>
<!ELEMENT ycoord (#PCDATA)>
<!ELEMENT startjoint (#PCDATA)>
<!ELEMENT endjoint (#PCDATA)>
<!ELEMENT jointid (#PCDATA)>
<!ELEMENT magnitude (#PCDATA)>
<!ELEMENT angle (#PCDATA)>

It is possible to use the XML file without the dtd but nothing beats knowing that the data and the format it is in is as it should be. This means that a lot of error messages will crop up if anything goes wrong but applying techniques to remove mistakes as far as possible will make life easier. The concept of poka-yoke.

This is a great starting example and I have already tested it, the results will be posted on future pages.

Before that, the question remains....is there an easier way to set up these files?

That is the next little exercise.

About

This is where I place the very basic notes on programming from those starting at the very beginning using Linux or similar operating systems. It's set up to be understood by everyone. If you have an opinion as to how this page is done, then you are already and intermediate or advanced programmer and I don't care!