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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:02:07+00:00 2026-05-14T06:02:07+00:00

If I have a class with some value member that I want to store

  • 0

If I have a class with some value member that I want to store regardless of type, I would think that an object type would be the best. Lets say that the object can realistically be one of three types: string, int, customeClass. Would it be better to keep an extra enum member of the class with what type is stored in the value? Or is the execution of

if(object is string){...}
else if(object is int){...}
else if(object is customeClass){...} 

fast enough that it’s not worth storing the extra 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-14T06:02:07+00:00Added an answer on May 14, 2026 at 6:02 am

    Don’t do premature optimization before measuring and proving that is operator is a local bottleneck on a hot code path. Maintaining the enum for the alternative approach will tax development over long time.

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

Sidebar

Related Questions

I have a class C(Of T). I want to determine if some given value
I have a class with a complex data member that I want to keep
I want to have a static class that would hold different kinds of data
I have some test class TestKlass = (function() { function TestKlass(value) { this.value =
I have a class and I want to have some bit masks with values
I have some class that I'm passing as a result of a service method,
Suppose I have some class which has a property actor_ of type Actor .
I have a class with some method that depend by one parameter. What is
Say I have some special class, WrappedDataTable , and I want to associate each
I have declared the following enum type in which I want the first member

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.