0

I have two classes (A and B) and a Model (T) with some properties. In A class, There is a method with the passing model(T). We have to check a condition to check the name using a switch case, where the name matches the case then we have to call a public method of the B Class.

Public class A{
private IB _b;

public void methods(T t){
    switch(t.name){
        case Q.A
        _b.testmethod1(t);
        case Q.B
        _b.testmethod2(t);
        case Q.C
        _b.testmethod3(t);
        case Q.D
        _b.testmethod4(t);
    }}

I have tried the if condition instead of if but the meaning is the same. Does this code violate Single Responsibility Principle or the generalized code?

Does this code violate Single Responsibility Principle or the generalized code? if yes then let me know how to manage with switch case.

David_DD
  • 585
  • 1
  • 5
  • 12

0 Answers0