You are previewing Learning Dynamics NAV Patterns.
O'Reilly logo
Learning Dynamics NAV Patterns

Book Description

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

About This Book

  • Design software that is maintainable outside the ecosystem of their creators

  • Ensure quality by following patterns that have been proved to work

  • Over two dozen practical Architectural and Design patterns

  • Who This Book Is For

    Learning Dynamics NAV Patterns is intended for developers, architects, (technical) consultants, and application managers. You may have very little or no knowledge about NAV patterns, but you should be acquainted with programming.

    What You Will Learn

  • Apply object-oriented practices to C/AL programming

  • Structure your application to avoid merge conflicts

  • Refactor legacy code and avoid anti-patterns

  • Design decision trees to decide when to use which patterns

  • Clone codes and their application in Dynamics NAV

  • Make your application extensible by creating predefined hooks and facades

  • In Detail

    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.

    Style and approach

    This book explains the concepts of patterns, code structuring, and object-oriented concepts in a way that is easy to understand for Dynamics NAV specialists through practical examples.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Learning Dynamics NAV Patterns
      1. Table of Contents
      2. Learning Dynamics NAV Patterns
      3. Credits
      4. Foreword
      5. About the Author
      6. Acknowledgement
      7. About the Reviewers
      8. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
          3. Instant updates on new Packt books
      9. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      10. 1. Introducing Dynamics NAV Patterns and Software Architecture
        1. What do we mean by 'patterns'?
          1. Software design patterns
          2. The Procedural software design patterns
        2. Microsoft Dynamics NAV Design Patterns
          1. The object-oriented patterns
          2. Non-object-oriented patterns
          3. The functional oriented patterns
        3. Patterns elements and hierarchy
          1. Architectural patterns
          2. Design patterns
          3. Structuring code
          4. The coding standards
          5. Anti-patterns
            1. Code cloning
          6. Legacy code
          7. Upgradability
            1. The upgrade frequency
            2. Design patterns and upgrades
          8. Delta files
          9. Repeatability
            1. Design patterns and repeatability
          10. Lifecycle of a design pattern
            1. Technology changes
            2. Old habits die hard
            3. New design patterns
          11. Software architecture in Microsoft Dynamics NAV
            1. Metadata
        4. Building blocks
          1. Table
          2. Page
          3. Report
          4. Codeunit
          5. Query
          6. XMLPort
          7. MenuSuite
        5. Metadata
          1. Flowfields
          2. Flowfilters
        6. Base application
          1. Functional processes
        7. Summary
      11. 2. Architectural Patterns
        1. The Singleton Pattern
          1. Technical description
          2. Company-Initialize
          3. Implementations
            1. Examples
          4. Enhancements
        2. The Supplemental and Subsidiary Pattern
          1. Technical description
          2. Implementations
            1. Examples
        3. The Compound Pattern
          1. Technical description
            1. Implementation
            2. Examples
        4. The Rules Pattern
          1. Technical description
          2. Implementations
          3. Examples
        5. The Master Data Pattern
          1. Technical description
          2. Implementations
          3. Examples
        6. The Journal Template-Batch-Line Pattern
          1. Technical description
            1. The Journal Template table
            2. The Journal Batch table
            3. The Journal Line table
              1. Recurring Journals
              2. Pages
            4. Codeunits
          2. Implementations
            1. Hierarchy
            2. Journals as contracts
          3. Examples
        7. The Entry Pattern
          1. Technical description
          2. The Entry Table types
            1. Historical entries
            2. Temporary entries
          3. Entries that can be deleted
            1. Temporary tracking buckets
          4. Implementations
          5. Examples
        8. Document Pattern
          1. Technical description
            1. The Header table
            2. The Line table
            3. Posting and archiving
          2. Implementations
          3. Examples
        9. The Argument table
          1. Technical description
          2. Implementations
        10. Summary
      12. 3. Design Patterns
        1. The Entity State Pattern
          1. Technical description
          2. Setting the State
          3. Testing the State
          4. Implementations
          5. Examples
        2. The Select Pattern
          1. Technical description
          2. Implementations
            1. Examples
        3. The Number Series Pattern
          1. Technical description
            1. The Table reference field
            2. Setup reference
            3. C/AL functions and variables
          2. Implementations
          3. Examples
        4. Address Integration Pattern
          1. Technical description
            1. Fields
          2. Copying the address
            1. Printing addresses
          3. Implementations
          4. Examples
        5. Multi-Level Setup
          1. Technical description
          2. Implementations
          3. Examples
        6. Document History
          1. Technical description
            1. The naming conventions
            2. Codeunit Structure
            3. Test Near, Test Far
            4. Do it
            5. Clean up
            6. An Example
            7. TRANSFERFIELDS
          2. Implementations
          3. Examples
        7. Copy Document Pattern
          1. Technical description
            1. Validation logic
          2. Implementations
          3. Examples
        8. Job Queue Entry Pattern
          1. Technical description
            1. Preprocessing
            2. Getting records
            3. The Main function
            4. Post-processing
            5. Error handling
          2. Implementations
            1. Examples
        9. Dismissible dialogs and save preferences
          1. Technical description
            1. Dismissible dialog
          2. Implementations
            1. Examples
        10. Setup Update Pattern
          1. Technical description
            1. Restrictions
          2. Implementations
          3. Example
        11. Model-View ViewModel Pattern
          1. Technical description
          2. Implementations
          3. Examples
        12. Summary
      13. 4. Building an Example Application Using Patterns
        1. The design elements
        2. The Pattern dependencies
        3. Step one – Foundation
          1. Example setup
          2. Which Patterns to use
          3. The implementation
          4. The Multi-Level Setup Pattern
        4. Step two – Master Data
          1. Example Person
          2. The Example Product
          3. Number Series
            1. Adding Setup fields
            2. Adding variables
            3. Adding the No. Series field
            4. Code snippets
          4. Entity State
          5. Implementing the Address Integration Pattern
        5. Step three – Journals & Entries
          1. Creating your own Journal and Entry
          2. Validation in Journals
        6. Step four – Documents
          1. Implementing a Document
          2. Document history
          3. Selecting a Pattern
          4. Other Patterns
          5. Posting
            1. The ThrowErrorIfNoSelection function
            2. The TestNear function
            3. The TestFar function
            4. The PostExampleOne/PostExampleTwo function
            5. The PostExJnlLine function
            6. The DeleteExampeDocument function
        7. The layered model
        8. Summary
      14. 5. Coding Best Practices
        1. Coding guidelines
          1. Code design
            1. Variable capacity
            2. The Cyclomatic Complexity
            3. The function size
            4. Using complex data types
            5. Localizability
            6. Date formulas
          2. Code readability
            1. Variable naming
            2. Self-explaining
            3. Suffix versus prefix
            4. Approved abbreviations
        2. Class-Method-Property
          1. The Table as a class
          2. A Codeunit as a method
        3. Function libraries and interfaces
        4. Natural Language Programming
          1. Pitfalls
          2. Bonus – debugging
        5. Encapsulation
          1. Override Functions
        6. Façade
        7. Hooks
          1. Disabling the original source code
          2. Predefined hooks
        8. Variant variables
        9. Managing DLL
        10. Summary
      15. 6. Anti-patterns and Handling Legacy Code
        1. Anti-patterns
          1. Code cloning
            1. Forking
            2. Templating
            3. Customizing
            4. Exact match
            5. Examples
            6. Transaction mirroring
            7. Code normalization and writing clean code
            8. The Document type normalization
            9. The small business application
            10. The VAT and Sales Tax calculation
            11. Avoiding code cloning
          2. Boat anchors
          3. Other anti-patterns and context
          4. Programming language capabilities
        2. Legacy code
        3. Refactoring the C/AL Code
          1. Refactoring tables
            1. Renaming
            2. Normalization
          2. Code refactoring
            1. Finding the process owner
            2. Moving to Codeunit
            3. Breaking down the code into functions
            4. Encapsulating functions
            5. Normalizing the code
        4. The boy scout rule
        5. Summary
      16. 7. Building Solutions Using Patterns
        1. Building blocks
          1. Applying Architectural Patterns
            1. The application setup
            2. Guests
            3. Room
            4. Season
            5. Price
            6. Reservation
            7. Stay
            8. Check-in
            9. Check-out
            10. Clean
            11. Evaluation
            12. Invoice
        2. Creating the Table objects
        3. Applying Design Patterns
          1. The Bed and Breakfast setup
          2. Bed and Breakfast season
          3. Bed and Breakfast room
          4. Bed and Breakfast price
          5. Bed and Breakfast clean entry
          6. Bed and Breakfast stay
          7. Bed and Breakfast journal and entry
          8. The Bed and Breakfast evaluation header and evaluation line
        4. Defining the methods
        5. Writing the Code and Link methods
          1. Creating the cleaning entries
        6. Refactoring
          1. The new class members
          2. The new function library
          3. Room members
          4. The room price calculation
        7. Testing the application
          1. Test isolation
          2. Analyzing the results
        8. Upgrading the application
          1. Creating a Delta file
          2. The steps of creating a Delta file
          3. Inside the Delta file
        9. Building our application
          1. Building the result
        10. Managing the source code
          1. Creating the workspace
          2. Setting up Visual Studio
          3. Uploading the files
        11. Summary
      17. Index