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

The Archive Base Latest Questions

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

How is strategy pattern is different then dependency injection? ie below is what you

  • 0

How is strategy pattern is different then dependency injection?

ie below is what you can do with Strategy pattern:

class Foo{
   private readonly ISortAlgo _sortAlgo;

  public Foo(ISortAlgo sortAlgo)
  {
     _sortAlgo = sortAlgo;
  }

  public void Sort()
  {
    _sortAlgo.sort();
  }

}

with DI you can do the same, essentially you can have constructor, setter, interface etc. injection. and it would give the same effect as Strategy pattern. I am aware that DI is also set of other principles, such as loose coupling, testability, wiring etc.

In terms of implementation i dont see much difference.

what s the difference between strategy pattern and DI?

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

    First, dependency injection has not only constructor injection as method to inject, but also property, method injection and ambient context.

    Second, stategy defines behaviour, so client could select special one that matches on his needs. While dependency injection works with abstraction of external dependencies.

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

Sidebar

Related Questions

I have the following Strategy Pattern implemented: public abstract class RetrievalStrategy { public abstract
Strategy pattern and Dependency Injection both allow us to set / inject objects at
I'm using the strategy pattern to parse files of different formats. Each strategy returns
When implementing the Strategy Pattern, where does one put the code that determines which
My question is I wanna apply strategy pattern to save log from Image above
I want to create a class that can use one of four algorithms (and
In my understanding the strategy pattern is used to make behaviour interchangable. This involves
Sometimes when using the strategy pattern I find some of the algorithm implementations do
When would the Strategy Pattern be used? I see client code snippets like this:
I am basically trying to implement a Strategy pattern, but I want to pass

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.