I want to print out my app's workflow. I'd like to know which way is more efficient or just better to do the things? Here's my code:
private void methodOne {
System.out.println("Dummy.class -> methodOne() started");
...
System.out.println("Dummy.class -> methodOne() ended");
}
private void methodTwo {
System.out.println(logMsg("Dummy", "methodTwo") + "started");
...
System.out.println(logMsg("Dummy", "methodTwo") + "ended");
}
private String logMsg(String className, String methodName) {
return className + ".class -> " + methodName + "() ";
}
Which one should I use? Is it better to just create whole strings like in methodOne() or just reuse part of them like in methodTwo()?
EDIT: Let's say I want to use logMsg in at least 100 methods