Category Archives: NAV Architecture, Patterns & Code

Design Patterns are common solutions best practices to solve problems. This is a well known concept in computer programming and can therefore be applied to Microsoft Dynamics NAV as well.

NAV2016 | My first extension (UPDATED) | NAVUG Summit

UPDATE: Download the files and script from the new Mibuso

This blog is written from Reno Nevada where the folks from the NAVUG content committee asked me to talk about how to integrate add-ons with NAV. This session was intented to inspire people to think about alternative approaches to the traditional raw source code modification.

Part of the session was about Web Services and the new Eventing framework. I also wanted to show how the new extensions allow you to enhance NAV without customisations. Hence I had to figure out how this works.

Step 1 – Create the Delta

The first step is to have Delta files that are within the limitations of the extension framework. These are New tables, Pages and Codeunits and adding fields to tables and pages.

Reports, XMLPorts and Query objects are not supported.

Delta

Once we have the delta files we need aditional PowerShell

Step 2 – Manifest

The extension needs an XML file that tells us what the version of our extension is, the name and the publisher.

The easiest way to have that is to create it with PowerShell

Manifest

The XML looks like this

Manifest2

Step 3 – Create NAVX File

NAVx

That is how easy it is to create an extension.

Step 4 – Publish the Extension

Now we need a new clean database to use it in. So in PowerShell we move to a new service tier.

Publish

This makes the extension available in our database, but it is not activated

Step 5 – Install

The last step is to install the extension.

Install

Done!

Now the extension is available in our database.

You can hopefully download this example from the new Mibuso website soon.

Here are the commands for copy/paste

New-NAVAppManifest -Name “NAVUG Summit” -Publisher “Mark Brummel” -Version “1.0.0.0” |

New-NAVAppManifestFile -Path “C:\Users\marq\Documents\DynamicsExt90\Manifest.xml”

Get-NAVAppManifest -Path “C:\Users\marq\Documents\DynamicsExt90\Manifest.xml” |

New-NAVAppPackage -Path “C:\Users\marq\Documents\DynamicsExt90\NAVUG.navx”

-SourcePath “C:\Users\marq\Documents\DynamicsExt90\Delta\”

Publish-NAVApp -ServerInstance Clean2016 -Path “C:\Users\marq\Documents\DynamicsExt90\NAVUG.navx”

Install-NAVApp -ServerInstance Clean2016 -Name “NAVUG Summit” –Version 1.0.0.0

UPDATE

The orriginal post was created with NAV 2016 RTM. Microsoft has now made an upgrade codeunit mandatory. Read here.

ANNOUNCING: New Book | Learning Dynamics NAV Patterns

Since Packt Publishing put it on their website, I might as well reveal a secret project I’ve been working on for the last couple of months, almost a year.

My new book Learning Dynamics NAV Patterns is about to be released. I am in the final stages of processing reviews.

Learning Dynamics NAV Patterns

You can order the book here.

The book is a written version of the Master Class for Application Architecture and Patterns I am currently teaching accross the globe and contains a lot of information about the Dynamics NAV DNA in a structured, easy to follow way. Things that have been in the product, some 30 years, some only one or two releases.

It also contains coding best practices, anti-patterns and refactoring methodologies and finaly a real world example of how to apply patterns while architecting a solution, working with Delta files and using Visual Studio Online to host your IP in the cloud.

The book is a more abstract and technical version of my first book Microsoft Dynamics NAV 2013 Application Design. All the things I learned from being part of the Design Patterns project and Partner Ready Software have been applied to this hands on bundled work. I would like to thank all other members from the teams for their inspiration during the meetings and brainstorm sessions and I hope they enjoy the way the efforts are combined and for everyone to grab although the book is my view and solely my opinion on the matter. The book would have also been worse without the reviewers. One in particular who shall remain anonimous had a big impact on the final version.

I’ve also read countless articles about clean code, object orriented programming and design patterns. I can’t mention them all but I would like to thank everyone for sharing their views and vision with the world.

Please (pre) order the book and enjoy.

Mark Brummel

cropped-navskills1.png

Toronto Master Class Application Architecture & Design Patterns

On March 23 and 24, the first Master Class for Microsoft Dynamics NAV Application Architecture and Design Patterns was held in Toronto.

Thirteen students attended. This what they had to say:

“I think this should be a mandatory class… developers who have the knowledge of design patterns and common coding practices inherently develop stronger, cleaner code.” ~ Michael Hollinger, Harbor Wholesale Foods

“An awesome course that covers the best practices of NAV development and application architecture.” ~ Sukeev Kailayapathy, Second Foundation

The workshop will be scheduled twice per year in Toronto (or on demand if enough students register). Your teacher will be Floyd Chan.

Toronto - Class of 2014; design patterns; master class; Dynamics NAV
Toronto – Class of 2015

The workshop is scheduled for the following locations this year.

When Where Who
May The Netherlands Luc van Vugt, Mark Brummel
May Belgium Steven Renders, Mark Brummel
June Iceland Gunnar Gestsson, Mark Brummel
June Japan (Closed Partner Training)
June Romania (Closed Partner Training)
October United States (NAVUG, Reno) Mark Brummel
October Online NAVUG Academy Mike Doster
November Online NAVUG Academy Mike Doster

Master Class – Application Architecture & Design Patterns

During the workshop, we will reveal all the secrets that are hidden in the Dynamics NAV Source Code. You will get answers to questions like…

  • How is Dynamics NAV Architected and how do the modules communicate
  • What are Design Patterns and Anti Patterns and how do they apply to Dynamics NAV
  • How can I avoid conflicts during my object merge
  • What impact do monthly rollups have to my roadmap and release strategy
  • Can the new Delta Files help me get more organized
  • Why does Dynamics NAV have so much Code Cloning
  • Are the coding standard documented and how can apply them
  • Can I implement Object Oriented concepts such as MVVM, overloading and reflection
  • How do I organize my object structure
  • Best Practices such as Encapsulation and Natural Language Programming
  • Be familiar with over 30 most used Design Patterns in Dynamics NAV
  • What does a perfect UI look like to be repeatable in the cloud
  • Understand the impact of Meta Data on Software Design
  • What is the difference between Reservation Entries, G/L Entries and Interaction Log Entries

Course Outline

The course has four, iterative blocks that explain the elements for good software architecture using Design Patterns – Repeatable User Interface, Coding Guidelines, Architectural Principles and Exercises.

Introduction

  • Introduction to Application Architecture
  • Rollup update & Upgrade Strategies
  • Design Patterns & Anti Patterns
  • Meta Data Driven Software Development

Object Architecture

  • Define Object Hierarchy
  • Enhance the use of the Symbol Menu
  • Interfaces
  • Function Libraries
  • Natural Language Programming
  • Encapsulation
  • Arguments & Overloading
  • Façade & Hooks

Coding Guidelines

  • Design
  • Internationalization
  • Localizability
  • Readability
  • Data Dictionary
  • Hungarian Notation
  • User Interface
Design Patterns

  • Singleton, Multi Level Setup & Rules Pattern
  • Master Data, Entity State & Compound
  • Documents, Copy, Posting & Archiving
  • Test Near, Test Far, Do It, Clean Up

Code Cloning

  • Fundamentals
  • Transaction Mirroring
  • Forking, Templating, Customize & Exact Match

Modern UI for Repeatable Software

  • Instructions in the User Interface
  • Transaction Data Update
  • Hiding Fields & Fast tabs
  • Totals on Sub Pages
  • Create Data from Templates

Model View View Model

  • Working with Temporary Tables
  • MVVM Pages
  • Reports based on data in memory
  • Query data on Pages

We’re back to be found | Dynamics NAV Community

Oh my, I was almost ready to blog about it. We were completely lost!

“What do you mean?”, I hear you say.

Dynamics NAV is, as far as I know, the only product on the community website with a Wiki and with one of the last updates, we were gone missing.

Fortunately we are back and on a really nice place.

Wiki

Thanks Bogdana and Dustin for this nice spot.

Remember, the wiki is a community project. If you want to contribute, don’t hesitate to sign up!

http://community.dynamics.com/nav/w/designpatterns/default.aspx

Design Patterns YouTube Playlist | 30 Videos

With the recovery of a lost video at Microsoft, the Design Patterns YouTube PlayList has 30 Videos now.

23 of these videos are part of the How Do I series and co-sponsored by Microsoft. 7 videos are created by me.

You can find the PlayList on my YouTube channel: Here is the link:

https://www.youtube.com/user/brummelds

Until a year ago I was unfamiliar with YouTube and video making but it is surprisingly easy to do and sends out a very clear message.

The playlist includes an hour long introduction to the concept of Design Patterns

Workshops (Advertisement)

If you want to learn more about how Design Patterns can help you improve development of Dynamics NAV in your company we have started a series of workshops together with regional MCT’s.

The first region we host is North America. On March 19th and 20th we do Atlanta with Mike Doster and on March 23rd and 24th we do Toronto with Floyd Chan.

Next up will be Europe with probably Belgium, The Netherlands, UK and Austria. I am still looking for an MCT in the UK to work together with.

Quiz: Can you see the difference between these two images?

ThinkNAVAttlantaThinkNAVToronto

[PRS] Design Patterns that should be [made] obsolete [by Microsoft]

Yes, this blog has a double title. Every now and then you need to do a little self reflection. Two weeks ago I was in talking with my fellow PRS member Soren Klemmensen and we discussed the fact that in the list of object oriented Design Patterns that we brought to Dynamics NAV there are a few that could be built in or better integrated if Microsoft would help us a little.

Ok, if you read this and think, what does this guy mean, then I should tell you some background first, otherwise just skip this part.

For the last 4 or 5 years ago we have been working on the Design Patterns project. Next to documenting the existing patterns with Microsoft we also tried to look at some best practices to better code in Dynamics NAV. They are also design patterns, categoriesed as implementation patterns, meaning the way you structure code.

Examples of these patterns are:

  • Class, Method, Property (aka Agents/Actions)
  • Natural Language Programming
  • Encapsulation
  • Facade
  • Hooks
  • Interfaces
  • Surrogate Keys

You can learn more about these patterns on my YouTube channel.

While most of these patterns have nice names now, we actually changed them quite a number of times. Natural Language Programming was once called Readable Code and Encapsulation was called Atomic Coding. The Class, Method Property has two names as well. Reason for this is that we learned during the project that most of these concepts are well known in computer science and object oriented programming. We were reinventing wheels.

Dynamics NAV has a realtively basic development environment that does not allow us to do things that Visual Studio and C# or other languages do. On the other hand it has lots of things that C# does not have that we can take advantage of.

This can come in handy when trying to make a couple of these PRS design patterns obsolete, smarter or built in the environment. One of the reasons we can do this is becuase C/AL and C/SIDE are very metadata driven.

So what patterns can be made obsolete

Class Method Property (aka Agents/Actions)

This pattern teaches us to make all functions that you can perform on a table a member of the table and if complex enough put inside their own codeunit.

The reason why we thought of that is actually a bug in the symbol menu. The symbol menu does not understand code outside the contect of the variable you define. For example: if you define a variable of the type Sales Header, it does not show that we have a codeunit that takes this record as a parameter and posts it.

If that would be the case, we would probably have to rethink this pattern. I have implemented this pattern at one of my solutions where we have a table that is more or less the core of an application. This table now had douzens and douzens of functions. I can honestly say that this does not improve usabilty more than loosely coupling the codeunits to tables.

It would be easier if NAV reads the metadata and helps with the symbol menu. That would save a lot of functions on the table that are then obsolete and actually a hassle to maintain.

Facade

This was the example I thought about yesterday when I did an introduction to design patterns workshop for NAVUG USA. I was talking about encapsulation and override. Most languages allow programmers to override functions in a class. NAV does not.

With PRS we found Facade as a solution for that, but it is actually wrong to suggest to implement a facade for each function you create on the table. Think about it. You would dramatically make your code more complex than required.

Facade is a great pattern! It exists in object oriented world and it should be implemented by design if the architect expects functional requirements to override the function. The typycal example is weighing bridges where every customer has their own hardware and has a custom interface. This is what facade does great.

C/AL should allow programmers to override any other function at design when required without the orriginal architect anticipating every move. Other programming languages allow that.

Surrogate Keys

This is the newest member of the PRS design patterns and as most other patterns it started its life with another name. Unique Record Identifier.

In dynamics NAV most tables are connected through the primairy key, for example comments. Comment tables have complex primary keys to be able to connect them to each table in NAV.

The idea is to add a single unique key to each table in NAV so we can connect to other tables using a single unique key. Think about the possibilities to add factboxes using this to each table in NAV without thinking.

C/SIDE can add this automatically for us.

Conclusion

Some design patterns can be improved with what I think are relatively small changes to C/Side. We should always self reflect and realise that some things we do are actually workarounds.

Microsoft Convergence Atlanta 2015 | My Sessions & Workshops

Convergence 2This year in Atlanta I will be attending Convergence for the first time in many years. I am really looking forward to go back to this great event.

I am also speaking at two sessions for this event as part of the sessions delivered by NAVUG.

Ask your peers: Reporting with Microsoft Dynamics NAV and Word – really!

Would you like to get up-to-speed on Microsoft Word reporting for Microsoft Dynamics NAV 2015? In this session, we’ll discuss the user-friendly and powerful setup options, layout and formatting possibilities, and report scheduling and notifications. We’ll also show you the exciting Jet Add-in that greatly simplifies using the dataset from Microsoft Dynamics NAV. After spending a little time with us, you’ll be ready to do it yourself! This session is presented by NAVUG/MVPs.

Ask your peers: Upgrading Microsoft Dynamics NAV – myths and facts

When upgrading to the latest and greatest, everyone is faced with challenges. You are not alone! How do I determine budget? Am I dependent on vendors? Will there be downtime? What about existing hardware and peripherals? Do I need to upgrade SQL Server? What about Microsoft Azure vs. on-premise? We’ll separate the myths and facts so you can proceed intelligently, and we’ll prepare you for questions to ask your partner to help you upgrade effectively. This session is presented by NAVUG/MVPs.

Design Patterns Worskhop

Are you visiting Convergence and curious about learning more about Design Patterns? Together with Mike Doster, Lead MCT, I am hosting a workshop in Atlanta the same week as convergence. On March 19th and 20th you can learn everything about design patterns and programming best practices in NAV.

The price of the workshop is 580 USD. You can register via this website. You can also use the contact form on this blog.

Here is a short intro video to the Design Patterns

See you in Atlanta!

Convergence 1

Design Patterns on Partner Source now!

We already have Design Patterns on YouTube, MSDN, Wiki and MiBuSo.

Now we can add Partner Source to that list. Microsoft has asked me to create an overview page and introduction video to the subject.

You can find the page here. (If you have access to Partner Source).

The introduction video has also been uploaded to my YouTube channel, where you can find a link to all Design Patterns videos, including the ones I’ve created about the Implementation Patterns.

C/AL Coding Guidelines | NAV2015

As long as I work with Dynamics NAV as a developer, coding guidelines have always been a point of arguments.

Long, long time ago they were published by Navision as part of the development training materials and documentation.

I know most partners have their own rules and standards, and Microsoft have them too.

They are published

The good news is that they are now updated and published by Microsoft!

You can find them on the Dynamics Community website. Here.

As part of the “How Do I” video series for Design Patterns in Microsoft Dynamics NAV I have also recorded a video.

Cyclomatic Complexity

One of the things I like most about the guidelines is Cyclomatic Complexity. This is a well known concept in computer programming and is now mapped for Dynamics NAV.

More information you can find here and here.

Implementation Patterns

While you are implementing these guidelines in your organization, remember to have a look at these implementation patterns. They are great to use and have a big return on investment.

Implementation Pattern #1 | Classes, Methods and Properies

Implementation Pattern #2 | Natural Language Programming

Implementation Pattern #3 | Encapsulation

Introduction to Design Patterns and Upgradable Code | Free Webinar

For the NAVUG Summit in St. Louis 2014 I did a presentation called Introduction to Design Patterns and Upgradable Code“. This presentation was very well received with top ratings. Therefor NAVUG have asked me to repeat the presentation in a webinar which is free for anyone to attend.

The Webinar is on January 27th from 21:00 to 22:00 CET (Europe) and 3:00 PM – 4:00 PM EST (US)

Here is the link

The session will be recorded too.

NAVUG_New-1_sm