I am designing one application in which I have to read one file given by a user and calculate the total number of operations. There are two ways I can think of achieving this:
Creating static variable that holds total operations. The benefit of this approach is that any where I need to perform some calculation based on total operations, I don't need to call function again and again which will read all the records from file and calculate number of operations.
Create function which returns number of operations by looping through file.
Option 1 is better performance wise, but static variable are against principle of OOP. Kindly let me know if there is any other approach to this problem and if my understanding is correct.
Thanks in advance.