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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:08:23+00:00 2026-05-12T08:08:23+00:00

I have a method returning an ISomething . I am trying to use Inversion

  • 0

I have a method returning an ISomething. I am trying to use Inversion of Control throughout my program… but I have no idea how to do it when it comes to the return value – I cannot pass it to the method, or to the object when constructing it, because this method is supposed to create the object.

The only solution I see is to pass an ISomething factory (Func<ISomething>) to the object when constructing it. Is this the usual / correct solution or is something else recommended?

[Edit] Weird – nobody else had this problem? I mean, there’s no up- (or even down-) voting…

[Edit] More details: the method is supposed to import an IExcel into an ITable. The consensus below seems to be that I should think of this method as a converter, transforming an IExcel into an ITable, thus receiving both as arguments instead of returning the ITable value. I’ll leave this up for one more day and then go with one of the responses if nothing new shows up.

  • 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-12T08:08:23+00:00Added an answer on May 12, 2026 at 8:08 am

    Is your method supposed to be constructing the ISomething, or setting it’s state and returning an ISomething with state initialized? (or does this need to be one operation?)

    If your class has a method that is responsible for creating an ISomething, then it is an ISomethingFactory (unless you have mixed concerns). In that case, it has the logic to choose the correct ISomething implementation and create it, so you shouldn’t worry too much about the IoC aspect.

    However, if this class’s concern is not creating the appropriate ISomething, then I would probably pass a factory in. The issue is, that in most cases your DI container should be able to do this for you (call a factory to get the appropriate ISomething), so seeing a method that must create an ISomething that is not a factory makes me nervous.

    Trying to give architectural guidance is always tough in a forum like this though – but with the limited input there I’d say either you have a factory that you didn’t know was a factory, or you have a problem.

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

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is already a valid date - ISO-8601 format -… May 12, 2026 at 12:29 pm
  • Editorial Team
    Editorial Team added an answer The note under "Remarks" on the InvokeMember page indicates that… May 12, 2026 at 12:29 pm
  • Editorial Team
    Editorial Team added an answer In [1]: from PyQt4 import QtCore In [2]: s =… May 12, 2026 at 12:29 pm

Related Questions

I'm having some issues with a bit of LINQ syntax and I believe I'm
If I understand correctly, in rest style, every query (that is, every action on
I'm the lead dev for Bitfighter , and am adding user-scripted bots using Lua.
With reference to this programming game I am currently building. I have a Class
I have several lines of a method that I would like to ensure that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.