There's more...

When extending Dynamics 365, don't be afraid of using industry best practices to enhance your code. Whether you are extending the platform using .NET code, JavaScript, or any other means, code quality rules apply. This recipe covers a basic refactoring example. You can further enhance your code to suit your scenario.

For example, if you have a few plugins that do more or less the same thing with some minor differences (for example, case management automation with different case types), you can create a class hierarchy of business logic with a business layer factory class to choose and instantiate the appropriate class.

The Dynamics 365 Developer Toolkit contains a default abstract PluginBase that can also be used in lieu of the one mentioned in this recipe.

Another common example is the usage of interfaces for entities. When entities are generated using CrmSvcUtil, all classes are created as partial classes (you can create a separate C# partial class to augment these classes). In the Modeling normalized entities using two different entities recipe from Chapter 1, No Code Extensions, we ended up with redundant attributes between the two entity types. If your business logic deals with only the common attributes, you can create a common interface between those entities and rely on polymorphism to pass any of the two to your business logic.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.89.24