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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:23:44+00:00 2026-06-13T15:23:44+00:00

I am trying to see if there is a design pattern that can solve

  • 0

I am trying to see if there is a design pattern that can solve this:

I have created an abstract class A with properties a,b and c. I have another class B that extends the class A and adds more properties: x,y,z. Then I have another class C that again extends A and adds i,j,k. Lastly I have a factory method that determines which instance to create B or C and thats the part where I need help. How or what should this factory method return: If it returns an instance of A than I wouldnt know which specific instance was created B or C? I need this factory method to create a concrete instance. Now, I know that I could write static method like createB or createC but I am looking for a more general solution maybe another design pattern here.

Update: The reason I want to know the concrete class is that I need to pass this object to a frontend jsp. That JSP would need to know what specific class was instantiated so it can call the appropriate getters.

  • 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-13T15:23:45+00:00Added an answer on June 13, 2026 at 3:23 pm

    I would Keep Factory Pattern as it should. so the return type would be the Abstract A class. B & C Should also inherit their properties through Proxy Pattern.

    So Make CAble & BAble Interfaces and use C & B as instances of A (as they’re both generated by the same factory), then cast B & C to act as their Interfaces Describe.

    Cheers!

    UPDATE:

    I think I’ve figured what you need, picture the following:
    In a School Page.
    There is a general view of Students & Professors, both have common and individual fields, but the common request is schoolMember.

    class SchoolMember // The return type of your Factory
      -name
      +getView():SchoolMemberView // Will be used by the View//View Model
    
    Interface Professor
      getProfession()
    Interface Student
      getSemester() 
    
    class FacultyMamber: SchoolMember,Professor
      -profession
      +getView():SchoolMemberView
    class UniStudent: SchoolMember,Student
      -semmester
      +getView():SchoolMemberView
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out the name behind this design pattern. Basically, you have
I am trying to design a class as a Code Kata for myself that
I'm trying to make a design like at the picture: as you can see,
I am trying to design a page where there are some tables. It seems
I am trying to design a system for something like this with ASP.net/C#. The
I have a major headache trying to get an image that is contained within
One part of domain-driven design that there doesn't seem to be a lot of
Suppose I have a class that downloads a news feed from the web public
I have a group of related companies that share items they own with one-another.
I'm trying to design a website for my mums backpackers business. The problem that

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.