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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:47:22+00:00 2026-05-30T17:47:22+00:00

I have a system that performs operations on lots of Things , these can

  • 0

I have a system that performs operations on lots of Things, these can be considered to be hardware devices accessible over a communication channel.

I use a manager construct that accepts tasks for single Things. Now, there are at least three types of Thing and they have slightly different properties associated with them. The manager must know about these extra properties as they are needed to perform any operation correctly (some Things must have their X foo’d instead of their Y etc…).

At the moment I have separate manager class for each type of thing. This causes a good deal of duplication as the Things are mostly similar.

It would be good if I could have an abstract manager that implements a good deal of the functionality and then each concrete implementation can supply the little extra bits.

Here is a greatly simplified example:

public abstract class ThingManager
{
    private ConcurrentDictionary<Guid, ??ThingTask??> _ThingTaskQueue;

    public virtual AddNewThingTask(<params>)
    {
        ??ThingTask?? NewTask = new ??ThingTask??(<params>);
        _ThingTaskQueue.Add(NewTask);
        Monitor.Pulse(_NewDataToProcess);
    }

    /* Implemented by the concrete, will depend on the type of ??ThingTask?? */
    public abstract GetSomeTaskParameterForAThing(Guid thingID)   
}

public class ThingTask
{
    public enum ThingOperation
    {
        Foo,
        Bar 
    };

    public String Name { get; set; };
    public ThingType Type { get; set; };
    public ThingOperation Operation { get; set; } 
}

public class AdvancedThingTask
{
    public enum ThingOperation
    {
        Foo,
        Bar,
        Baz 
    };

    public String Name { get; set; };
    public ThingType Type { get; set; };
    public ThingOperation Operation { get; set; }
    public Boolean EnableFrobber { get; set; } 
}

As you can see I need some way, when defining the concrete ThingManager to have ??ThingTask?? be either a ThingTask or an AdvancedThingTask. It would then be up to the concrete to make use of the extra properties when implementing the abstract methods.

Using an interface for ??ThingTask?? wouldn’t work because the properties would have to be declared in the interface and each one has different properties available.

I get the feeling I’m missing something very obvious as to how to do this cleanly, hopefully someone can help 🙂

  • 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-30T17:47:24+00:00Added an answer on May 30, 2026 at 5:47 pm

    use generics rather than a pure abstract class, someting along the lines of:

    public abstract class ThingManager<T> where T : ThingTask
    

    dependant on your full implementation I doubt if this will need to remain abstract

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

Sidebar

Related Questions

I have a system that creates an order and that order can be billed
I have developed a console utility that performs some operations against a server application.
I have a lot of code that performs bitwise operations on unsigned integers. I
I have a thread that keeps looping and performs operations on an object. The
I have a running system that process short and long running operations with a
I have a program that connects to an Oracle database and performs operations on
We have system here that uses Java JNI to call a function in a
I have a system that combines the best and worst of Java and PHP.
I have a system that uses a meta refresh to a logout page, which
We have a system that has a Mysql database with about 2Gigs of data.

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.