Learning Dynamics NAV Patterns - Marije Brummel - E-Book

Learning Dynamics NAV Patterns E-Book

Marije Brummel

0,0
28,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Microsoft Dynamics NAV is a complete ERP system, which also contains a robust set of development tools to support customization and enhancement. These include an object designer for each of the seven application object types, a business application-oriented programming language with .NET interface capability, a compiler, a debugger, and programming testing language support.
Learning Dynamics NAV Patterns will guide you through the NAV way of solving problems. This book will first introduce you to patterns and the software architecture of the NAV and then help you to build an example application. Then, it walks you through the details of architectural patterns, design patterns, and implementation patterns. This book will also talk about anti-patterns and handling legacy code. Finally, it teaches you to build solutions using patterns.
Proven patterns and best practices will help you create better solutions that are easy to maintain in larger teams across several locations. It will guide you through combining abstract patterns using easy-to-understand examples and will help you decide which patterns to use in which scenarios.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 189

Veröffentlichungsjahr: 2015

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Learning Dynamics NAV Patterns

Create solutions that are easy to maintain, are quick to upgrade, and follow proven concepts and design

Marije Brummel

BIRMINGHAM - MUMBAI

Learning Dynamics NAV Patterns

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: September 2015

Production reference: 2180722

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78528-419-9

www.packtpub.com

Credits

Author

Marije Brummel

Reviewers

Alex Chow

Luc Van Dyck

Alain Krikilion

Rakesh Raul

Daniel Rimmelzwaan

Bill Warnke

Commissioning Editor

Kunal Parikh

Acquisition Editor

Tushar Gupta

Content Development Editor

Priyanka Mehta

Technical Editor

Rohith Rajan

Copy Editor

Yesha Gangani

Project Coordinator

Izzat Contractor

Proofreader

Safis Editing

Indexer

Tejal Soni

Graphics

Sheetal Aute

Production Coordinator

Aparna Bhagat

Cover Work

Aparna Bhagat

Foreword

One of the many things that make Microsoft Dynamics NAV unique is that it is fully customizable and extendable. The ERP application, shipped by Microsoft as a part of NAV, is completely customizable and extendable using the traditional raw source code modification, or using the events as of Microsoft Dynamics NAV 2016. This makes the product extremely flexible and adored by the SMB market.

NAV has been built to focus on simplicity. It has been built with a strong belief that the application developer need not know all about the technical domain, like transaction isolation, advanced error recovery, database locks, memory allocations, and so on, but instead, should be able to unleash his or her domain skills. In short, write the happy path code and leave the rest to the NAV—no more, no less. I still believe that these principles hold their value and lately, we can add web-services, cloud, devices, and other new terms to the list of challenges that Microsoft Dynamics NAV handles behind the scenes almost like magic.

The application that is shipped with Microsoft Dynamics NAV has been designed by keeping simplicity and extendability in mind. The simple yet powerful syntax of the the application language, the ability to copy and paste parts of the application and reuse it in a different way, has always been a part of the Microsoft Dynamics NAV DNA. Although copying and pasting, from a purely engineering perspective, could be considered bad practice, it has proven itself very productive over the years.

Over a period of time, many Patterns that are found in today's application have evolved naturally. Many of them were first used in the character-based version, upgraded to the Windows client, and then later to the current three-tier architecture. While the adherence to and use of such Patterns is purely optional for developers, multiple reasons exist to follow the recommended Patterns and guidelines—the code will typically be easier to test and easier to upgrade, just to mention two.

By following some guidelines and principles, the sharing of application code in a large and growing community will also benefit tremendously. It might be as simple as consequent variable naming when writing code, or consistent naming of fields and tables when designing the data model.

I believe that small things like identifying recurring Patterns and assigning names to these can enhance communication, and create a common syntax between developers. It allows the community to discuss best practices, and improve and share design. This is very important, since downstream it allows the design of extensions that are easy to merge, have a lower maintenance cost, and allow easier implementation of additional changes.

Using common guidelines and best practices make it easier to work together and share code in an ecosystem that is dynamic and spans across the globe.

This is what makes Patterns unique and powerful—just like NAV itself.

Thomas Hejlsberg

Chief Architect

Microsoft Dynamics NAV

August 2015

About the Author

Marije Brummel - Author, Programmer, Consultant, Project Manager, Presenter, Evangelist, Sales person, and Trainer. She has been working for Partners, ISV’s, End Users, Master VARs, and Microsoft across the globe in more than 25 countries. It’s next to impossible to find someone as widely and deeply experienced as Marije in the Business Central community.

She received numerous awards including the Microsoft MVP award and the NAVUG All-Star. She was chair of the Dynamics Credentialling committee and authored the official Microsoft Exam materials. She did both onsite and online readiness sessions for Microsoft when the product went through major changes such as moving from two to three tier and the introduction of extensions.

Her biggest passion is changing the world for the better in every way possible. One of her biggest achievements was the introduction of Design Patterns into the Business Central community. She is the go-to-girl when it comes to performance troubleshooting and upgrade challenges. Technologies such as the Azure stack and Web frameworks don’t hold secrets in regards to Business Central. She wrote a number of books and countless blog articles and YouTube videos, which influenced almost every person and project involved with Business Central. At home, she enjoys the outdoors with her dog and tries to spend as much time as possible with her kids and family. She likes shopping and traveling.

Acknowledgement

This book is the result of working with Microsoft Dynamics NAV® for almost 20 years, and having had many discussions, debates, and even arguments with other people who are as passionate about the product as I am.

Being an early adopter of the software, I was very fortunate to be able to make many mistakes during my career and learn from them each time. Fundamental questions like variable naming, the user interface, and where to write the code, were all discussed many times, and have changed over the years.

Like many developers, I feel like a creative artist that needs to put his signature on his work. Unfortunately, this does not go well when writing solutions for Microsoft Dynamics NAV. When you adopt the style of the base application, you will find that collaboration becomes easier, and people will understand your efforts better than when you create your own style.

During the years that I have worked with the product, I've come to appreciate the structure of the base application. At a certain point in my career, I made an assumption that many of you might recognize. I started to treat what was done in the core product as "always correct".

In the past ten years, ever since I received my first MVP award, I have become closer to the development team and have been fascinated by the way the product was created and how issues are prioritized. I heard many stories from people who worked on the product in the early '90s, and started to realize that the core product is written by developers just like me and that many of the core components were acquired from partners who had their own development styles.

Over the years, I felt the core NAV product became "polluted", and the code was written in a less structured way, both by Microsoft and NAV partners. Between 2006 and 2010, my core business was performance troubleshooting and upgrades. The code that I saw during this period motivated me to write my first book about Application Design. This was my first effort to document the way Microsoft Dynamics NAV is designed, and how application areas work together.

Eric Wauters, who many of you know as Waldo, was a reviewer of this book, and his reaction was very positive. The book became mandatory reading for his team of developers and consultants. Together, we met Gary Winter at an event called Directions. I had worked with Gary many years before this, and remembered having conversations about designing components that can be reused. I had written a generic piece of software for weighing bridges, and I demonstrated this to him. After that event, Partner Ready Software was born—a think tank about Microsoft Dynamics NAV, trying to solve the bigger issues of life.

Design Patterns were first discussed at NAVTechDays. Many thanks to Luc Van Dyck for trusting the three of us, and giving us 90 minutes of presentation time without really knowing what we would do. At the same event, I also talked about tips and tricks for developers sharing ideas about variable naming and source control.

After NAVTechDays, we had the opportunity to present our ideas at MDCC in Denmark where our code product was being developed. The talks we had with Bardur Knudsen and Lars Hammer were inspiring. Lars was then working on DevBase, an internal prototype that we now know as the Delta file, using PowerShell.

With Partner Ready Software, we started to realize that we were reinventing the wheel. Many great minds had preceded us and the saying, "Great minds think alike" was spot on. As you will read in this book, we use many best practices from object-oriented programming, though C/AL is not object-oriented. We don't have inheritance or super classes, but with discipline and guidelines we can get very close.

Life became very interesting when the MVPs were introduced to a project that was happening internally at Microsoft. Apparently, the developers who were working on the core product were also asking questions about why things were done in a certain way, and if that way was good, why was it not documented? The Microsoft Design Patterns project was born, and I was first in line to participate.

The most that I learned about most in this project was how to define Patterns. How abstract should a Pattern be, and when does a Pattern become a functional description or a tip, or a "how do I" description?

I do believe that Patterns should be abstract. They relate very closely to the objects that we have in the product, and could be the properties of these objects and elements. The Patterns in this book have a hierarchy and dependencies.

I'd like to thank everyone in the Microsoft Design Patterns team for their efforts and hope that the project will continue for many years to come.

Special thanks to the two very important mentors that I've had in my professional career—David Studebaker and Michael Nielsen. Dave and his wife Karen are very special friends, and their knowledge and wisdom have been very important. Very often when I discuss an idea with Dave, he says things like, "Yes we did that in 1973 with Cobol." Michael has been my guardian angel at Microsoft for a decade. Being the most senior person on staff, it is very interesting to use him as a sounding board for ideas and vice versa.

I hope this book will inspire you, as it did me, to write software in a generic style that others will recognize and find easy to work with.

I'd also like to thank the reviewers as mentioned in the book, but also Dave Studebaker and Luc van Vugt, who unofficially helped me with this book. Also, thanks to Soren Klemmensen, Andrew Good, and Rick Williams for listening to me for many hours on Skype.

Last, but definitely not least, I want to thank my wife, Dionel, and my kids Josefien, Wesley, Saskia, and Daan. Thank you for allowing me to spend time writing these books, and travelling to the events where I can talk to others about this.

About the Reviewers

Alex Chow has been working with Microsoft Dynamics NAV, formerly Navision, since 1999. Over the years he has conducted hundreds of implementations across multiple industries. His customers range from $2 million-a-year small enterprises to $500 million-a-year multinational corporations.

Over the course of his Dynamics NAV career, Alex has often been designated as the primary person responsible for the success and failure of a Dynamics NAV implementation. The fact that he is still in the Dynamics NAV business means that he's been pretty lucky so far. His extensive career in the Dynamics NAV business is evidence of his success rate and expertise.

With his background in implementing all the functions and modules in and outside of Microsoft Dynamics NAV, Alex has encountered and resolved from the most practical to the most complex requirements and business rules. Through these experiences, he has learned that sometimes you have to be a little crazy to have a competitive edge.

Believing that sharing these experiences and knowledge would benefit the Dynamics NAV community, Alex writes about his journey at http://www.dynamicsnavconsultant.com/. He also founded AP Commerce, Inc. (http://www.apcommerce.com/) in 2005, which is a full service Dynamics NAV service center. In addition, he has written a book about Dynamics NAV titled Getting Started with Dynamics NAV 2013 Application Development, published by Packt Publishing

Alex lives in Southern California with his beautiful wife and two lovely daughters. He considers himself the luckiest man in the world.

Luc Van Dyck is active as a software consultant and works for a Belgian Microsoft partner. He started working with Microsoft Dynamics NAV in 1997 (at that time, it was called Navision Financials 1.10).

In 1999, he started the website http://mynavision.net/ to provide a forum and downloads for users of the Dynamics NAV ERP system. When Microsoft bought Navision Software A/S in 2002, the site was renamed http://mibuso.com/.

Mibuso is one of the largest online communities for Microsoft Dynamics professionals. This community gives users and the developers of products from the Microsoft Dynamics family (NAV, AX, CRM, and so on) a place to exchange ideas and tools, and to find business partners and products. The website provides a forum where you can ask questions about the different Dynamics products, and also contains a large selection of downloads. Microsoft partners can submit their company details to the Business Directory, and publish their add-ons or factsheets in the Product Directory.

Since 2011, Luc has organizes a two-day technical conference called NAV TechDays. This annual conference takes place in Antwerp (Belgium), and is targeted towards all Microsoft Dynamics NAV developers.

Alain Krikilion has been working with Dynamics NAV (formerly "Navision Financials", "Navision Attain", and "Microsoft Business Solutions Navision") since 1999, mostly solving technical problems in both small local projects and big international projects. Besides specializing in NAV, he also specializes in optimizing Microsoft SQL Server for Dynamics NAV.

He started working with NAV in rainy Belgium, and in June 2002 he moved to sunnier Italy. In April 2015, he moved to less sunny London.

Alain is also a moderator of the http://mibuso.com/ forum where, aside from moderating, he also helps to solve (mostly technical) problems. He also assists in the organization of the NAV Techdays event.

Alain Krikilion has been a Microsoft Dynamics NAV MVP (Most Valued Professional) since 2006.

Rakesh Raul is a Dynamics NAV consultant with more than 11 years of NAV and consulting experience. His 10 year journey with Microsoft Dynamics NAV includes more than 40 implementations—1 horizontal and 3 vertical solution designs and development.

Rakesh is also the author of another book in Packt's Dynamics NAV Series: Microsoft Dynamics NAV 7 Programming Cookbook, published by Packt Publishing. It is a collection of short, easy-to-read recipes or tutorials about writing the code for NAV.

Currently, Rakesh works in Cognatio Systems, Dubai-UAE, as a Team Lead. Cognatio Systems is a provider of Enterprise Solutions. The Microsoft Dynamics family for Enterprise Resource Planning (ERP) and CRM is the company's primary focus along with various other complementary products and solutions.

Daniel Rimmelzwaan was born and raised in The Netherlands, and moved to the USA at the end of 1999 to be with his new American wife. In Holland, he worked as a Microsoft Access and VBA developer. When looking for a job as a VB developer in the USA, he was introduced to Navision by a "VB Recruiter", and was intrigued by the simplicity of its development tools. He decided to accept the job offer to be a Navision Developer, with the firm intention of continuing to look for a "real" developer job.

More than 15 years later, with a couple of stints in the Microsoft partner channel and a few years as a freelancer, Daniel currently works as the chief quality officer for KCP Dynamics Group, an international partner servicing customers all over the world, and he is enjoying his career more than ever.

Ever since he started working with NAV, Daniel has been an active member of the online communities for NAV, such as http://mibuso.com/, http://dynamicsuser.net/, and the online forums managed by Microsoft. For his contributions to these online communities, he received his first of eleven consecutive Microsoft Most Valuable Professional Awards in July 2005, which was only the second year that the MVP Award was given out for NAV. The MVP Award is given out by Microsoft to the independent members of technology communities around the world, and recognizes people that share their knowledge with other members of the community.

Daniel lives with his wife and two kids in Arizona in the USA.

Bill Warnke has been working with Microsoft Dynamics NAV since 2006, when he was tasked with creating an integration between NAV and an existing mobile invoicing solution during an ERP migration. He was hooked on rapid development, all-in-one environment, and integration capabilities. Since then, he's worked exclusively with Dynamics NAV.

Currently, he works for ArcherPoint (http://www.archerpoint.com/) as a Dynamics NAV developer.

Bill has also worked as a reviewer for Getting Started with Dynamics NAV 2013 Application Development, published by Packt Publishing

He lives in Wisconsin with his wife, two young daughters, and his dog. You can read his blog at http://billwarnke.com/.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

Instant updates on new Packt books

Get notified! Find out when new books are published by following @PacktEnterprise on Twitter or the Packt Enterprise Facebook page.

Table of Contents

Preface

1

Introducing Dynamics NAV Patterns and Software Architecture

What do we mean by 'patterns'?

Software design patterns

The Procedural software design patterns

Microsoft Dynamics NAV Design Patterns

The object-oriented patterns

Non-object-oriented patterns

The functional oriented patterns

Patterns elements and hierarchy

Architectural patterns

Design patterns

Structuring code

The coding standards

Anti-patterns

Legacy code

Upgradability

Delta files

Repeatability

Lifecycle of a design pattern

Software architecture in Microsoft Dynamics NAV

Building blocks

Table

Page

Report

Codeunit

Query

XMLPort

MenuSuite

Metadata

Flowfields

Flowfilters

Base application

Functional processes

Summary

2

Architectural Patterns

The Singleton Pattern

Technical description

Company-Initialize

Implementations

Enhancements

The Supplemental and Subsidiary Pattern

Technical description

Implementations

The Compound Pattern

Technical description

The Rules Pattern

Technical description

Implementations

Examples

The Master Data Pattern

Technical description

Implementations

Examples

The Journal Template-Batch-Line Pattern

Technical description

Implementations

Examples

The Entry Pattern

Technical description

The Entry Table types

Entries that can be deleted

Implementations

Examples

Document Pattern

Technical description

Implementations

Examples

The Argument table

Technical description

Implementations

Summary

3

Design Patterns

The Entity State Pattern

Technical description

Setting the State

Testing the State

Implementations

Examples

The Select Pattern

Technical description

Implementations

The Number Series Pattern

Technical description

Implementations

Examples

Address Integration Pattern

Technical description

Copying the address

Implementations

Examples

Multi-Level Setup

Technical description

Implementations

Examples

Document History

Technical description

Implementations

Examples

Copy Document Pattern

Technical description

Implementations

Examples

Job Queue Entry Pattern

Technical description

Implementations

Dismissible dialogs and save preferences

Technical description

Implementations

Setup Update Pattern

Technical description

Implementations

Example

Model-View ViewModel Pattern

Technical description

Implementations

Examples

Summary

4

Building an Example Application Using Patterns

The design elements

The Pattern dependencies

Step one – Foundation

Example setup

Which Patterns to use

The implementation

The Multi-Level Setup Pattern

Step two – Master Data

Example Person

The Example Product

Number Series

Entity State

Implementing the Address Integration Pattern

Step three – Journals & Entries

Creating your own Journal and Entry

Validation in Journals

Step four – Documents

Implementing a Document

Document history

Selecting a Pattern

Other Patterns

Posting

The layered model

Summary

5

Coding Best Practices

Coding guidelines

Code design

Code readability

Class-Method-Property

The Table as a class

A Codeunit as a method

Function libraries and interfaces

Natural Language Programming

Pitfalls

Bonus – debugging

Encapsulation

Override Functions

Façade

Hooks

Disabling the original source code

Predefined hooks

Variant variables

Managing DLL

Summary

6

Anti-patterns and Handling Legacy Code

Anti-patterns

Code cloning

Boat anchors

Other anti-patterns and context

Programming language capabilities

Legacy code

Refactoring the C/AL Code

Refactoring tables

Code refactoring

The boy scout rule

Summary

7

Building Solutions Using Patterns

Building blocks

Applying Architectural Patterns

Creating the Table objects

Applying Design Patterns

The Bed and Breakfast setup

Bed and Breakfast season

Bed and Breakfast room

Bed and Breakfast price

Bed and Breakfast clean entry

Bed and Breakfast stay

Bed and Breakfast journal and entry

The Bed and Breakfast evaluation header and evaluation line

Defining the methods

Writing the Code and Link methods

Creating the cleaning entries

Refactoring

The new class members

The new function library

Room members

The room price calculation

Testing the application

Test isolation

Analyzing the results

Upgrading the application

Creating a Delta file

The steps of creating a Delta file

Inside the Delta file

Building our application

Building the result