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 6982827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:20:22+00:00 2026-05-27T18:20:22+00:00

I occasionally find myself with several methods in a class that all require the

  • 0

I occasionally find myself with several methods in a class that all require the same data (for example, a query object). Typically, there will be one public method with a generic name like parseReport() which in turn delegates work out to several private methods and finally returns the finished product:

public function parseReport( queryObject ) {
    queryObject = correctDatesAndTimes( queryObject );
    queryObject = sortByCusomter( queryObject );
    queryObject = buildHierarchy( queryObject );

    return queryObject;
}

private function correctDatesAndTimes( queryObject ) {
    // do some stuff

    return queryObject;
}

private function sortByCusomter( queryObject ) {
    // do some stuff

    return queryObject;
}

private function buildHierarchy( queryObject ) {
    // do some stuff

    return queryObject;
}

So my question is, should my queryObject be a class-level property that all of my methods will reference rather than passing it through as an argument to the method each time it is called?

  • 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-05-27T18:20:23+00:00Added an answer on May 27, 2026 at 6:20 pm

    In a case like this, queryObject should not be a class property. If you look at it, you actually have one big function that is split in several smaller functions. If it was one big function, you wouldn’t make a class property of it.

    Data belongs in a class property, when the data is actually a part of the class. Remember that
    a class definition is the encapsulating of both data and behavior.

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

Sidebar

Related Questions

I occasionally find myself passing this or Me to a child object. Such as
In C#, I find myself occasionally wanting to register a method for an event
I find myself writing delegates occasionally for really simple functions (take no arguments and
Occasionally I come accross a unit test that doesn't Assert anything. The particular example
I have an application that is used in image processing, and I find myself
Occasionally I find code which tests if two NSString s are the same like
I want to find a minimal set of headers, that work with all caches
Possible Duplicate: Can you define “literal” tables in SQL? Occasionally I find myself in
I find myself occasionally in C# 3.0 looking for ways to simulate the notion
I've been using jQuery .find() to do xml traversal, and I'm finding that occasionally

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.