0

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

  • 1
    What exactly do you want to achieve? As it is, the graph doesn't convey any information that's not better gained from the code. – Hans-Martin Mosner Sep 27 '20 at 06:10
  • 2
    The first thing which seems to be wrong with this graph is that using numbers (instead of the actual names) make it pretty hard to read. But even if I replace the numbers by names, it does not seem to match the code. For example, why is there an arrow from 1(brand) to 2(age)? In the code, those two variables look unrelated, there is no data flow from brand to age. – Doc Brown Sep 27 '20 at 06:59
  • This is not how data flow graphs are typically used. But it'd be more correct as 5->4->2 & 3->1. – candied_orange Sep 27 '20 at 07:41
  • The purpose of the Dataflow diagram is to flow information between a component of the system.what you want to do? please elaborate your question. – AjayGohil Oct 19 '20 at 05:54

1 Answers1

1

[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.

Ewan
  • 70,664
  • 5
  • 76
  • 161