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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:02:33+00:00 2026-05-26T19:02:33+00:00

in my application I’ve got three interfaces ICapture<T> , IDecoder<T, K> , and IBroadcaster<K>

  • 0

in my application I’ve got three interfaces ICapture<T>, IDecoder<T, K>, and IBroadcaster<K>.

Now I implement for example a VideoCapture class inheriting from Capture<IntPtr> (IntPtr is the raw data produced by the class). When data is generated by an object of VideoCapture, I firstly want to decode it from T to K, and then broadcast it.

What I want to know is: how would you chain this ? Simply by writing a method like

var data = videoCapture.GetData();
var decoded = decoder.Decode(data);
broadcaster.Broadcast(decoded);

Or are there any design patterns, that I could use? I know of the chain of responsibility pattern. I could imagine writing classes like CaptureHandler, DecoderHandler, and BroadcastHandler inheriting from HandlerBase. HandlerBase would provide mechanisms to hand over objects to the next handler.

var handler1 = new CaptureHandler();
var handler2 = new DecodeHandler();
handler1.SetNext(handler2);
handler1.Handle(object);

But I dunno if this is the best approach for my situation.

  • 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-26T19:02:34+00:00Added an answer on May 26, 2026 at 7:02 pm

    You could an instance of each object into the constructor of the next. If for example, every decoder instance needs a video capture instance to work, then you can have a constructor as follows …

    Decoder(VideoCapture<T> captureDevice)
    {
    }
    

    And do the same thing for the Broadcaster, i.e have a constructor that will take in a decoder instance as a parameter.

    In fact, I am not even sure you would need generics. You might do, depending on your application. We can only see a small part in this question after all. Not sure what Types you will be passing into each of these classes either and how the Type parameter will be used inside them.

    But if I was to hazard a guess, I think just normal OO hierarchy would be the best, simplest way to go.

    So, have a Capture base class, which has the virtual method GetData(). You will then create sub classes for different kinds of Capturing you do. “CapturePal”, “CaptureSecam”, “CaptureMeSecam” etc. Again, I am guess that sub classing would be enough for you rather than a generic Type parameter (would Capture<float>() as well as Capture<StringBuilder>() be meaningful in your application?)

    So once you have a base class and subclasses for your capture functionality, do the same for your Decoder and Broadcaster classes. Base class Decoder, sub class “DivxDecoder”, “MpegDecoder”. Base class Broadcaster with subclass “TVBroadcaster”, “IPBroadcaster”, “TCPBroadcaster” etc.

    Now, the constructors for each of the base classes will take the other base class as a parameter and call the appropriate methods.

    This will allow you to chain them as follows

    var myProcessingChain = new TVBroadcaster(new DivxDecoder (new CaptureSecam(inputData))));
    

    assuming that all the capture classes take the same input type.

    The other option is to use Interfaces. If your application has some classes that can act as both a capturer and a decoder for example.

    Think a bit more about whether you really need Generics. Generics are helpful when you want to reuse algorithms and want to be agnostic to the Type, while enforcing Type safety. Being agnostic to Type is different from being able to accept a set of Types that share a commonality. In this case you can get the commonality among the Types by using inheritance.

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

Sidebar

Related Questions

Application.Run(form); Actually I tried to call this from my project. I got this exception.
Application deals with strings that represent decimals that come from different cultures. For example
My application dynamically loads assemblies at runtime from specific subfolders. These assemblies are compiled
Application-Stack: Rails3, CanCan, Devise, Shoulda I've got some nested Resources and want to test
my application has the following structure: public class Transaction { public int TransactionID {
My application fetches information from an API. Unfortunately their data isn't very pretty. This
Application requests KML data through AJAX from server. This data is stored in javascript
Application.Run(new Main()); This line gives TypeInitializationException was unhandled after I switched from 3.5 to
// Application Drupal 7 // Problem Background My website imports product data from a
Application Settings.bundle contains a version number , which is automatically generated during build. From

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.