Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Extending Microsoft Dynamics 365 Finance and Supply Chain Management Cookbook

You're reading from   Extending Microsoft Dynamics 365 Finance and Supply Chain Management Cookbook Create and extend secure and scalable ERP solutions to improve business processes

Arrow left icon
Product type Paperback
Published in Mar 2020
Publisher Packt
ISBN-13 9781838643812
Length 534 pages
Edition 2nd Edition
Arrow right icon
Author (1):
Arrow left icon
Simon Buxton Simon Buxton
Author Profile Icon Simon Buxton
Simon Buxton
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Starting a New Project 2. Data Structures FREE CHAPTER 3. Creating the User Interface 4. Working with Form Logic and Frameworks 5. Application Extensibility 6. Writing for Extensibility 7. Advanced Data Handling 8. Business Events 9. Security 10. Data Management, OData, and Office 11. Consuming and Exposing Services 12. Unit Testing 13. Automated Build Management 14. Workflow Development 15. State Machines 16. Other Books You May Enjoy

Using the attribute framework to construct classes

In Chapter 4, Working with Form Logic and Frameworks, we wrote the ConVMSVehicleServiceTableType class. This had a method that determined whether or not the record can be edited. It used a CanEdit method, which in turn called a CanEditStatus method. There was nothing obviously wrong here, but what if our customer wanted to add a status? They could use Chain of Command, which is okay, but this also means we didn't design the solution to be extended in this way. There are two ways to structure the logic in this case:

  • Use a switch statement on the status
  • Write a class per status that is constructed based on the record's status

The latter option is used by SalesLineType. This is much simpler to read, especially when the code in each case is more than one line. It is also much easier to extend. The traditional way to write...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime