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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:33:55+00:00 2026-06-15T18:33:55+00:00

I have an OO design question. I’m using a Factory pattern to create objects

  • 0

I have an OO design question.

I’m using a Factory pattern to create objects of a class appropriate to the parameters I pass the Factory. However, there are some attributes that I can only get after object creation which I want to then use to further subclass or “specialize” the type of object.

I need subclass for polimorphism to use custom logic for object with additional input parameters.

I think it’s some design pattern “Redetermination object class at runtime”. How can i implement it? Oh may be it is bad practice?

  • 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-15T18:33:56+00:00Added an answer on June 15, 2026 at 6:33 pm

    You can’t change object type at runtime. If you have instance of base class, then it will stay of base class type. But you can create new objects at runtime. Use composition instead of inheritance.

    I.e. instead of inheriting from your base class, create another objects hierarchy – extract to new classes (not inherited from your base class) code which changes after your base object creation. It could be some strategy. Then provide different implementations of strategy to your base object at runtime (i.e. “specialize” base class instance).

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

Sidebar

Related Questions

I have a design question... I want to create my own image class called
I have a design question. I'm using the HttpURLConnection class to navigate a website.
I have a design problem: Question class: have a question and answer (String) TextQuestion
This is more of a design question. I have a template class, and I
I have a general Database Design question: When is it better to create a
I have a design question about the use of Hibernate annotations and DAO pattern.
I am designing a product database and I have a design question. There are
I have a bit of a design question if anyone at there cares to
I am using c3P0 in my system. I have design question related to changing
I have a design question: let me expalin in simple example: Public class A()

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.