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

  • Home
  • SEARCH
  • 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 8109529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:26:49+00:00 2026-06-06T01:26:49+00:00

I have two classes, Item and SoldItem . SoldItem inherits from Item adding some

  • 0

I have two classes, Item and SoldItem. SoldItem inherits from Item adding some property such as prize, solddate, etc.

First I create a Item, and when i sold it I want to create solditem. Is correct this design? if yes how I can create solditem starting from item?

  • 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-06T01:26:52+00:00Added an answer on June 6, 2026 at 1:26 am

    I’d say this is improper use of inheritance. What if you need to diversify the Item into subclasses by some feature that is orthogonal to whether it has been sold? For example, if you sell software, an item could be shipped on physical media, it could be downloadable, or it could be a subscription; if you decide to model these out by using inheritance as well, you already have six classes. And each orthogonal feature you add becomes a multiplier to the number of classes you need.

    A better design, involving composition, would be to have separate Item and Sale classes, and a link between the two; then you can add functionality to the Item class to get the relevant Sale, if any, and vv., get the Item of Sale (which should always be non-null). In this context, thinking relational rather than object-oriented is probably a better approach.

    If you are only interested in sold items, you’d look at Sale objects directly, getting item information through the related Item. If you are interested in any item, get an Item instance, and if needed query it for a Sale.

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

Sidebar

Related Questions

I have two classes one of which inherits from the other. Im trying to
I have two classes generated by LINQ2SQL both from the same table so they
I'm using play-1.2.3. I have two classes some kind of these: LabelItem: @Entity @Table(name=T_LABEL_ITEM)
First, a little background (greatly simplified): I have two classes, one called Entity and
I have two classes Item and Category. Items may belong to a single category.
I have two PHP model classes named Category and Item. A Category may have
i have this two classes: Item<T> : BusinessBase<T> where T : Item<T> { public
I have two C# classes, say Container and Item , and a unidirectional association:
I have two list items that, when clicked, should change classes from '.off' to
I have two classes.... Parcel and FundParcel...and I'm trying to convert an IEnumerable of

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.