There are plenty of nested if else statements in the legacy code (VB Script) which I want to migrate to a meaningful representation for easier maintenance in a Java application. Most of these statements are used to generate a sql statement based on user selection of parameters. Any suggestions to better model this logical branching problem as a data structure viz., directed graphs?
For example, if the parameters are:
age department grade
String finalSQL = “”;
if(department is not ‘HR’){
// append something to finalSQL
if (age between 21-35)
{
// append something to finalSQL
}
else if (age between 35-40)
{
// append something to finalSQL
}else{
// append something to finalSQL
}
} else {
if(grade > g7){
// append something to finalSQL
}else if (grade is g2 or g4 or g6){
// append something to finalSQL
} else{
// append something to finalSQL
}
}
return finalSQL;