Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:49:07+00:00 2026-06-14T09:49:07+00:00

I am designing one application in which I have to read one file given

  • 0

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:

  1. 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.

  2. 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:49:08+00:00Added an answer on June 14, 2026 at 9:49 am

    This is shading into a “functional programming” technique, but I would suggest that you write functions with the signatures:

    int numberOfOperations(String line)
    List<String> linesForFile(File file)
    

    and then something like:

    int totalOperations = 0;
    for(String line : linesForFile(file)){
      totalOperations += numberOfOperations(line);
    }
    return totalOperations;
    

    That way, you have easy-to-test individual functions, you aren’t coupling the logical domain of “counting operations” with the specific source (a file), etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am designing an application, one aspect of which is that it is supposed
I'm designing a networking framework which uses WSAEventSelect for asynchronous operations. I spawn one
i am designing a silverlight application in which i want to level of user
I am designing an application where a user places multiple UIImageViews one over another.
I have an issue regarding how one would go about designing an application suited
I'm designing a web application which stores SEO metrics relating to websites. There are
I have made one windows phone based application. i want some designing ideas from
I am in the process of designing a web application which will have multiple
I have been trying different techniques while designing this application, which to me is
I have this query for an application that I am designing. There is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.