samedi 9 avril 2016

Design interface that now needs more arguments than before

Explaining usecase:

public class Course {
    Mathematics math;
    Physics physics;
    English english;
    String teacher;
    String schoolName; //Just want explaing modelling hence keeping
}

public class PhysicsHelper extends Helper {
    public void help(Physics physics, String teacher) {
        Course course = // create course
        help(course);
    }
}

public class MathematicsHelper extends Helper {
    public void help(Mathematics math, String teacher, Address address) {
        String schoolName = address.getSchoolName
        Course course = // create course            
        help(course);
    }
}

public abstract class Helper {
    public void help(Course couse) {
        // defualt set of operations to be called by all helpers.
    }
}

Now,i have a requirement something like:

PhysicsHelper has started understanding english as well, so now PhysicsHelper has method

public class PhysicsHelper extends Helper {
    public void help(Physics physics, String teacher, English english) {
    }
}

  1. Is this the correct way of modelling this usecase
  2. If in future more argument are needed by PhysicsHelper, should changes be made to help() method?

Aucun commentaire:

Enregistrer un commentaire