Advertisement
2002C Coding Standards #14466

Code Formatting - Its important people!

I aim to try and get more people to make their code more readable. More readable code means that the code is percieved better and better perception of the code might even to a better vote. Also, it makes everybody else alot happier if thay can actually read your code.

AI

Resumo por IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Código fonte
original-source
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<link rel=File-List href="./Contents_files/filelist.xml">
<title>Contents:</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
 <o:Author> Thomas Waddell</o:Author>
 <o:LastAuthor> Thomas Waddell</o:LastAuthor>
 <o:Revision>4</o:Revision>
 <o:TotalTime>44</o:TotalTime>
 <o:Created>2001-10-17T08:40:00Z</o:Created>
 <o:LastSaved>2001-10-17T08:42:00Z</o:LastSaved>
 <o:Pages>3</o:Pages>
 <o:Words>642</o:Words>
 <o:Characters>3660</o:Characters>
 <o:Lines>30</o:Lines>
 <o:Paragraphs>7</o:Paragraphs>
 <o:CharactersWithSpaces>4494</o:CharactersWithSpaces>
 <o:Version>9.3821</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;
	mso-font-charset:2;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
	{font-family:EnglischeSchT;
	panose-1:3 3 4 2 4 6 7 12 13 3;
	mso-font-charset:0;
	mso-generic-font-family:script;
	mso-font-pitch:variable;
	mso-font-signature:7 0 0 0 147 0;}
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
h1
	{mso-style-next:Normal;
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	page-break-after:avoid;
	mso-outline-level:1;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-font-kerning:0pt;}
p.MsoBodyText, li.MsoBodyText, div.MsoBodyText
	{margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;
	text-underline:single;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:35.4pt;
	mso-footer-margin:35.4pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1027"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
 <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-GB link=blue vlink=purple style='tab-interval:36.0pt'>
<div class=Section1>
<p class=MsoNormal><b><span style='font-size:14.0pt;mso-bidi-font-size:12.0pt'>Contents:<o:p></o:p></span></b></p>
<p class=MsoNormal><span style='mso-tab-count:1'>            </span></p>
<p class=MsoNormal style='margin-left:36.0pt'><a href="#Intro">Introduction</a></p>
<p class=MsoNormal><span style='mso-tab-count:1'>            </span><a
href="#Indent">Indentation</a></p>
<p class=MsoNormal><span style='mso-tab-count:1'>            </span><a
href="#Lines">Lines</a></p>
<p class=MsoNormal><span style='mso-tab-count:1'>            </span><a
href="#Comment">Commenting</a></p>
<p class=MsoNormal style='text-indent:36.0pt'><a href="#fInish">That&#8217;s it</a></p>
<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
<h1><a name=Intro><span style='font-size:14.0pt;mso-bidi-font-size:12.0pt'>Introduction</span></a><span
style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><o:p></o:p></span></h1>
<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:10.0pt;
mso-bidi-font-size:12.0pt'>First of all, what do I actually want to do here?
Well, this is not an easy question to answer. All too often I see badly written
code. It might be the best code ever written but if it is unreadable then it is
considered (by me anyway) as being bad code. Code can be formatted in different
ways. It is up to you. I will be showing you all of my conventions but these
are not the only ways to do it. Your way might be right as well. <o:p></o:p></span></p>
<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
<p class=MsoNormal><a name=Indent><b><span style='font-size:14.0pt;mso-bidi-font-size:
12.0pt'>Indent your code.</span></b></a><b><span style='font-size:14.0pt;
mso-bidi-font-size:12.0pt'><o:p></o:p></span></b></p>
<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
<p class=MsoNormal><span style='mso-tab-count:1'>            </span><span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>The first thing I always
notice in a piece of code is how well it is indented. For example:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Private</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
<span style='color:blue'>Function</span> Example (<span style='color:blue'>ByVal</span>
ExampleVar <span style='color:blue'>as</span> <span style='color:blue'>long</span>)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>If</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
ExampleVar &gt; 0 <span style='color:blue'>then</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Select</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
<span style='color:blue'>Case</span> ExampleVar<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Case</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
1:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Call</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
DoThis (1)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Case</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
2:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Call</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
DoThis (2)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>End</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> <span
style='color:blue'>select</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Elseif</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
ExampleVar &lt; 0 <span style='color:blue'>then</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Case</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
-1:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Call</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
DoThis<span style="mso-spacerun: yes">  </span>(-1)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Case</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
&#8211;2<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Call</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
DoThis<span style="mso-spacerun: yes">  </span>(-2)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>End</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> <span
style='color:blue'>Select</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>End</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> <span
style='color:blue'>if</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>End</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> <span
style='color:blue'>Function</span></span><span style='font-size:10.0pt;
mso-bidi-font-size:12.0pt'><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>This
is not indented at all. If the code is long and complex with long lines then it
looks like an English essay or something similar. This I believe is much more
readable:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Private</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
<span style='color:blue'>Function</span> Example (<span style='color:blue'>ByVal</span>
ExampleVar <span style='color:blue'>as</span> <span style='color:blue'>long</span>)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>If</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
ExampleVar &gt; 0 <span style='color:blue'>then</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt;color:blue'>Select</span><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt'> <span style='color:blue'>Case</span> ExampleVar<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt;color:blue'>Case</span><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt'> 1:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt'><span
style='font-size:8.0pt;mso-bidi-font-size:12.0pt;color:blue'>Call</span><span
style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> DoThis (1)<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt;color:blue'>Case</span><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt'> 2:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt'><span
style='font-size:8.0pt;mso-bidi-font-size:12.0pt;color:blue'>Call</span><span
style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> DoThis (2)<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt;color:blue'>End</span><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt'> <span style='color:blue'>select</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>Elseif</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
ExampleVar &lt; 0 <span style='color:blue'>then</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt;color:blue'>Select</span><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt'> <span style='color:blue'>case</span> ExampleVar<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt;color:blue'>Case</span><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt'> -1:<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt'><span
style='font-size:8.0pt;mso-bidi-font-size:12.0pt;color:blue'>Call</span><span
style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> DoThis<span
style="mso-spacerun: yes">  </span>(-1)<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt;color:blue'>Case</span><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt'> &#8211;2<o:p></o:p></span></p>
<p class=MsoNormal style='margin-left:36.0pt;text-indent:36.0pt'><span
style='font-size:8.0pt;mso-bidi-font-size:12.0pt;color:blue'>Call</span><span
style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> DoThis<span
style="mso-spacerun: yes">  </span>(-2)<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:36.0pt'><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt;color:blue'>End</span><span style='font-size:8.0pt;
mso-bidi-font-size:12.0pt'> <span style='color:blue'>Select</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>End</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> <span
style='color:blue'>if</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>End</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> <span
style='color:blue'>Function<o:p></o:p></span></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>The
rules I use for indentation are:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>For
every new block you write, on the next line press tab. <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>I.E.
A block is defined as a &#8220;With statement&#8221;, &#8220;If statement&#8221;, &#8221;Loop&#8221;, &#8220;Select case
statement&#8221;, &#8220;Type structure&#8221;, &#8220;Enumeration structure&#8221;, E.T.C<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Basically
anything with a beginning, then some code, then an end.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>E.g.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>With</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'>
<span style='color:blue'>This</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:1'>                </span><span style='color:blue'>If</span>
This <span style='color:blue'>then</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:2'>                                </span><span
style='color:blue'>Select</span> <span style='color:blue'>case</span> This<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:2'>                                </span><span
style='color:blue'>Case</span> 1:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:3'>                                                </span>DoThis<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:2'>                                </span><span
style='color:blue'>Case</span> <span style='color:blue'>else</span>:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:3'>                                                </span>DoThis<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:2'>                                </span><span
style='color:blue'>End</span> <span style='color:blue'>Select</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:1'>                </span><span style='color:blue'>Else</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:2'>                                </span><span
style='color:blue'>While</span> This<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:3'>                                                </span>DoThis<span
style='color:blue'><o:p></o:p></span></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:2'>                                </span><span
style='color:blue'>Wend</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'><span
style='mso-tab-count:1'>                </span><span style='color:blue'>End</span>
<span style='color:blue'>If</span><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'>End</span><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt'> <span
style='color:blue'>With<o:p></o:p></span></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:blue'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>This
is good indentation and makes your code very readable.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Just
one more thing, do not squash all your code up. Leave spaces between blocks and
lines, or blocks and other blocks, between functions, subs E.T.C.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<h1><a name=Lines><span style='font-size:14.0pt;mso-bidi-font-size:12.0pt'>Lines.
Break long ones up, and don&#8217;t use the &#8220;:&#8221; function</span></a></h1>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>If
you have a long line such as an API function:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:#3366FF'>Declare</span><span style='font-size:8.0pt;mso-bidi-font-size:
12.0pt'> <span style='color:#3366FF'>Function</span> BitBlt <span
style='color:#3366FF'>Lib</span> &quot;gdi32&quot; <span style='color:#3366FF'>Alias</span>
&quot;BitBlt&quot; (<span style='color:#3366FF'>ByVal</span> hDestDC <span
style='color:#3366FF'>As</span> <span style='color:#3366FF'>Long</span>, ByVal
x <span style='color:#3366FF'>As</span> <span style='color:#3366FF'>Long</span>,
<span style='color:#3366FF'>ByVal</span> y <span style='color:#3366FF'>As</span>
<span style='color:#3366FF'>Long</span>, <span style='color:#3366FF'>ByVal</span>
nWidth <span style='color:#3366FF'>As</span> <span style='color:#3366FF'>Long</span>,
<span style='color:#3366FF'>ByVal</span> nHeight <span style='color:#3366FF'>As</span>
<span style='color:#3366FF'>Long</span>, <span style='color:#3366FF'>ByVal</span>
hSrcDC <span style='color:#3366FF'>As</span> <span style='color:#3366FF'>Long</span>,
<span style='color:#3366FF'>ByVal</span> xSrc <span style='color:#3366FF'>As</span>
<span style='color:#3366FF'>Long</span>, <span style='color:#3366FF'>ByVal</span>
ySrc <span style='color:#3366FF'>As</span> <span style='color:#3366FF'>Long</span>,
<span style='color:#3366FF'>ByVal</span> dwRop <span style='color:#3366FF'>As</span>
<span style='color:#3366FF'>Long</span>) <span style='color:#3366FF'>As</span> <span
style='color:#3366FF'>Long<o:p></o:p></span></span></p>
<p class=MsoNormal><span style='font-size:8.0pt;mso-bidi-font-size:12.0pt;
color:#3366FF'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Fortunately
for us this has already been put into separate lines for us, but imagine it
hadn&#8217;t.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>To
break something up into separate lines use this &#8220; _&#8221; at the end of the line.
E.G.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Original
Line:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>FirstPart
SecondPart ThirdPart<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Broken
Up:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>FirstPart
_<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Second
Part _<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Third
Part <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Simple
enough right?<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Another
thing I see is this:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>FirstLine:
SecondLine: ThirdLine<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Don&#8217;t
put separate lines onto one line.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>There
we go. That was simple right?<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<h1><a name=Comment><span style='font-size:14.0pt;mso-bidi-font-size:12.0pt'>Commenting</span></a><span
style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><o:p></o:p></span></h1>
<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Just
a quick note on this.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Do
not overdo the comment lines. Only explain things, which are difficult, in
detail. For the rest, a quick description of what the particular piece of code
does.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Most
of the time people do not bother to comment their code at all. This is
something to avoid doing. Always put some commenting in.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>A
good idea is: If you have written any custom subs/ functions/ properties E.T.C.
then you should put a short comment line at the beginning with a description of
the function, what you should pass to the parameter if there are any, and what
the function returns if it returns something. <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>There
are two ways to comment:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>1 <span
style='color:#339966'>&#8216;Comment here<o:p></o:p></span></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>2<span
style='color:#339966'> Rem Comment here <o:p></o:p></span></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
color:#339966'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>I
think Rem stands for remark<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<h1><a name=fInish><span style='font-size:14.0pt;mso-bidi-font-size:12.0pt'>Ok.
I&#8217;m done now</span></a></h1>
<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
<p class=MsoBodyText><span style='mso-tab-count:1'>                </span>Remember
I am not saying here that my way is right. Your way is wrong. Change your ways
now.</p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>All
I am saying is that you should adopt some kind of conventions to make your code
more readable. I use the ones I do because those are the ones I see most often
and find most readable.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'>Thanks
for reading this and please leave your <b>feedback. </b>Maybe it&#8217;s sad but I
love feedback. A <b>vote</b> wouldn&#8217;t do any harm either. I&#8217;m not after code of
the month or anything but if somebody comes across this and it has a good vote
then they are more likely to read it. More people read this and everybody&#8217;s
code becomes more readable (Then world peace and happiness for everybody </span><span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:Wingdings;
mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";
mso-char-type:symbol;mso-symbol-font-family:Wingdings'><span style='mso-char-type:
symbol;mso-symbol-font-family:Wingdings'>J</span></span><span style='font-size:
10.0pt;mso-bidi-font-size:12.0pt'>)<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:16.0pt;mso-bidi-font-size:12.0pt;
font-family:EnglischeSchT'>&lt;Coding Genius&gt;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></p>
</div>
</body>
</html>
Comentários originais (3)
Recuperado do Wayback Machine