Translate: essence, not the content

Very few projects start off with a clean slate; the majority have some body of existing text-based code (C/C++/Asembler) which needs to be either translated or wrapped into the Model-Based Design environment.  For the cases where translation is the desired path, the objective should be the translation of the essence (e.g. requirements) not the content.

Why translate essence, not content?

First, every programing language has unique constructs which may or may not be directly replicable in other languages.  Because of this, a common failure mode is to try and directly replicate coding patterns in the MBD environment.

catTrans_1.jpg

Second, when you translate the based on the requirements you have the opportunity to improve upon the existing code.

There is a function for that…

It is common with text-based algorithms to implement basic functions such as table look ups, integrators, etcetera.  While in some edge cases the text-based implementation is more efficient this is less common with the growing maturity of Model-Based Design tools.

blocks

Further, the small efficiency gains from the existing implementation are frequently less important than the clarity found by using built in blocks.

It is really a…

In text based languages truth tables and state machines are implemented as either a series of if/then/else or switch/case statements.  Within MBD environment both truth tables and state machines have direct implementations.

Pushing things too far…

The final note, there are some areas where text based modeling makes the most sense.  Generally, this is in the area of long complex equations.  While they can be rendered in block form they are more easily read in text form.  With that in mind, I recommend using MATLAB blocks for longer equations.

simpleMath

The image above, the Pythagorean theorem, is relatively simple.  Yet even it would be more easily read as

C = sqrt(A^2 + B^2)

Final thoughts (part 1)

When translation occurs it is important that the new implementation is validated against the behavior of the existing code.  Failure to do so can result in larger system level errors.

Final thoughts (part 2)

In my translation example, I used the simple phrase “I have the cutest cat in the world”  I submit the following images to back that claim up

 

 

 

One thought on “Translate: essence, not the content

  1. Michael, I love to see “Why translate essence, not content?” first.
    I can testify a couple of cases, where the “requirement stop” was totally bypassed to perform straight reverse engineering of existing code in a Simulink model/Stateflow chart. Result: blurry assessment of model-based design potential.
    P.s. In both the cases, a problematic area of the development workflow was
    in the management of requirements (decomposition, translation, traceability).

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s