Extending Microsoft Dynamics 365 Finance and Supply Chain Management Cookbook - Second Edition
by Simon Buxton
How it works...
The first question that might be asked is why? We wrote five classes and an interface when a few lines of code in a switch statement was required and would have been much quicker to write.
The first reason is that switch statements are naturally hard to extend through extensibility. With this method, we can use Chain of Command on the classes and add a new status element very easily. We just add the new base enum element as usual, and then write the class to handle it. This is no code to change in the ConVMSVehicleServiceTableType class. The attribute pattern is designed to be extended by developers working on our package and those working for our customers in their own packages.
Another reason is that the status logic is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access