Hi, a quick question on good or bad practices when write
Java applications
I'm writing a class which takes a file name as a parameter when initialising it. But I don't want the full file name, I only want the file name minus the file extension. So I have a private
String variable with getters and setters. During the object initialisation, I call this private method to set the String variable. Is it bad practice to do this, to call a class method in the constructor? Would I be better to have as part of the constructor this code which sets the file name?
It is a total of 1 line of code - this.fileName = file.substring(0, 4); so it wouldn't really bulk up the constructor, but I have a preference for methods which do one thing, and methods for everything (I learned to program with smalltalk and this was the norm AFAIR - you never touch a variable, except through getter/setter methods)