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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:18:07+00:00 2026-05-27T09:18:07+00:00

General Problem I have some objects that have some variables that are not known

  • 0

General Problem

I have some objects that have some variables that are not known at creation time.

Right now I create these objects and gradually fill them until they are fully instantiated. But I’m wondering, “Is it a good design to gradually fill an object until it is fully instantiated?”.

My Specific Problem

I’m developing a Java program that has a hierarchy of Task objects. These tasks have some variables that are known when I create them, and some variables that only become known when the task is being scheduled. Right now I create these tasks with the variables that are known, and when the task is ready for scheduling I call scheduleTask(Task t) and this method will set the variables that become known when the task is being scheduled.

But is it a good solution to create objects that are not fully instantiated, and set the remaining variables when they become known?

I was thinking about deferring the task creation until all variables are known (when it is being scheduled). But some taks can only be scheduled after getting an approval from external sources.

Does somebody have some design ideas on how to solve this problem?

EDIT: I forgot to mention that I have different types of Tasks that all inherit from “Task”.

EDIT 2: How about “ProposedTask” objects that have the variables that are known before scheduling? References to these can be hold until it gets approval. Then a new “Task” can be created while scheduling based upon the “ProposedTask” object (‘scheduleTask(ProposedTask p)’ now takes a ProposedTask object).

  • 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-27T09:18:08+00:00Added an answer on May 27, 2026 at 9:18 am

    Use the Builder pattern. E.g:

    Task.Builder b = new Task.Builder():
    b.knownProperty(value).anotherProperty(value2);
    
    myExecutor.schedule(b);
    
    
    ...
    void schedule(Task.Builder b) {
        b.propertyBeforeExecute(value);
        Task t = b.build();
    }
    

    Many frameworks use it to create partially created objects and then execute some action. E.g.: Http requests builders -> HttpPool executors

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

Sidebar

Related Questions

Update: After some more reading I see that this problem is totally general, you
I have a project that contains several submodules, that communicate using some objects that
The general problem: We have urls coming to our IIS web servers formatted like:
Okay, so I'm using perl to read in a file that contains some general
I have this general problem in design, refactoring or triage: I have an existing
I have a graph-theoretic (which is also related to combinatorics) problem that is illustrated
I've worked on projects that have very complex XML configuration, and one problem that's
I have a function that's taking a long time to run. When I profile
Sometimes we have several classes that have some methods with the same signature, but
Imagine that I have a general class Person . Then I have specializations 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.