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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:20:41+00:00 2026-06-09T10:20:41+00:00

Situation: I’m looking to create a framework in which I will crunch data. The

  • 0

Situation:

I’m looking to create a framework in which I will crunch data. The output of the data crunch will be a string (which I need for the bulk of my program). I will be consuming Data Crunchers made by other people.

I have an interface that looks like this:

public interface IDataCruncher {
    string Execute( ICruncherInput input );
}

The Problem:

Since each DataCruncher will perform differently and requires different inputs, I have resorted to passing the information in as dictionary<string, object>, however the packing/unpacking process is tedious to implement and is not compile safe for packing up the material (you could misspell a dictionary key, or forget one, causing the data cruncher to crash).

public interface ICruncherInput {
    Dictionary<string, object> Data { get; }
}

The Question:

Is it possible to pass data to the Data Cruncher implementation with compile time safety, or at least stronger safety than casting from objects?

Is there a way to define these key contracts in the code? (As opposed to assuming the dictionary will contain the keys I need, and defining the keys in a document outside of the code)

  • 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-09T10:20:43+00:00Added an answer on June 9, 2026 at 10:20 am

    I common way to pass data to a class, is to pass it to the constructor. Since the constructor is not part of the interface, different classes implementing the same interface can have different constructor signatures.

    But of cause it works only, if you are not instantiating the class through the default constructor.

    IDataCruncher cruncher1 = new DataCruncherA(x, y, z);
    IDataCruncher cruncher2 = new ExcelDataCruncher(pathOfExcelFile);
    IDataCruncher cruncher3 = new SampleDataCruncher();
    

    And of cause it is fully type-safe and will not compile if the wrong parameters are passed.

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

Sidebar

Related Questions

Situation: I am writing a program to solve for primes. I need to solve
Situation: Have a UITextField instance which is a subview of a UIScrollView. Need: Screen
Situation: need to find which layer the user has touched. Problem: Apple says we
Situation: I have an index page which loads pages into it with ajax as
Situation is simple. I need to wrap text around two inline objects (buttons with
Situation: I want to provide a website service where users can enter some data
Situation: I am writing a program in C that maintains a number of threads.
Situation I'm implementing a Listener for PHPUnit that will record test results to a
Situation: typedef int TypeA; typedef int TypeB; I need to make TypeA incompatible with
Situation: I have a sendersocket which is bound to localhost UDP port 33100. I

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.