<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.board18.org/index.php?action=history&amp;feed=atom&amp;title=Coding_Standards_Variables</id>
	<title>Coding Standards Variables - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.board18.org/index.php?action=history&amp;feed=atom&amp;title=Coding_Standards_Variables"/>
	<link rel="alternate" type="text/html" href="https://wiki.board18.org/index.php?title=Coding_Standards_Variables&amp;action=history"/>
	<updated>2026-06-15T13:34:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.0</generator>
	<entry>
		<id>https://wiki.board18.org/index.php?title=Coding_Standards_Variables&amp;diff=2939&amp;oldid=prev</id>
		<title>Rich: initial contents of this page</title>
		<link rel="alternate" type="text/html" href="https://wiki.board18.org/index.php?title=Coding_Standards_Variables&amp;diff=2939&amp;oldid=prev"/>
		<updated>2020-07-25T15:52:24Z</updated>

		<summary type="html">&lt;p&gt;initial contents of this page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Coding Standards Index}}&lt;br /&gt;
&lt;br /&gt;
BOARD18 uses &amp;#039;&amp;#039;&amp;#039;var&amp;#039;&amp;#039;&amp;#039; to define all JavaScript variables.&lt;br /&gt;
This practice should be continued if only for consistancy.&lt;br /&gt;
&lt;br /&gt;
There are a lot of &amp;quot;best practices&amp;quot; documents on the web&lt;br /&gt;
that warn coders to avoid variables that are scoped outside &lt;br /&gt;
of any function. OOP is all about &amp;quot;locality of reference&amp;quot;.&lt;br /&gt;
This makes sense if you are including libraries which may,&lt;br /&gt;
by chance, use the same variable names. That can cause chaos.&lt;br /&gt;
&lt;br /&gt;
But BOARD18 is a maverick in this respect. JavaScript functions&lt;br /&gt;
in BOARD18 often access &amp;quot;global&amp;quot; variables. Information is passed &lt;br /&gt;
in massive structures that are updated in various places.&lt;br /&gt;
&lt;br /&gt;
BOARD18 uses the following trick to partially mitigate this&lt;br /&gt;
potential problem.&lt;br /&gt;
&lt;br /&gt;
All board18 &amp;#039;global&amp;#039; variables are contained &lt;br /&gt;
in one &amp;#039;master variable&amp;#039; called &amp;#039;&amp;#039;&amp;#039;BD18&amp;#039;&amp;#039;&amp;#039;.  This isolates &lt;br /&gt;
them from global variables in other packages.&lt;br /&gt;
&lt;br /&gt;
At the front of the board18com.js file, which is included in &lt;br /&gt;
every BOARD18 page, is the following 5 lines of code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var BD18 = {};&lt;br /&gt;
BD18.noteTimeout = null; // Used by doLogNote().&lt;br /&gt;
BD18.welcomename = null; // Used by doLogNote().&lt;br /&gt;
BD18.help = &amp;quot;https://wiki.board18.org/w/Player%27s_Guide_V2.5&amp;quot;;&lt;br /&gt;
BD18.version = &amp;quot;2.5.11&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
Thus the &amp;#039;&amp;#039;&amp;#039;BD18&amp;#039;&amp;#039;&amp;#039; object becomes the only global&lt;br /&gt;
variable in BOARD18. Many objects and arrays will be &lt;br /&gt;
added to this object. But it still remains only one variable.&lt;br /&gt;
&lt;br /&gt;
[[Category:Standards]]&lt;/div&gt;</summary>
		<author><name>Rich</name></author>
	</entry>
</feed>