Sunday, March 14, 2021

ExtensionOf versus extends

 "extends" is about inheritance in the usual object-oriented way. You create a new class inheriting from the base class and you can use it anywhere where you can use the parent class. For example, if a method accepts a parameter of type BaseClass, you can put there an object of ChildClass (if ChildClass extends BaseClass). But you can't change anything in BaseClass itself; you can merely add things or redefine existing methods in BaseClass.

Unlike inheritance, ExtensionOf is something completely specific to Dynamics 365 for Finance and Operations. Although you can't physically change BaseClass (because it's typically in a completely different DLL), class extension allow you to pretend that you added things like methods to BaseClass. Note that you won't be using a new type like with inheritance. Instead of adding things to ChildClass, you add them directly to BaseClass and instances of BaseClass will get the new methods, fields etc.

Inheritance didn't get deprecated by any mean; class extensions solve a different problem. They allow you to add capabilities even to classes where you don't control instantiation (= you can't use ChildClass instead of BaseClass) because the application wasn't designed for extensibility.





Source:

ExtensionOf versus extends - Dynamics 365 Finance Forum Community Forum

No comments:

Post a Comment

How get primary email of customer or vendor

Below code is for customer only, for vendor we need to replace  CustTable  with VendTable.   dirPartyContactInfoView        dirPartyContactI...