Badly Designed Languages, Consistency and Tools

Most commercial languages and community based languages are easy to understand and use. You may however find yourself in a position where you have to use an inelegant proprietary language that is annexed to an application you have been engaged to support. The language may be used as part of a customisation process. Now for the worst case scenario:

The syntax of the language is extremely irregular and the documentation provided for it is worse!

Having to employ a language that has excessively awkward syntax and unreasonably defined routines you know two things:


Even the untidiest rules with some perspiration and serious mental effort will eventually reveal a consistent approach to constructing a routine to achieve a desired result. To understand what the language's rules are and how they are applied:


Graphical representations of routines constructed from a badly designed language can vastly improve your understanding of what the language is saying. Charts and diagrams remove the clutter of curly braces, formatting and keywords. The graphic will present you with an abstracted clear view of the flow of the language and the way it instructs an application to do something. The next step is to write out a similar routine using your graphical representations as a guide and see if you can simulate a similar result to what is expected. If you are successful then you have solved some of the language's mystery.

Once you have a handle upon the language, your next step, if you have time, is to create some kind of interface between the language and yourself. By this I mean divorcing yourself from direct contact with the language by either:


Both options will need an interpreter that will convert your language to the proprietary language and vice versa. You start by breaking down and mapping the components that make up the proprietary language:
Begin by breaking down the independent components from the largest to the smallest for instance:
For example:

property x:5 [independent component]
property t:10 [independent component]

definition "my test property" [large component]
{
property "prop one" [dependent component of definition]
{
edit oneof "property two" relate by "is keyed by" READONLY [dependent component of property within definition]
} ASGRID LENGTH 1200
}

The tools at your disposal to help break down the proprietary code are:


Once you have learned the proprietary language's break-down and can represent scripts written in it within your interface, you can then work upon reversing the process so that you can create a proprietary script from your interface.

Things you may want your interface to do for you:


do 1{
code
do 2{
code
do 3 {
code
do 4 {
} // end do 4
} // end do 3
} // end do 2
} // end do 1

To convert the code the interface might break down the components into a database. A table for sub-routines, a table for properties and variables etc. Each component could be ordered by recording the starting position of a component's first character in the code block (script). This provides the ability to convert the code in both directions as it was originally written or re-write the code in order of component. For example:

You start with a script that looks like this:

property x:5

definition "def One"
{

display dialog x
}

property t:6

definition "def Two"
{

display dialog t
}

Splitting the code into it's respective tables:

Properties Line=1; Name=x; Value=5 Line=8; Name=t; Value=6

Definitions Line=3; Name=One Line=10; Name=Two

Definition Clauses Line=5; display dialog x Line=12; display dialog t

You can either re-write the lines of code in their respective line/character number order or re-write them by their object order like so:

property x:5
property t:6

definition "def One"
{

display dialog x
}

definition "def Two"
{

display dialog t
}

Once you have decomposed the code into a more manageable format you can manipulate it how you would like.

In recapitulation, when dealing with a badly designed language you carry out the following steps:

Duane Hennessy Senior Software Engineer and Systems Architect. Bandicoot Software Tropical Queensland, Australia (ABN: 33 682 969 957)

Your own personal library of code snippets. http://www.bandicootsoftware.com.au

Moderator of http://groups.yahoo.com/group/AccessDevelopers

Article Source: http://EzineArticles.com/?expert=Duane_Hennessy

Duane Hennessy - EzineArticles Expert Author