I had written something like the following,
public class ClassName {
//private instance variables
public ClassName() {
//initialize instance variables
this.someFunction();
}
public void someFunction() {
//do something
}
}
The person who reviews my code asked me to move the call to someFunction() method outside of the constructor. And I had to do something like this wherever I created an object for the class,
ClassName object = new ClassName();
object.someFunction();
Calling a method from constructor is a bad idea? Why the second way is preferred?