O'Reilly logo

Microsoft Dynamics NAV by Mark Brummel, Christopher Studebaker, David Studebaker, David Roys, Vjekoslav Babić, Cristina Nicolàs Lorente, Laura Nicolàs Lorente, Alex Chow

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Refactoring

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.

The new class members

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 new class members

The Codeunit is very clean and refactored.

The new function library

One of the functions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required