Dependency Injection Breaks Encapsulation

Me. It doesn’t serve a single responsibility, it serves multiple, which is by definition is a god object. I also object to him classifying it as an “abstract class”. I write abstract classes daily, that is not an abstract class. It is a base class that gets inherited by all other classes to provide various low level operations – it isn’t defining what implementations are permitted, it is defining the actual implementation and you’d have to override anything you don’t want (or want to work differently).

Abstract Class definition:

  • An abstract class cannot be instantiated.
  • An abstract class may contain abstract methods and accessors.
  • It is not possible to modify an abstract class with the sealed (C# Reference) modifier because the two modifers have opposite meanings. The sealed modifier prevents a class from being inherited and the abstract modifier requires a class to be inherited.
  • A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
2 Likes