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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:41:03+00:00 2026-05-27T09:41:03+00:00

I am maintaining an ASP.NET MVC project. In the project the original developer has

  • 0

I am maintaining an ASP.NET MVC project. In the project the original developer has an absolute ton of interfaces. For example: IOrderService, IPaymentService, IEmailService, IResourceService. The thing I am confused about is each of these is only implemented by a single class. In other words:

OrderService : IOrderService
PaymentService : IPaymentService

My understanding of interfaces has always been that they are used to create an architecture in which components can be interchanged easily. Something like:

Square : IShape
Circle : IShape

Furthermore, I don’t understand how these are being created and used. Here is the OrderService:

public class OrderService : IOrderService
{
    private readonly ICommunicationService _communicationService;
    private readonly ILogger _logger;
    private readonly IRepository<Product> _productRepository;

    public OrderService(ICommunicationService communicationService, ILogger logger,
        IRepository<Product> productRepository)
    {
        _communicationService = communicationService;
        _logger = logger;
        _productRepository = productRepository;
    }
}

These objects don’t seem be ever be created directly as in OrderService orderService = new OrderService() it is always using the interface. I don’t understand why the interfaces are being used instead of the class implementing the interface, or how that even works. Is there something major that I am missing about interfaces that my google skills aren’t uncovering?

  • 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-27T09:41:03+00:00Added an answer on May 27, 2026 at 9:41 am

    This particular design pattern is typically to facilitate unit testing, as you can now replace OrderService with a TestOrderService, both of which are only referenced as IOrderService. This means you can write TestOrderService to provide specific behavior to a class under test, then sense whether the class under test is doing the correct things.

    In practice, the above is often accomplished by using a Mocking framework, so that you don’t actually hand-code a TestOrderService, but rather use a more concise syntax to describe how it should behave for a typical test, then have the mocking framework dynamically generate an implementation for you.

    As for why you never see ‘new OrderService’ in the code, it’s likely that your project is using some form of Inversion of Control container, which facilitates automatic Dependency Injection. In other words, you don’t have to construct OrderService directly, because somewhere you’ve configured that any use of IOrderService should automatically be fulfilled by constructing a singleton OrderService and passing it in to the constructor. There are a lot of subtleties here and I’m not exactly sure how your dependency injection is being accomplished (it doesn’t have to be automatic; you can also just construct the instances manually and pass them in through the constructors.)

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

Sidebar

Related Questions

I am working on maintaining a ASP.NET MVC application that has the following coding
I'm maintaining a multi-project solution in ASP.NET + C#. We've decided to upgrade to
I have an ASP.NET site that I am maintaining. Currently it has code that
We are working on an ASP.NET MVC 3 project and taking advantage of Razor
I've been working on an ASP.net MVC project that uses checkbox HTML Helpers in
I've been working on an ASP.NET MVC project for about 8 months now. For
Greetings folks, The ASP.NET application I'm maintaining has a fairly long start up procedure.
I am working on maintaining an ASP.NET website, and I've noticed the business layer
I have an old ASP.NET 1.1 site that I am maintaining. We are working
I am looking at an asp.net 2 web application that I am maintaining (but

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.