Hi, I am currently processing DataRows. Each data row has Group, Division and Department. I want to find a file that corresponds to group, division and department in the form (group).(division).(department).xlsx. If the department cannot be found, go up one level and find the file (group).(division).xlsx. If it still cannot be found, go up another level to (group).xlsx.
The problem is that sometimes the department or division is blank, so I check directly in the lowest level that has info e.g. if department is missing, just go ahead and search in division level.
This results in many If conditions which makes it difficult to maintain. E.g. first check if department is present, then within this if branch there is another bunch of nested if’s to check three levels… if department not present then check if division is present, within this, check two levels with nested if’s… and lastly check if group is present and if no file found, throw exception.
How do I organize the activities without having repeated sequences?