Java: Is it used for refactoring / decoupling if only one class uses the new class?

the code:

public class Name {

private String[] name;
private String first;
private String middle;
private String last;
private String suffix;


public Name (String fullName) {
    //Name is parsed in constructor 
    parse1();
    parse2();
    parse3();
    //invoking more parse methods...
}

private void parse1() {}
private void parse2() {}
private void parse3() {}
//more parse methods...

These methods below the constructor help to parse fullName. I want to move these methods parse#()to another class, say NameHelper.classand do everything there public static, but something inside me says that it is useless for refactoring, since it will not use another class, but Name.

I want to reorganize, because later it will be really difficult to unit test. But I don’t want to sacrifice testing with ease against refactoring bad code, because I could always use PowerMockitoprivates to check.

+4
source share
2

, , . - ... .

, . "" , , "".

, , .

: , Powermock, . , /; ?

: , , Name. : , NameParserService; . - / !

+2

, , . . . , . , ().

+1

Source: https://habr.com/ru/post/1664003/


All Articles