سؤال

I am new to software testing and would like to know whether it's appropriate to draw a data flow graph that flows from initiation of variables to constructor and method.

Is there something wrong with this data flow graph?

class car {

  string brand; // 1
  int age; // 2

  car(string brandName, int year)
  {
     brand = brandName; // 3
     age = calAge(year); // 4
  }

  calAge(int year);
  {
   return DateTime.Now.Year - year; // 5
  }
}

enter image description here

هل كانت مفيدة؟

المحلول

[is it] appropriate to draw a data flow graph that flows from initiation of variables to constructor and method.

I'd say "No"

for two reasons..

  1. "data flow graph" seems to have a pretty specific meaning, which i assume you are using too. You should show the dependencies of each function or step, which would 'reverse' your flow

ie.

constructor -> depends on -> calAge, brandName, year
calAge -> depends on -> DateTime, year

Also, I'm not sure its appropriate to list variables as dependencies when they are simply storing an input. ie. is age a dependency of constructor? it doesn't need to be calculated before the constructor runs

  1. I think the diagram is of limited use.

    The key thing from a testing perspective seems to be the fact that the constructor depends on calcAge or perhaps more significantly DateTime.Now, which isn't clearly called out by your diagram.

    Indeed, if you moved the calc age code into the constructor, would your diagram change?

  2. The last arrow going back to 4 seems to be incorrect. Car() should be an end node

Overall though, perhaps if you are doing these flows (correctly) for all classes to check for these hidden dependencies, or are trying to demonstrate the hidden dependency in this case. Then Yes it would be a reasonable diagram type to use.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى softwareengineering.stackexchange
scroll top