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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:22:39+00:00 2026-06-18T02:22:39+00:00

There is a design issue I need your help with. Suppose I need to

  • 0

There is a design issue I need your help with.

Suppose I need to design a clothing store. In this store there are Sellers and Buyers each one is registered in the shop with an ID.

We want to allow a Seller to sign in as a Buyer and vice versa (using the same ID he was originally signed up with).

Keep in mind that Buyer and Seller have different data memeber and also in order to use the function Buy all we need is the Buyer data member and not he Seller data member.

At first sight, while considering that the Seller has different data member from the Buyer I decided to set these two classes as derived of ShopPerson which is derived from Person.

The reason I decided to have ShopPerson class is to allow Buyer and Seller a base class containing common functions .( becuase both of them can Buy and Sell)

My problem is:

The “Buy” function should be only member of Buyer, but then how could I treat a Seller as a Buyer? If by chance the Buyer is a Seller than he won’t have this function.

My solution above, using a ShopPerson class to have a shared/common classes isn’t good either because the Buy function uses some data member which are only dedicated for the Buyer and the ShopPerson wouldn’t be familiar with them.

The only solution I have in mind is to drop of inheritance, but I am not sure if this is correct.
How can I solve this design issue? Any ideas?

Thank you all, Syndicator!

  • 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-18T02:22:40+00:00Added an answer on June 18, 2026 at 2:22 am

    Inheritance may not be what you need. Perhaps something like the below.

    class Buyer{
        ShopPerson* person;
    
        void Buy();
    };
    
    
    class Seller{
        ShopPerson* person;
    
        void Sell();
    };
    

    i.e You have a central list of ShopPerson, but Buyer and Seller are thin classes which are instantiated on a transaction by transaction basis. You could use inheritance now

    class TransactionParticipant{
         ShopPerson *person;
         //Misc common functionality
    };
    

    And inherit Buyer and Seller from this class.

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

Sidebar

Related Questions

Isn't there a Design Pattern who describes how to high cohesion? I need some
Are there any known design principles, best-practices and design patterns that one can follow
There are three parties in my design: MSFT orderbook NASDAQ index (need to be
I've run across this design issue a number of times and was wondering if
I have a design issue. I need to implement a listener. I saw the
This is a design issue I keep running into, so I thought I would
What does it mean to say - Engineering scalability into applications. Are there design
Is there any design reason for that (like the reason they gave up multi
I am developing an application and part of the design is there is a
There is a big design flaw here, but I'm having trouble solving it: The

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.