This commit is contained in:
JeremyVyska 2023-02-22 13:45:30 +00:00
parent 35e175dacf
commit 2914a84a66
5 changed files with 8 additions and 8 deletions

View file

@ -773,7 +773,7 @@ this specific table will not be used as temporary by someone else. Reacting to t
</ul>
<p>Avoid subscribers to these events.</p>
<h2 id="references">References</h2>
&lt;p>The &lt;a href="https://alguidelines.dev/bcpatterns/generic-method-pattern/">Generic Method Pattern&lt;/a>&lt;/p></description></item><item><title>Docs: Suggested Abbreviations</title><link>https://alguidelines.dev/docs/bestpractices/suggested-abbreviations/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://alguidelines.dev/docs/bestpractices/suggested-abbreviations/</guid><description>
&lt;p>The &lt;a href="https://alguidelines.dev/docs/patterns/generic-method-pattern/">Generic Method Pattern&lt;/a>&lt;/p></description></item><item><title>Docs: Suggested Abbreviations</title><link>https://alguidelines.dev/docs/bestpractices/suggested-abbreviations/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://alguidelines.dev/docs/bestpractices/suggested-abbreviations/</guid><description>
&lt;p>&lt;em>Created by Microsoft, Described by waldo&lt;/em>&lt;/p>
&lt;h2 id="description">Description&lt;/h2>
&lt;p>Whenever possible, do &lt;strong>not&lt;/strong> use abbreviations in variables, functions and objects names.&lt;/p>

View file

@ -3,10 +3,10 @@ Description
In general, subscribers have to be put in codeunits. There are a few performance considerations that …"><meta property="og:title" content="Subscriber Codeunits"><meta property="og:description" content="Created by waldo, Described by waldo
Description In general, subscribers have to be put in codeunits. There are a few performance considerations that you should keep in the back of your minds, when designing such a codeunit.
Keep the codeunit as small as possible Work with a single instance codeunit only subscribe when necessary Avoid generic OnInsert/OnModify/OnDelete Let&rsquo;s discuss all points
Keep the codeunit as small as possible Every time a subscriber gets called, a new instance of the codeunit is being loaded in memory, which takes memory and processing power."><meta property="og:type" content="article"><meta property="og:url" content="https://alguidelines.dev/docs/bestpractices/subscribercodeunits/"><meta property="og:image" content="https://alguidelines.dev/images/og-image-fission.png"><meta property="article:section" content="docs"><meta property="article:modified_time" content="2023-02-20T17:28:34+01:00"><meta property="og:site_name" content="alguidelines.dev - Business Central Design Patterns"><meta itemprop=name content="Subscriber Codeunits"><meta itemprop=description content="Created by waldo, Described by waldo
Keep the codeunit as small as possible Every time a subscriber gets called, a new instance of the codeunit is being loaded in memory, which takes memory and processing power."><meta property="og:type" content="article"><meta property="og:url" content="https://alguidelines.dev/docs/bestpractices/subscribercodeunits/"><meta property="og:image" content="https://alguidelines.dev/images/og-image-fission.png"><meta property="article:section" content="docs"><meta property="article:modified_time" content="2023-02-21T17:12:09+01:00"><meta property="og:site_name" content="alguidelines.dev - Business Central Design Patterns"><meta itemprop=name content="Subscriber Codeunits"><meta itemprop=description content="Created by waldo, Described by waldo
Description In general, subscribers have to be put in codeunits. There are a few performance considerations that you should keep in the back of your minds, when designing such a codeunit.
Keep the codeunit as small as possible Work with a single instance codeunit only subscribe when necessary Avoid generic OnInsert/OnModify/OnDelete Let&rsquo;s discuss all points
Keep the codeunit as small as possible Every time a subscriber gets called, a new instance of the codeunit is being loaded in memory, which takes memory and processing power."><meta itemprop=dateModified content="2023-02-20T17:28:34+01:00"><meta itemprop=wordCount content="844"><meta itemprop=image content="https://alguidelines.dev/images/og-image-fission.png"><meta itemprop=keywords content="AL,Performance,"><meta name=twitter:card content="summary_large_image"><meta name=twitter:image content="https://alguidelines.dev/images/og-image-fission.png"><meta name=twitter:title content="Subscriber Codeunits"><meta name=twitter:description content="Created by waldo, Described by waldo
Keep the codeunit as small as possible Every time a subscriber gets called, a new instance of the codeunit is being loaded in memory, which takes memory and processing power."><meta itemprop=dateModified content="2023-02-21T17:12:09+01:00"><meta itemprop=wordCount content="844"><meta itemprop=image content="https://alguidelines.dev/images/og-image-fission.png"><meta itemprop=keywords content="AL,Performance,"><meta name=twitter:card content="summary_large_image"><meta name=twitter:image content="https://alguidelines.dev/images/og-image-fission.png"><meta name=twitter:title content="Subscriber Codeunits"><meta name=twitter:description content="Created by waldo, Described by waldo
Description In general, subscribers have to be put in codeunits. There are a few performance considerations that you should keep in the back of your minds, when designing such a codeunit.
Keep the codeunit as small as possible Work with a single instance codeunit only subscribe when necessary Avoid generic OnInsert/OnModify/OnDelete Let&rsquo;s discuss all points
Keep the codeunit as small as possible Every time a subscriber gets called, a new instance of the codeunit is being loaded in memory, which takes memory and processing power."><link rel=preload href=/scss/main.min.84a617ff0c0265eb62b5cd2929c572f4ed37dc4907d0cf068be4eb2974f6d60f.css as=style><link href=/scss/main.min.84a617ff0c0265eb62b5cd2929c572f4ed37dc4907d0cf068be4eb2974f6d60f.css rel=stylesheet integrity><script src=https://code.jquery.com/jquery-3.6.0.min.js integrity=sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK crossorigin=anonymous></script>
@ -134,8 +134,8 @@ Keep the codeunit as small as possible Every time a subscriber gets called, a ne
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>if</span><span style=color:#f8f8f8;text-decoration:underline> </span>JustSomeTable<span style=color:#ce5c00;font-weight:700>.</span>Color<span style=color:#f8f8f8;text-decoration:underline> </span>=<span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#39;RED&#39;</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>then</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>UnbindSubscription<span style=color:#ce5c00;font-weight:700>(</span>DemoSubs<span style=color:#ce5c00;font-weight:700>)</span><span style=color:#000;font-weight:700>;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>until</span><span style=color:#f8f8f8;text-decoration:underline> </span>JustSomeTable<span style=color:#ce5c00;font-weight:700>.</span>Next<span style=color:#ce5c00;font-weight:700>() </span>&lt;<span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#0000cf;font-weight:700>1</span><span style=color:#000;font-weight:700>;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span></code></pre></div><h2 id=avoid-oninsertonmodifyondelete>Avoid OnInsert/OnModify/OnDelete</h2><p>The reason for this is, that it breaks the batch-calls:</p><ul><li>Any &ldquo;OnInsert&rdquo; subscriber breaks the bulk inserts, simply because it needs to perform an operation after every record that was inserted</li><li>Any &ldquo;OnModify&rdquo; subscriber slows down the &ldquo;ModifyAll&rdquo;, simply because it needs to perform an operation after every record that was modified. I fact: 1 SQL call is turned into a loop of SQL calls.</li><li>Any &ldquo;OnDelete&rdquo; subscriber slows down the &ldquo;DeleteAll&rdquo;, simply because it needs to perform an operation after every record that was deleted. I fact: 1 SQL call is turned into a loop of SQL calls.</li></ul><p>Avoid subscribers to these events.</p><h2 id=references>References</h2><p>The <a href=https://alguidelines.dev/bcpatterns/generic-method-pattern/>Generic Method Pattern</a></p><div class="text-muted mt-5 pt-3 border-top">Last modified February 20, 2023: <a href=https://github.com/microsoft/alguidelines/commit/8a4eca4d58547e7f3bc2c98c2a855e780015a8ed>Update index.md (8a4eca4d)</a>
by Soren Klemmensen</div></div></main></div></div><footer class="bg-dark py-5 row d-print-none"><div class="container-fluid mx-sm-5"><div class=row><div class="col-6 col-sm-4 text-xs-center order-sm-2"><ul class="list-inline mb-0"><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title=GitHub aria-label=GitHub><a class=text-white target=_blank rel=noopener href=https://github.com/microsoft/alguidelines aria-label=GitHub><i class="fab fa-github"></i></a></li><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title=Twitter aria-label=Twitter><a class=text-white target=_blank rel=noopener href="https://twitter.com/search?q=%23bcalhelp" aria-label=Twitter><i class="fab fa-twitter"></i></a></li><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title=Discord aria-label=Discord><a class=text-white target=_blank rel=noopener href=https://discord.gg/4wbfNv3 aria-label=Discord><i class="fab fa-discord"></i></a></li></ul></div><div class="col-6 col-sm-4 text-right text-xs-center order-sm-3"></div><div class="col-12 col-sm-4 text-center py-2 order-sm-2"><small class=text-white>&copy; 2023 alguidelines.dev Project All Rights Reserved</small></div></div></div></footer></div><script src=https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js integrity=sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN crossorigin=anonymous></script>
</span></span></span></code></pre></div><h2 id=avoid-oninsertonmodifyondelete>Avoid OnInsert/OnModify/OnDelete</h2><p>The reason for this is, that it breaks the batch-calls:</p><ul><li>Any &ldquo;OnInsert&rdquo; subscriber breaks the bulk inserts, simply because it needs to perform an operation after every record that was inserted</li><li>Any &ldquo;OnModify&rdquo; subscriber slows down the &ldquo;ModifyAll&rdquo;, simply because it needs to perform an operation after every record that was modified. I fact: 1 SQL call is turned into a loop of SQL calls.</li><li>Any &ldquo;OnDelete&rdquo; subscriber slows down the &ldquo;DeleteAll&rdquo;, simply because it needs to perform an operation after every record that was deleted. I fact: 1 SQL call is turned into a loop of SQL calls.</li></ul><p>Avoid subscribers to these events.</p><h2 id=references>References</h2><p>The <a href=https://alguidelines.dev/docs/patterns/generic-method-pattern/>Generic Method Pattern</a></p><div class="text-muted mt-5 pt-3 border-top">Last modified February 21, 2023: <a href=https://github.com/microsoft/alguidelines/commit/375ef7043e7ca203812bbed104ba0baa355d4cc7>Update index.md (375ef704)</a>
by deadmouse</div></div></main></div></div><footer class="bg-dark py-5 row d-print-none"><div class="container-fluid mx-sm-5"><div class=row><div class="col-6 col-sm-4 text-xs-center order-sm-2"><ul class="list-inline mb-0"><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title=GitHub aria-label=GitHub><a class=text-white target=_blank rel=noopener href=https://github.com/microsoft/alguidelines aria-label=GitHub><i class="fab fa-github"></i></a></li><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title=Twitter aria-label=Twitter><a class=text-white target=_blank rel=noopener href="https://twitter.com/search?q=%23bcalhelp" aria-label=Twitter><i class="fab fa-twitter"></i></a></li><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title=Discord aria-label=Discord><a class=text-white target=_blank rel=noopener href=https://discord.gg/4wbfNv3 aria-label=Discord><i class="fab fa-discord"></i></a></li></ul></div><div class="col-6 col-sm-4 text-right text-xs-center order-sm-3"></div><div class="col-12 col-sm-4 text-center py-2 order-sm-2"><small class=text-white>&copy; 2023 alguidelines.dev Project All Rights Reserved</small></div></div></div></footer></div><script src=https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js integrity=sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN crossorigin=anonymous></script>
<script src=https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js integrity="sha512-UR25UO94eTnCVwjbXozyeVd6ZqpaAE9naiEUBK/A+QDbfSTQFhPGj5lOR6d8tsgbBk84Ggb5A3EkjsOgPRPcKA==" crossorigin=anonymous></script>
<script src=https://cdn.jsdelivr.net/npm/mermaid@8.13.4/dist/mermaid.min.js integrity="sha512-JERecFUBbsm75UpkVheAuDOE8NdHjQBrPACfEQYPwvPG+fjgCpHAz1Jw2ci9EXmd3DdfiWth3O3CQvcfEg8gsA==" crossorigin=anonymous></script>
<script src=/js/tabpane-persist.js></script>