1

According to some information, IoC is a principle.

https://www.tutorialsteacher.com/ioc/introduction

But elsewhere it is a pattern.

What is Inversion of Control?

The Inversion of Control (IoC) and Dependency Injection (DI) patterns are all about removing dependencies from your code

Which one is right?

jaco0646
  • 15,303
  • 7
  • 59
  • 83
arif2018
  • 11
  • 3
  • 2
    The top-voted answer on the Stack Overflow question might simply not subscribe to the same definitions as the blog you are linking to, or might be using relaxed terminology. To my uninitiated eyes, I suppose a principle could also manifest as a pattern, and you could call that manifestation an example of the principle, at least informally. – tripleee Feb 22 '19 at 12:11
  • 2
    The terms may have [different definitions](https://stackoverflow.com/q/31317141/1371329), but don't expect people to use them consistently. – jaco0646 Feb 22 '19 at 14:46
  • https://code.replyfeed.com/ – arif2018 Mar 20 '19 at 12:36

1 Answers1

1

Principles are the guiding set and when principles are followed to solve problems patterns are evolved.

Principles and patterns are inseparable. Usually when we observe a large set of problem then we can see categories in which we can categorize the problems. Over a period of time software development community has seen many problems and also have observed categories. Such major categories are Object Creation, Behavior addition and modification, and structuring code to avoid messy classes. Now when people followed good principles to solve these problem, again it was observed that solutions follow a kind of pattern. Such patterns were grouped togather by famous GOF in a book.

IoC is a principle, many software implement the principle like Spring. IoC solves many code messups and maintainability issues. If someone calls it a pattern its not wrong to say so. There is not much gain in arguing if its a pattern or principle as Both are inseparable.

nits.kk
  • 5,204
  • 4
  • 33
  • 55