This is a matter of theory, I assume that I am using this standard procedure for this.
If I have a Constructor method that performs many tuning operations that collect data, etc., should I store the "all things" construct in the constructor or try to call other methods from within the constructor (to view the code basically), or should I just initialize everything that I have and leave other things to be considered later if they are really necessary?
Here is an example.
I am creating an object that is basically a collection manager. It needs to read data from a file, and it stores it inside an array.
I use a constructor to create an object with basic properties and read data later, or I have to read all the information and set up an array inside the constructor, which saves time later, but takes extra time here, or I need to do something in the lines
public myConstructor(String filename) { data = readDataIn(filename); }
This is not actual code, just an example of outsourcing for different methods for "pretty code", and not a super-long constructor method. I can tell 5-6 short and good methods that only the constructor can access.
source share