We have a C program which uses a .h header file to describe the custom-made data structure we use. The data structure must follow the design in the functional specification. There is some diagram to describe the member of the data structures and it would be described a ANS.1 abstract syntax, and then the asn file would be compiled to a .h header file.

In order to enhance our system, a request to change the functional specification was approved and a new specification was made. ( We jump from 2.10 to 2.12 as we had skipped the upgrade of 2.11 ) Comparing 2.10 to 2.12, a lot of new stuff were added and some old stuff were removed. We need to use a new .asn to compile a new .h header file in order to follow the specification.

The problem is that, something useful were removed. For example some member of a data structure were removed and we have been using the member for logic in the program. The program can't even compiled with the new header file. The program have been up and running and we would like to avoid any major down time due to this upgrade.

P.S. The specification is not only for our company, it is a standard for the file structure of the files sending between companeis within the whole industry. Say, if one declare to use 2.12 spec, and other party will treat the file with 2.12 standard and discard any files which doesn't follow the standard.

P.S. Of course there is no option. The decision is made. However I am facing a problem that the c program was written by some other people and have complex logic. The program would be hugely damaged by the change of the header file. And I may have no idea some to restore peace and functionality to it. Any suggestion of how to check with each difference is appreciated.

  • 1
    Which spec to support is the managers decision, and it seems they've made that decision. You need to adopt the new spec, amend your programs, test thoroughly and release. – jozzas Aug 27 '12 at 6:54
  • The program have 4800 line of C code with pointers. And about half of the header file were changed/dislocated. – lamwaiman1988 Aug 27 '12 at 7:07
  • 1
    4800 lines is not much. And when you use strings or arrays, you're already handling pointers. No chance to avoid them in C, so better get used to them. Granted, there is C code out there where 100 lines are too much to handle. "In My Egotistical Opinion, most people's C programs should be indented six feet downward and covered with dirt." Blair P. Houghton – Secure Aug 27 '12 at 7:28
  • 1
    Could you calculate the missing data from the existing data? Then you could write a function that does this and call it instead the data access where the missing data is needed. If this is not possible, then you have to change the program logic. – Secure Aug 27 '12 at 7:30
  • 1
    @Secure: that is what I thought also. I would like to add that it may be necessary to this in both directions (old structure <-> new structure). Sadly the OP missed to give us any information about the data flow directions, what makes his question very hard to answer. – Doc Brown Aug 27 '12 at 10:56
  • Versioning is your first line of defense.

If the passed data objects don't already have a version number embedded within them, you will want to add one. Having a version ID will allow you to determine if it's the older spec with information you're interested in or the newer one.

  • Wrapping the data object | struct becomes your next line of defense.

Instead of just tweaking the existing code that reads the data object and pushes that into your application, create a thin layer of code that processes the data object and converts that to a structure you can pass around within your application. At a broader level, you are decoupling your application from the specific version of the data object you receive.

Within this thin layer, you can add some logic that determines which version of the data object that you received. If it's the later version, then you can add logic to replace the missing values or insert dummy values instead.

Wrapping the data object allows you to preserve the contract that you had between the layers of your code. Likewise, you'll have flexibility in what versions of the data object you can now send out.

An example application stack might look like this:

Rest of the application code
    internal application data struct
data object processing layer
    received data objects (v2.10, v2.12)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.