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.
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.