It's not so much a question of best practices, but rather a question of correctness. From my understanding of the problem you are trying to solve, making using static
variables for CSVFilePath
and HTMLReport
would be incorrect, since (I assume) their values depend on the jsonFilePath
passed into the Reporter
's constructor. If you had multiple Reporter
s, each monitoring a different JSON file, each Reporter
would have a different CSVFilePath
and HTMLReport
— hence, they should be instance variables, not class variables.
That said, instance methods rarely use class variables, unless the class variables are const
or readonly
. If your instance method does use a static
variable, you should at least rethink what you are doing, and why.
If you only expect to ever create one Reporter
in your system, look into making Reporter
a singleton.
It's not so much a question of best practices, but rather a question of correctness. From my understanding of the problem you are trying to solve, making using static
variables for CSVFilePath
and HTMLReport
would be incorrect, since (I assume) their values depend on the jsonFilePath
passed into the Reporter
's constructor. If you had multiple Reporter
s, each monitoring a different JSON file, each Reporter
would have a different CSVFilePath
and HTMLReport
— hence, they should be instance variables, not class variables.
That said, instance methods rarely use class variables, unless the class variables are const
or readonly
. If your instance method does use a static
variable, you should at least rethink what you are doing, and why.
If you only expect to ever create one Reporter
in your system, look into making Reporter
a singleton.
It's not so much a question of best practices, but rather a question of correctness. From my understanding of the problem you are trying to solve, using static
variables for CSVFilePath
and HTMLReport
would be incorrect, since (I assume) their values depend on the jsonFilePath
passed into the Reporter
's constructor. If you had multiple Reporter
s, each monitoring a different JSON file, each Reporter
would have a different CSVFilePath
and HTMLReport
— hence, they should be instance variables, not class variables.
That said, instance methods rarely use class variables, unless the class variables are const
or readonly
. If your instance method does use a static
variable, you should at least rethink what you are doing, and why.
If you only expect to ever create one Reporter
in your system, look into making Reporter
a singleton.
It's not so much a question of best practices, but rather a question of correctness. From my understanding of the problem you are trying to solve, making using static
variables for CSVFilePath
and HTMLReport
would be incorrect, since (I assume) their values depend on the jsonFilePath
passed into the Reporter
's constructor. If you had multiple Reporter
s, each monitoring a different JSON file, each Reporter
would have a different CSVFilePath
and HTMLReport
— hence, they should be instance variables, not class variables.
That said, instance methods rarely use class variables, unless the class variables are const
or readonly
. If your instance method does use a static
variable, you should at least rethink what you are doing, and why.
If you only expect to ever create one Reporter
in your system, look into making Reporter
a singleton.