-
Book Overview & Buying
-
Table Of Contents
Learning Dynamics NAV Patterns
By :
If we read the code that we have just written, we can immediately start cleaning the code, and then start refactoring it.
Let's browse through the functions one by one, see how we can refactor, and see what the result looks like.
Quite a number of functions can be the members of a class or the table. We can add the function called OccupiedOrHasNotBeenCleanedForAWeek, CreateCleaningEntryForRoom, FindLastCleaningDate, and CreateCleaningEntryForRoom as members of the Room table.
If we do this, our Codeunit will look like the following:
The Codeunit is very clean and refactored.
One of the functions cannot be moved as a member of the Room table. The LastWeek function is a generic function.
Let's create a new function library and call it the Bed and Breakfast function, as shown here:
The Room table now has three members that can...
Change the font size
Change margin width
Change background colour