change nav 1-patterns formatting
This commit is contained in:
parent
ba12637e35
commit
7e4e21d223
54 changed files with 211 additions and 250 deletions
|
|
@ -2,20 +2,18 @@
|
|||
title = "Singleton"
|
||||
weight = 1090
|
||||
+++
|
||||
## Singleton
|
||||
_By Bogdana Botez at Microsoft Development Center Copenhagen_
|
||||
|
||||
_By Bogdana Botez at Microsoft Development Center Copenhagen_
|
||||
[![ ][image0]][anchor0]
|
||||
|
||||
**Context: **The pattern described in this article applies to Dynamics NAV only. For the general definition of the **Singleton** pattern, see for example [this link][anchor1].**
|
||||
**
|
||||
**Context:** The pattern described in this article applies to Dynamics NAV only. For the general definition of the **Singleton** pattern, see for example [this link][anchor1].
|
||||
|
||||
**Problem**: As a C/AL developer, you need to coordinate action (through a codeunit) or store information (in a table) that is unique across the system.
|
||||
|
||||
**Forces:**
|
||||
|
||||
* **Lost reference to centralizer:** An instance of a relevant object could attempt to centralize control or data in the system. However, once this object is no longer in scope, the reference to it is lost and cannot be retrieved for later coordination
|
||||
* **Cannot rebuild the initial state: **A new instance of the same object could be created, however the last known state of the lost instance cannot be known anymore.
|
||||
* **Cannot rebuild the initial state:** A new instance of the same object could be created, however the last known state of the lost instance cannot be known anymore.
|
||||
|
||||
**Solution:** create an object which resides in memory in a single copy (instance). Have a way to retrieve this unique object from code. This object can either be a [**Singleton Table**][anchor2], or a [**Singleton Codeunit**][anchor3].
|
||||
|
||||
|
|
@ -26,7 +24,7 @@ The implementation varies depending on the technology and language used. In obje
|
|||
* **Centralization**: the setup information is stored in a single well-known place and easily retrievable from anywhere in the application code, by invoking a Record.GET. In case of a single-instance codeunit, any reference to it will retrieve the same instance, so the context will be preserved.
|
||||
* **Persistence**: information remains even after the instance goes out of scope, because it continues to live in memory.
|
||||
|
||||
**Limitation: **The generic object-oriented **Singleton** pattern permits instantiation of a limited number n of objects (where usually n=1, but it can have other positive values too). However, in Dynamics NAV, the Singleton patterns are limited: n is always 1\.
|
||||
**Limitation:** The generic object-oriented **Singleton** pattern permits instantiation of a limited number n of objects (where usually n=1, but it can have other positive values too). However, in Dynamics NAV, the Singleton patterns are limited: n is always 1\.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@
|
|||
title = "Singleton Codeunit"
|
||||
weight = 1100
|
||||
+++
|
||||
## Singleton Codeunit
|
||||
_By Bogdana Botez at Microsoft Development Center Copenhagen_
|
||||
|
||||
_By Bogdana Botez at Microsoft Development Center Copenhagen
|
||||
_
|
||||
[![ ][image0]][anchor0]
|
||||
|
||||
_[![ ][image0]][anchor0]
|
||||
_
|
||||
|
||||
**Problem**: In some situations, global state needs to be preserved at runtime throughout a session.
|
||||
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ In a functionality that is large enough (such as sales, inventory, fixed) you ma
|
|||
|
||||
**Implementation**
|
||||
|
||||
**1\. Define: **Create a Setup Table with Dummy a Primary Key. Typically with type Code=10\. Then add fields to define the global rules.
|
||||
**1\. Define:** Create a Setup Table with Dummy a Primary Key. Typically with type Code=10\. Then add fields to define the global rules.
|
||||
|
||||
**2\. Instantiate: **Place the instantiation code in a central place where it is guaranteed to be invoked before the functionality uses it. This is done in Codeunit 2\.
|
||||
**2\. Instantiate:** Place the instantiation code in a central place where it is guaranteed to be invoked before the functionality uses it. This is done in Codeunit 2\.
|
||||
|
||||
**3\. Enforce: **Give the user access to the record so that he can change the default setup, by creating a Card page. On the page, enforce the singleton to prevent deletion of the record or insertion of a new record
|
||||
**3\. Enforce:** Give the user access to the record so that he can change the default setup, by creating a Card page. On the page, enforce the singleton to prevent deletion of the record or insertion of a new record
|
||||
|
||||
**4\. Use: **Access the rule in code and use it
|
||||
**4\. Use:** Access the rule in code and use it
|
||||
|
||||
****
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ The **Singleton Table** has two established applications in Dynamics NAV:
|
|||
|
||||
YouTube Video of NAV Singleton:
|
||||
|
||||
[watch?v=aQPu s9FkYI&list=PLhZ3P LY7CqmVszuvtJLujFyHpsVN0Uw&index=13][anchor3]
|
||||
{{< youtube aQPu-s9FkYI>}}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@
|
|||
title = "Cue Table"
|
||||
weight = 440
|
||||
+++
|
||||
## Cue Table
|
||||
_By Bogdana Botez at Microsoft Development Center Copenhagen_
|
||||
|
||||
_By Bogdana Botez at Microsoft Development Center Copenhagen
|
||||
_
|
||||
[![ ][image0]][anchor0]
|
||||
|
||||
_[![ ][image0]][anchor0]
|
||||
_
|
||||
|
||||
Cues are the second usual application of the [**Singleton Table**][anchor1] pattern in Dynamics NAV, after [**Setup Tables**][anchor2].
|
||||
|
||||
|
|
@ -22,8 +19,6 @@ The overview information consists of summed-up numbers, calculated from business
|
|||
|
||||
**Problem**: NAV stores data in tables. By definition, a table is a repetitive structure containing multiple lines, each line having a different piece of the information. But sometimes this repetitive information needs to be summed-up or otherwise synthetized, and presented as an overview.
|
||||
|
||||
**
|
||||
**
|
||||
|
||||
**Solution:** Store overview information in a singleton table.
|
||||
|
||||
|
|
@ -37,14 +32,13 @@ There are two ways of calculating overview information in NAV.
|
|||
* * The way to calculate the overview is too complex for flow fields, or
|
||||
* The data needs to be pulled from an external system (like Dynamics CRM, QuickBooks or any external integration).
|
||||
|
||||
**
|
||||
**
|
||||
****
|
||||
|
||||
The implementation of Cues is already described in detail on MSDN, in [Creating and Customizing Cues][anchor4] and in [Walkthrough: Creating a Cue Based on a FlowField][anchor5].
|
||||
|
||||
**NAV Usages**
|
||||
|
||||
Table 1 - Cue tables in Dynamics NAV****shows some examples of singleton tables used for creating Cues.
|
||||
_Table 1 - Cue tables in Dynamics NAV_ shows some examples of singleton tables used for creating Cues.
|
||||
|
||||
Table ID
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
title = "Setup Table"
|
||||
weight = 1070
|
||||
+++
|
||||
## Setup Table
|
||||
|
||||
_By Abhishek Ghosh, at Microsoft Development Center Copenhagen_
|
||||
|
||||
## [![ ][image0]][anchor0]
|
||||
[![ ][image0]][anchor0]
|
||||
|
||||
This is the first and most well-known of the two usual applications of the **Singleton Table** pattern in Dynamics NAV.
|
||||
|
||||
|
|
@ -58,7 +56,7 @@ Several Setup tables in NAV implement this pattern. Some of those are:
|
|||
* Table 313 Inventory Setup
|
||||
* Table 242 Source Code Setup
|
||||
|
||||
**Variation: **While most tables just insert a record with empty primary key in codeunit 2, table 242 ("Source Code Setup") offers an example of inserting default values into all fields of the table (method "InitSourceCodeSetup"). This practice, wherever feasible, is likely to reduce the effort during implementation.
|
||||
**Variation:** While most tables just insert a record with empty primary key in codeunit 2, table 242 ("Source Code Setup") offers an example of inserting default values into all fields of the table (method "InitSourceCodeSetup"). This practice, wherever feasible, is likely to reduce the effort during implementation.
|
||||
|
||||
**Related resources:** [Considerations on optimizing the Singleton Table, by Søren Klemmensen][anchor2].
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue