Book a Demo

Author Topic: question about modeling C code into UML  (Read 14435 times)

umllearner

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
question about modeling C code into UML
« on: February 21, 2014, 01:42:15 am »
Dear all,
I am doing reverse engineering from C code into UML model using EA.
I am facing problem about how to modeling class relationship for usage of global variables.
For example:
In Test_pub.c
#include pub.h
Void test_pub_func(void)
{
 g_var ++; /* g_var is a global variable */
}

In Pub.h, glabal variable is defined:
Uint32 g_var;

I have modeled pub.h as a class diagram named pub, where defines g_var as public attribute of pub.
Test_pub.c is also modeled as a class diagram named test_pub, where defines test_pub_func as public operation of test_pub.
Now I wonder what could be the relationship between test_pub and pub, for example, dependency (use) or association?
Thanks in advance for your help
Lai

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: question about modeling C code into UML
« Reply #1 on: February 21, 2014, 01:58:41 am »
Hm. Why do you use a non-OO language to learn UML? You like it the hard way :-?

q.

umllearner

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: question about modeling C code into UML
« Reply #2 on: February 21, 2014, 02:00:31 am »
It is reverse engineering, the code is already there, and I have to show the design through UML.
unfortunately it is not up to me to decide the design tool.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: question about modeling C code into UML
« Reply #3 on: February 21, 2014, 11:20:56 am »
You "can" write OO with C. But from experience it's very, very unlikely that this has been done. So it does not make much sense. Can you photograph air? Can you paint on water? Use Eclipse or the like to document the code. If you want to re-design, start from scratch. You could document the use cases  and requirements with EA.

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: question about modeling C code into UML
« Reply #4 on: February 21, 2014, 12:23:04 pm »
Quote
Now I wonder what could be the relationship between test_pub and pub, for example, dependency (use) or association?
Dependency. It would only be an Association if "Test_pub" owned an attribute typed by "pub".
The Sparx Team
[email protected]

umllearner

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: question about modeling C code into UML
« Reply #5 on: February 21, 2014, 10:39:50 pm »
@KP,
thanks for your answer.
in case that one constant macro (ex: #define FALSE 0) is defined in pub, which is used inside of test_pub, then this relationship should be also dependency?
Thanks
Lai
« Last Edit: February 21, 2014, 10:43:22 pm by wlai56 »