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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:54:28+00:00 2026-06-17T03:54:28+00:00

I am designing a producer/consumer based application and I am stucked at representing Task

  • 0

I am designing a producer/consumer based application and I am stucked at representing Task produced by producer in class representation.

The actual problem goes like: A producer can produce a StandaloneTask which can be directly consumable by a consumer or it can produce a CompressTask which has to be goes through a TaskDecompressor first which extract it first into a number of StandaloneTask which can them be consumed by consumers.

Since there is a lot of commonality between the StandaloneTask and the CompressTask, so I have created a base class called TaskBase which contains all this common information.

class abstract TaskBase 
{

}

class StandloneTaskType1: TaskBase
{

}

class StandloneTaskType2: TaskBase
{

}

.
.
.

class StandloneTaskTypeN: TaskBase
{

}

How decompressing of a task works?
A task can have one or more parameters which needs to be filled at run time. A compress task consists of a task with parameters and other info about how to get values that need to be filled in those parameters. After getting values, a TaskDecompressor is suppose to fill all these values into the parametrized task to generate one or more standalone task.

I have created a CompressTask class as follow.

class CompressTask: TaskBase
{
    TaskBase task;

    //runtime parameters
}

Now, its looks very weird to me that the CompressTask is derived from TaskBase and it also contains an instance of TaskBase. Is it correct to have such class? Or are there any better class representation of the given case.

  • 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-17T03:54:29+00:00Added an answer on June 17, 2026 at 3:54 am

    Overall this structure is not uncommon, you are somewhat starting to go down the road of the Composite pattern. Your CompressTask is somewhat acting like the Composite and your StandaloneTask is like the Leaf.

    I’d recommend reading up on that design pattern and potentially think about making it easier for a consumer to consume any subclass of TaskBase regardless of it being a CompressTask or StandaloneTask. That will strengthen your design and simplify consumption.

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

Sidebar

Related Questions

while designing my user control, i encountered the following problem: i would like to
I am designing a text based game similar to Zork, and I would like
I am designing a REST like API for paginated data retrieval of a YUI-based
How can you avoid circular dependencies when you're designing two classes with a producer/consumer
While designing a new WPF application I noticed exceptions not being thrown during data
Im designing my school's website and I kind of want to do like a
When designing an distributed application in Java there seem to be a few technologies
I'm designing a database that stores movie related information. I'm stuck on a problem
While designing a C++ class, suppose I have following two options: Option 1: One
Programming language: Java Task: designing a hash function that maps Chinese Strings to numbers

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.