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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:33:18+00:00 2026-05-14T15:33:18+00:00

I have a Car class. It has three properties: id, color and model. In

  • 0

I have a Car class. It has three properties: id, color and model.

In a particular query I want to return all the cars and their properties, and I also want to return a true/false field called “searcherKnowsOwner” which is a field I calculate in my database query based on whether or not the individual conducting the search knows the owner. I have a database function that takes the ID of the searcher and the ID of the car and returns a boolean.

My car class looks like this (pseudocode):

class Car{
  int id;
  Color color;
  Model model;
}

I have a screen where I want to display all the cars, but I also want to display a flag next to each car if the person viewing the page knows the owner of that car.

Should I add a field to the Car class, a boolean searcherKnowsOwner? It’s not a property of the car, but is actually a property of the user conducting the search. But this seems like the most efficient place to put this information.

  • 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-14T15:33:18+00:00Added an answer on May 14, 2026 at 3:33 pm

    Let the Car and Owner object remain unchanged. Define 2 classes SearchCriteria and SearchResults

    SerachCriteria will hold the search criteria as supplied by end-user and your application logic will return an object of type SearchResults that is a collection of Cars.

    You can maintain a flag within SearchResult corresponding to each car object in the result for if the owner is known.

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

Sidebar

Related Questions

I have a car model. (In my database, the cars table has a column
Say I have a class Car that has 2 properties: NSMutableArray *parts and BOOL
I have the following setup. Class, say, Car that has a CarPart (belongsTo=[car:Car]). When
i have a class of this kind Class Car { private $color; public function
We have small class, that has a related class class Car has_one :engine, :dependent
I used to have one class for one file. For example car.cs has the
if I have a ActiveRecord model: class Car < ActiveRecord::Base belongs_to :store end In,
So, imagine I have this model: class Car has_one :engine end and the engine
I have a following model: class Car(models.Model): make = models.CharField(max_length=40) mileage_limit = models.IntegerField() mileage
I have a class Car which has a class scope variable cost, i understand

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.