Book a Demo

Author Topic: Modelling legacy C code  (Read 4411 times)

David Regan

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Modelling legacy C code
« on: March 16, 2019, 01:19:43 am »
I have inherited a legacy project in C which is a mess. It has many files and global variables. I am new to EA and am trying to use it to document the project in order to understand what is happening.


Consider main.c declares a global variable MainState. In another file log.c logInit() sets MainState to MS_DUTY (an enum val)

I have created a class to represent main.c with the globals as attributes and an object diagram with main instantiated (not sure if that's good).

I would like to use an activity diagram to describe the function logInit(). I tried using WriteVariable action to show MainState being written. This seems to work if I  free-type MainState = MS_DUTY but I thought there may be a way to tie it in the the actual object.

Mauricio Moya (Arquesoft)

  • EA User
  • **
  • Posts: 344
  • Karma: +8/-4
  • EA Consulting and development in Spanish
    • View Profile
    • Arquehub Azure Module
Re: Modelling legacy C code
« Reply #1 on: March 16, 2019, 07:33:54 am »
You can reverse-engineering the code and then visualize the C classes in a Class diagram. Have you tried it?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Modelling legacy C code
« Reply #2 on: March 16, 2019, 08:13:51 am »
You can reverse-engineering the code and then visualize the C classes in a Class diagram. Have you tried it?

He's talking of C, not Cxx. C is not OO and can not be RE-ed in any way. AD's are fine to help understanding things. There might be parts where state machines are appropriate. But in most cases I'd simply say: forget it. Try to write down some notes. Look if there are ways to re-factor things. It depends what the code is good for. If it's for embedded systems then SysML might be worth a look. If it's a business application: run. As fast as you can.

q.