I know that changing private method's sign with public ignore encapsulation principle. I know But I wonder that if the method does not effect or break other part of system, can i make the method's signature public?
For instance;
I have a method which contains switch-case block;
private Object foo(Object object, MyTypeEnum type) {
....
switch(type) {
case type.x:
return "a";
break;
case type.y:
return "b";
break;
case type.z:
return "c";
break;
.
.
.
}
..
}
In addition;
- Moving the method in utils class to be able to make its sign public is bad practise since the method is not generic and reusable
- Testing a public method which calls the private method(foo) is one of solutions. However, my codebase has a lot of legacy and untested code so i have to change other classes and methods. Furthermore, I have no enough time refactor other part of my codebase.
What do you advice to me for this case ?
Aucun commentaire:
Enregistrer un commentaire