<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>General</title><link>http://blogs.vbcity.com/hotdog/category/119.aspx</link><description>Just stuff in general</description><managingEditor>Robert Verpalen</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Robert Verpalen</dc:creator><title>Query Expression Pattern: article on creating custom Linq sources</title><link>http://blogs.vbcity.com/hotdog/archive/2007/11/08/8859.aspx</link><pubDate>Thu, 08 Nov 2007 09:55:00 GMT</pubDate><guid>http://blogs.vbcity.com/hotdog/archive/2007/11/08/8859.aspx</guid><wfw:comment>http://blogs.vbcity.com/hotdog/comments/8859.aspx</wfw:comment><comments>http://blogs.vbcity.com/hotdog/archive/2007/11/08/8859.aspx#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://blogs.vbcity.com/hotdog/comments/commentRss/8859.aspx</wfw:commentRss><trackback:ping>http://blogs.vbcity.com/hotdog/services/trackbacks/8859.aspx</trackback:ping><description>&lt;P&gt;&lt;FONT size=4&gt;Article can be found here: &lt;/FONT&gt;&lt;A href="http://blogs.vbcity.com/hotdog/articles/8858.aspx"&gt;&lt;FONT size=4&gt;http://blogs.vbcity.com/hotdog/articles/8858.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The new Linq functionality is great and easy to use. Enough tutorials exist on how to use the Linq syntax and on both DLinq and XLinq as well. However when you want to implement your own Linq source, pickings are slim. The ones that are available use the IQueryable interface. However, before that interface and seemingly at the heart of Linq is the 'Query Expression Pattern'&lt;BR&gt;In the following article the basics of that pattern are explored and hopefully provide some insight on how to easily extend on the vastness already provided by Linq: &lt;A href="http://blogs.vbcity.com/hotdog/articles/8858.aspx"&gt;&lt;STRONG&gt;http://blogs.vbcity.com/hotdog/articles/8858.aspx&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src ="http://blogs.vbcity.com/hotdog/aggbug/8859.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Robert Verpalen</dc:creator><title>InstanceDescriptor and the isComplete parameter</title><link>http://blogs.vbcity.com/hotdog/archive/2006/06/01/6029.aspx</link><pubDate>Thu, 01 Jun 2006 01:29:00 GMT</pubDate><guid>http://blogs.vbcity.com/hotdog/archive/2006/06/01/6029.aspx</guid><description>&lt;P&gt;This is just a summary of how I overlooked this silly little thing that could have made my designer workings so much easier in the past: how to use the InstanceDescriptor (returned by a TypeConverter) to create a variable inside InitializeComponent and set the properties of that variable, instead of having to set everything inside the constructor. All that was needed, is to set that last parameter (isComplete) to false.&lt;/P&gt;
&lt;P&gt;It's so incredible simple and effective, I still can't believe how I&amp;nbsp;could have missed it all that time. Perhaps some of you out there have always been using it and wonder the same thing, but then again perhaps there are others who missed this in the same way and can be spared the same search and use of unneeded CodeDom solutions.&lt;/P&gt;
&lt;P&gt;
&lt;HR id=null&gt;
For a long time now, I've been wanting properties to be able to persist in the designer, where the property in this case is an instance. The easy way is to set the designerserializationvisibility to Content, but then you would always need an instance and that doesn't work when using properties with the &lt;FONT color=#008080 size=2&gt;IExtenderProvider&lt;/FONT&gt;.&lt;BR&gt;In comes the InstanceDescriptor. Creating one is fairly straight forward: by assigning a custom typeconverter to the type used by the property and enabling&amp;nbsp;that typeconverter to return an InstanceDescriptor all properties using that type can be used (how the property is created in the designer is another thing. For example you can have the typeconverter create one automatically when text is typed by implement a convertFrom(string) )&lt;BR&gt;However, I often ended up creating a bunch of constructors to suit the different scenarios without having to include all parameters all the time. &lt;BR&gt;What I really wanted, was the designer to create a variable inside InitializeComponent, and use the default serialization on the properties of that variable. But I never could find any way besides using custom serialization with the CodeDomSerializer.&lt;BR&gt;Then, one day, while trying to getting an InstanceDescriptor to work with a more dynamic construction by using a parameter array of settings in the constructor of my class, I tried setting the isComplete parameter to false. That didn't work for that, (I had to use an array of setting instances as parameter instead of loose setting instances), suddenly a variable appeared inside the InitializeComponent. Not only that, the properties that had to be saved, were indeed present.&lt;BR&gt;Problem was, at that time I changed around several things and feared it was&amp;nbsp;a fluke inside the IDE (yes, yes, me of little faith. I am indeed sorry), until I reviewed the changes and realized the power of that one parameter. By setting that one parameter to false, my class had become so much easier to maintain and&amp;nbsp;could be an effective solution to so much&amp;nbsp;more other past work arounds, that I just had to write this down here. A long story for such a thing and not likely to be read by much people, but at least it will be a reminder to self to keep re-exploring after the re-exploring of the exploring.&lt;/P&gt;&lt;img src ="http://blogs.vbcity.com/hotdog/aggbug/6029.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Robert Verpalen</dc:creator><title>.net security policy</title><link>http://blogs.vbcity.com/hotdog/archive/2006/03/20/5907.aspx</link><pubDate>Mon, 20 Mar 2006 08:24:00 GMT</pubDate><guid>http://blogs.vbcity.com/hotdog/archive/2006/03/20/5907.aspx</guid><description>&lt;P&gt;We have an intranet at work (yes really :D) And we generally trust its contents. So it would be preferrable if we could just drop a .net application and run it. All righty then: we have to set the local intranet to fulltrust. Didn't work :shock:&amp;nbsp; To make a long version of trial and error short: unless enterprise level security contains fulltrust on either all_code or on the proper zone (intranet, a trusted zone or both), the machinelevel settings will not be used, and vice versa. I still don't know the details on the .net security, but I just wanted something that would trust our intranet, without having to set them manually.&lt;/P&gt;
&lt;P&gt;There seem to be&amp;nbsp;plenty of&amp;nbsp;ways to incorporate group enterprise policies in Active Directory and all, but quickly got lost in the documentation. In the end making a class as below seemed like a much quicker way than reading in in the larger security scheme. Again, I'm sure there are much better ways to go about and I don't encourage usage of this code in such, but if you want something to quickly fully trust your intranet, you can use this&lt;/P&gt;
&lt;P&gt;This time, the class was created&amp;nbsp;largely in worktime (heh, don't need this at home), but I'm sure the company won't mind me sharing this bit (no company data is included and this way I know I can find it back ;-) . The latter&amp;nbsp;perhaps the main reason for posting :-D&amp;nbsp;)&lt;/P&gt;&lt;!-- --Start of code block
--&gt;
&lt;DIV onkeydown="var k =event.keyCode,i=-1,ch=this.firstChild;if(k==32){i=ch.sel;if(++i==ch.selcount)i=0;}else i = k - 49;if(i&gt;=0 &amp;amp;&amp;amp; i&lt;ch.selcount){ch.sel=i;ch.click();}" style="BORDER-RIGHT: #000080 3px double; BORDER-TOP: #000080 3px double; MARGIN-LEFT: 10pt; BORDER-LEFT: #000080 3px double; MARGIN-RIGHT: 2pt; BORDER-BOTTOM: #000080 3px double"&gt;
&lt;DIV style="FONT-SIZE: 9pt; BORDER-BOTTOM: #000080 3px double; FONT-FAMILY: 'Microsoft Sans Serif'" onclick="var i=this.sel,j,ch,count = this.selcount;if(i==this.selold)return;this.selold=i;for(j=0;j&lt;count;j++){ch=this.childNodes[2+j];ch.childNodes[0].checked=j==i;ch.style.fontWeight = j==i ? 'bolder' : 'normal';}ch=parentNode.childNodes[1];var sh=new Array('none','');j=i==0?0:1;ch.style.display=sh[j];ch.nextSibling.style.display=sh[1-j];var h =ch.offsetHeight;ch.style.height=i==1?'250pt':null;if(i==1&amp;amp;&amp;amp; ch.offsetHeight&gt;h)ch.style.height=h;" sel="1" selold="1" selcount="3"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 10pt" onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy&lt;/A&gt;&lt;SPAN style="MARGIN-LEFT: 5pt; CURSOR: hand; MARGIN-RIGHT: 5pt" onclick=parentNode.sel=0&gt;&lt;INPUT onclick=this.blur(); type=radio&gt;Hide&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bolder; MARGIN-LEFT: 5pt; CURSOR: hand; MARGIN-RIGHT: 5pt" onclick=parentNode.sel=1&gt;&lt;INPUT onclick=this.blur(); type=radio CHECKED&gt;Scroll&lt;/SPAN&gt;&lt;SPAN style="MARGIN-LEFT: 5pt; CURSOR: hand; MARGIN-RIGHT: 5pt" onclick=parentNode.sel=2&gt;&lt;INPUT onclick=this.blur(); type=radio&gt;Full&lt;/SPAN&gt;&lt;!-- CodeBlock by R.Verpalen 2005 : http://blogs.vbcity.com/hotdog/archive/2005/12/30/5759.aspx--&gt;&lt;/DIV&gt;
&lt;DIV style="OVERFLOW: auto; HEIGHT: 250pt; BACKGROUND-COLOR: #dcdcdc"&gt;&lt;FONT color=#0000ff&gt;using&lt;/FONT&gt; System;&lt;FONT color=#0000ff&gt;&lt;BR&gt;using&lt;/FONT&gt; System.Collections;&lt;FONT color=#0000ff&gt;&lt;BR&gt;using&lt;/FONT&gt; System.Security;&lt;FONT color=#0000ff&gt;&lt;BR&gt;using&lt;/FONT&gt; System.Security.Policy;&lt;FONT color=#0000ff&gt;&lt;BR&gt;using&lt;/FONT&gt; System.Security.Permissions;&lt;FONT color=#0000ff&gt;&lt;BR&gt;using&lt;/FONT&gt; System.Reflection;&lt;FONT color=#0000ff&gt;&lt;BR&gt;using&lt;/FONT&gt; System.Globalization;&lt;BR&gt;&lt;FONT color=#008000&gt;&lt;BR&gt;/* quick Usage:&lt;BR&gt;* &lt;BR&gt;* &lt;BR&gt;* CompanySecurity.Create("YourCompanyName","StartOfAllowedDomain");&lt;BR&gt;* &lt;BR&gt;* &lt;BR&gt;* eg: CompanySecurity.Create("Subro","\\Subro\");&lt;BR&gt;* &lt;BR&gt;* &lt;BR&gt;* The company name would not strictly be necessary, but this way the settings&lt;BR&gt;* can be easily defined when checking with the 'normal' tools.&lt;BR&gt;* NB: off course when executing the code above, your code will need the proper&lt;BR&gt;* security permissions to execute, so make sure you execute this as a user with&lt;BR&gt;* the needed permissions and from a location from where this is allowed.&lt;BR&gt;* &lt;BR&gt;* For ease of use, you can put this on the intranet and create a batch file&lt;BR&gt;* that temporarily copies the file to the local drive and executes it. Executing&lt;BR&gt;* from the local computer will have the necessary rights. To ensure the proper user&lt;BR&gt;* rights are used, use runas in that batchfile &lt;BR&gt;* (runas /user:\\yourdomain\adminstratoraccount)&lt;BR&gt;* &lt;BR&gt;*/&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;BR&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;summary&amp;gt;&lt;BR&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; can create fully trusted company intranet policy&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;BR&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;/SUMMARY&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;class&lt;/FONT&gt; &lt;FONT color=#008080&gt;CompanySecurity&lt;/FONT&gt;&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; Create(&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Company,&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; AllowedDomainName)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;CompanySecurity&lt;/FONT&gt;(Company,AllowedDomainName).CreateEntries();&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; Create(&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Company)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;CompanySecurity&lt;/FONT&gt;(Company).CreateEntries();&lt;/DIV&gt;}&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;readonly&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Company;&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;readonly&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; CompanyPermission;&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;readonly&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; CompanyCodeGroup;&lt;BR&gt;&lt;/DIV&gt;&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt;[] levelstoset = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt;[] 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;{ &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt;.Machine, &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt;.Enterprise };&lt;/DIV&gt;&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; CompanySecurity(&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Company)
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;:&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;(Company,&lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)&lt;/DIV&gt;{&lt;BR&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; CompanySecurity(&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Company,&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; DomainName)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;this&lt;/FONT&gt;.Company = Company;&lt;BR&gt;CompanyPermission = Company + &lt;FONT color=#800000&gt;"_permissions"&lt;/FONT&gt;;&lt;BR&gt;CompanyCodeGroup = Company + &lt;FONT color=#800000&gt;"_zone"&lt;/FONT&gt;;&lt;FONT color=#0000ff&gt;&lt;BR&gt;this&lt;/FONT&gt;.DomainName = DomainName;&lt;/DIV&gt;}&lt;/DIV&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; DeleteCompanyEntries()&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;foreach&lt;/FONT&gt; (&lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; levelstoset)&lt;BR&gt;{&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;PolicyLevel&lt;/FONT&gt; pl = &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.GetLevel(level);&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (DeleteCompanyEntries(pl) == 0)&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"No entries existed for "&lt;/FONT&gt; + Company + &lt;FONT color=#800000&gt;" in "&lt;/FONT&gt; + pl.Label + &lt;FONT color=#800000&gt;" level"&lt;/FONT&gt;);&lt;/DIV&gt;&lt;/DIV&gt;}&lt;/DIV&gt;}&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;virtual&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; CreatePermissionset()&lt;BR&gt;{&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;//create fulltrust&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;PermissionSet&lt;/FONT&gt; set = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;PermissionSet&lt;/FONT&gt;(&lt;FONT color=#008080&gt;PermissionState&lt;/FONT&gt;.Unrestricted);&lt;/DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;//use&lt;/FONT&gt;&lt;FONT color=#008000&gt;&lt;BR&gt;// set = new PermissionSet(null);&lt;/FONT&gt;&lt;FONT color=#008000&gt;&lt;BR&gt;//to start an empty permissionset&lt;/DIV&gt;&lt;/DIV&gt;&lt;/FONT&gt;&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;NamedPermissionSet&lt;/FONT&gt; permissions = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt;(CompanyPermission, set);&lt;BR&gt;permissions.Description = &lt;FONT color=#800000&gt;"Allow "&lt;/FONT&gt; + Company + &lt;FONT color=#800000&gt;" local intranet"&lt;/FONT&gt;;&lt;FONT color=#0000ff&gt;&lt;BR&gt;return&lt;/FONT&gt; permissions;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;}&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; domainName;&lt;FONT color=#0000ff&gt;&lt;BR&gt;string&lt;/FONT&gt; domainCodeGroupName;&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; DomainName&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;get&lt;/FONT&gt; { &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; domainName; }&lt;FONT color=#0000ff&gt;&lt;BR&gt;set&lt;/FONT&gt;&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;if&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;value&lt;/FONT&gt; != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;value&lt;/FONT&gt; = &lt;FONT color=#0000ff&gt;value&lt;/FONT&gt;.Trim();&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;value&lt;/FONT&gt;.Length == 0)&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;value&lt;/FONT&gt; = &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;else&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (!&lt;FONT color=#0000ff&gt;value&lt;/FONT&gt;.EndsWith(&lt;FONT color=#800000&gt;@"\"&lt;/FONT&gt;))&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;value&lt;/FONT&gt; += &lt;FONT color=#800000&gt;@"\"&lt;/FONT&gt;;&lt;/DIV&gt;&lt;/DIV&gt;}&lt;BR&gt;domainName = &lt;FONT color=#0000ff&gt;value&lt;/FONT&gt;;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 60pt"&gt;if&lt;/FONT&gt; (domainName != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;domainCodeGroupName = Company + &lt;FONT color=#800000&gt;"_allow_"&lt;/FONT&gt; + domainName;&lt;/DIV&gt;}&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;}&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;}&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; DomainNameIsSet&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;get&lt;/FONT&gt; { &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; domainName != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt; ; }&lt;/DIV&gt;}&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; DeleteCompanyEntries(&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; pl)&lt;BR&gt;{&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;//remove ALL instances of the company groups&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;int&lt;/FONT&gt; cnt = 0;&lt;FONT color=#0000ff&gt;&lt;BR&gt;for&lt;/FONT&gt; (; ; )&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;bool&lt;/FONT&gt; found = &lt;FONT color=#0000ff&gt;false&lt;/FONT&gt;;&lt;FONT color=#0000ff&gt;&lt;BR&gt;foreach&lt;/FONT&gt; (&lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; cg &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; pl.RootCodeGroup.Children)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;if&lt;/FONT&gt; (cg.Name.ToLower() == CompanyCodeGroup.ToLower())&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;pl.RootCodeGroup.RemoveChild(cg);&lt;FONT color=#008080&gt;&lt;BR&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"\tCode group "&lt;/FONT&gt; + cg.Name + &lt;FONT color=#800000&gt;" removed"&lt;/FONT&gt;);&lt;BR&gt;found = &lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;;&lt;BR&gt;cnt++;&lt;FONT color=#0000ff&gt;&lt;BR&gt;break&lt;/FONT&gt;;&lt;/DIV&gt;}&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (!found) &lt;FONT color=#0000ff&gt;break&lt;/FONT&gt;;&lt;/DIV&gt;}&lt;BR&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;//adjust existing intranet settings&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;CodeGroup&lt;/FONT&gt; grI = &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.GetCodeGroup(pl, &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;DefaultGroups&lt;/FONT&gt;.LocalIntranet_Zone.ToString());&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (grI != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt; &amp;amp;&amp;amp; grI.PermissionSetName == CompanyPermission)&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;pl.RootCodeGroup.RemoveChild(grI);&lt;BR&gt;grI.PolicyStatement =&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;PolicyStatement&lt;/FONT&gt;( pl.GetNamedPermissionSet(&lt;FONT color=#800000&gt;"LocalIntranet"&lt;/FONT&gt;));&lt;BR&gt;pl.RootCodeGroup.AddChild(grI);&lt;FONT color=#008080&gt;&lt;BR&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"\tDefault intranet settings reverted"&lt;/FONT&gt;);&lt;/DIV&gt;}&lt;/DIV&gt;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;//remove trusted zone&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (domainName != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)&lt;BR&gt;{&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;//add as trusted zone&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;CodeGroup&lt;/FONT&gt; grTrusted = &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.GetCodeGroup(pl, &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;DefaultGroups&lt;/FONT&gt;.Trusted_Zone.ToString());&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (grTrusted != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;if&lt;/FONT&gt; (grTrusted.PermissionSetName == CompanyPermission)&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;grTrusted.PolicyStatement = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;PolicyStatement&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt;(&lt;FONT color=#800000&gt;"Internet"&lt;/FONT&gt;));&lt;FONT color=#008080&gt;&lt;/DIV&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"\tPermissionset on trusted zone reverted to internet settings"&lt;/FONT&gt;);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;for&lt;/FONT&gt;(;;)&lt;BR&gt;{&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;CodeGroup&lt;/FONT&gt; grD = &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.GetCodeGroup(grTrusted, domainCodeGroupName);&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (grD == &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;) &lt;FONT color=#0000ff&gt;break&lt;/FONT&gt;;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 100pt"&gt;grTrusted.RemoveChild(grD);&lt;BR&gt;&lt;BR&gt;pl.RootCodeGroup.RemoveChild(grTrusted);&lt;BR&gt;pl.RootCodeGroup.AddChild(grTrusted);&lt;BR&gt;cnt++;&lt;FONT color=#008080&gt;&lt;BR&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"\tTrusted zone removed"&lt;/FONT&gt;);&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 80pt"&gt;}&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 60pt"&gt;}&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;}&lt;/DIV&gt;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;//remove permissions&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;NamedPermissionSet&lt;/FONT&gt; ns = pl.GetNamedPermissionSet(CompanyPermission);&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (ns != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;pl.RemoveNamedPermissionSet(ns);&lt;FONT color=#008080&gt;&lt;BR&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"\tNamed permission set removed on "&lt;/FONT&gt; + pl.Label + &lt;FONT color=#800000&gt;" level"&lt;/FONT&gt;);&lt;BR&gt;cnt++;&lt;/DIV&gt;}&lt;/DIV&gt;&lt;BR&gt;&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;SecurityManager&lt;/FONT&gt;.SavePolicyLevel(pl);&lt;FONT color=#0000ff&gt;&lt;BR&gt;return&lt;/FONT&gt; cnt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;}&lt;/DIV&gt;&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; CreateEntries()&lt;BR&gt;{&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"Setting permissions for "&lt;/FONT&gt; + Company);&lt;FONT color=#0000ff&gt;&lt;BR&gt;foreach&lt;/FONT&gt; (&lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; levelstoset)&lt;BR&gt;{&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;PolicyLevel&lt;/FONT&gt; pl = &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.GetLevel(level);&lt;BR&gt;CreateEntries(pl);&lt;/DIV&gt;}&lt;/DIV&gt;}&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; CreateEntries(&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; pl)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;if&lt;/FONT&gt; (pl.RootCodeGroup.Children.Count == 0 &amp;amp;&amp;amp;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;pl.RootCodeGroup.PermissionSetName == &lt;FONT color=#800000&gt;"FullTrust"&lt;/FONT&gt;)&lt;/DIV&gt;{&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;Console&lt;/FONT&gt;.WriteLine(pl.Label + &lt;FONT color=#800000&gt;" not changed, all code allready has fulltrust"&lt;/FONT&gt;);&lt;FONT color=#0000ff&gt;&lt;BR&gt;return&lt;/FONT&gt;;&lt;/DIV&gt;}&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;DeleteCompanyEntries(pl);&lt;/DIV&gt;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;//create a full trust permission&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;NamedPermissionSet&lt;/FONT&gt; permissions = CreatePermissionset();&lt;FONT color=#008080&gt;&lt;BR&gt;PolicyStatement&lt;/FONT&gt; polstat = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;PolicyStatement&lt;/FONT&gt;(permissions);&lt;/DIV&gt;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;//create a new codegroup&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;UnionCodeGroup&lt;/FONT&gt; gr = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;UnionCodeGroup&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;ZoneMembershipCondition&lt;/FONT&gt;(&lt;FONT color=#008080&gt;SecurityZone&lt;/FONT&gt;.Intranet),&lt;BR&gt;polstat);&lt;/DIV&gt;gr.Description = &lt;FONT color=#800000&gt;"Allow applications in the "&lt;/FONT&gt; + Company + &lt;FONT color=#800000&gt;" intranet"&lt;/FONT&gt;;&lt;BR&gt;gr.Name = CompanyCodeGroup;&lt;FONT color=#008080&gt;&lt;BR&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"\t"&lt;/FONT&gt; + CompanyCodeGroup + &lt;FONT color=#800000&gt;" added"&lt;/FONT&gt;);&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;if&lt;/FONT&gt; (domainName != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)&lt;BR&gt;{&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;//add as trusted zone&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;CodeGroup&lt;/FONT&gt; grTrusted = &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.GetCodeGroup(pl, &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;DefaultGroups&lt;/FONT&gt;.Trusted_Zone.ToString());&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (grTrusted != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;pl.RootCodeGroup.RemoveChild(grTrusted);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;else&lt;/FONT&gt;&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;grTrusted = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;UnionCodeGroup&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;ZoneMembershipCondition&lt;/FONT&gt;(&lt;FONT color=#008080&gt;SecurityZone&lt;/FONT&gt;.Trusted), &lt;FONT color=#0000ff&gt;&lt;BR&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;PolicyStatement&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt;(&lt;FONT color=#800000&gt;"Internet"&lt;/FONT&gt;)));&lt;/DIV&gt;grTrusted.Name = &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;.&lt;FONT color=#008080&gt;DefaultGroups&lt;/FONT&gt;.Trusted_Zone.ToString();&lt;/DIV&gt;}&lt;/DIV&gt;&lt;/DIV&gt;&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 60pt"&gt;UrlMembershipCondition&lt;/FONT&gt; ums = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;UrlMembershipCondition&lt;/FONT&gt;(domainName + &lt;FONT color=#800000&gt;"*"&lt;/FONT&gt;);&lt;FONT color=#008080&gt;&lt;BR&gt;UnionCodeGroup&lt;/FONT&gt; grD = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;UnionCodeGroup&lt;/FONT&gt;(ums, polstat);&lt;BR&gt;grD.Name = domainCodeGroupName;&lt;BR&gt;grD.Description = &lt;FONT color=#800000&gt;"Allow all applications in the domain "&lt;/FONT&gt; + domainName;&lt;BR&gt;grD.PolicyStatement = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;PolicyStatement&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt;(&lt;FONT color=#800000&gt;"FullTrust"&lt;/FONT&gt;));&lt;BR&gt;grTrusted.AddChild(grD);&lt;FONT color=#008080&gt;&lt;BR&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"\t"&lt;/FONT&gt;+ CompanyPermission + &lt;FONT color=#800000&gt;" (permissionset) added"&lt;/FONT&gt;);&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 60pt"&gt;pl.RootCodeGroup.AddChild(grTrusted);&lt;/DIV&gt;&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 60pt"&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"\tTrusted zone added"&lt;/FONT&gt;);&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;}&lt;/DIV&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;//NB use addchild and NOT Children.Add&lt;/FONT&gt;&lt;BR&gt;pl.RootCodeGroup.AddChild(gr); &lt;FONT color=#008000&gt;// .Children.Add(ZoneGroup);&lt;/DIV&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;//add the group&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;FrameworkSecurity&lt;/FONT&gt;.SetNamedPermissionSet(pl, permissions);&lt;/DIV&gt;&lt;FONT color=#008000&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;//save the changes&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;BR&gt;SecurityManager&lt;/FONT&gt;.SavePolicyLevel(pl);&lt;/DIV&gt;&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;Console&lt;/FONT&gt;.WriteLine(&lt;FONT color=#800000&gt;"Policy written to "&lt;/FONT&gt; + pl.Label + &lt;FONT color=#800000&gt;" level"&lt;/FONT&gt;);&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;}&lt;/DIV&gt;}&lt;BR&gt;&lt;FONT color=#808080&gt;&lt;BR&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&amp;lt;summary&amp;gt;&lt;BR&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; Functions around the security settings. Not all are needed perhaps, but like&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;BR&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; this I know where&amp;nbsp;&amp;nbsp;to find them ;-)&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;BR&gt;///&lt;/FONT&gt;&lt;FONT color=#008000&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;/SUMMARY&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;class&lt;/FONT&gt; &lt;FONT color=#008080&gt;FrameworkSecurity&lt;/FONT&gt;&lt;BR&gt;{&lt;BR&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;#region&lt;/FONT&gt; enums&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;enum&lt;/FONT&gt; &lt;FONT color=#008080&gt;Levels&lt;/FONT&gt;&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;Enterprise, Machine, User&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;enum&lt;/FONT&gt; &lt;FONT color=#008080&gt;DefaultGroups&lt;/FONT&gt;&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;My_Computer_Zone,&lt;BR&gt;LocalIntranet_Zone,&lt;BR&gt;Internet_Zone,&lt;BR&gt;Trusted_Zone,&lt;BR&gt;Restricted_Zone&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;enum&lt;/FONT&gt; &lt;FONT color=#008080&gt;DefaultPermissions&lt;/FONT&gt;&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;FullTrust,&lt;BR&gt;SkipVerification,&lt;BR&gt;Execution,&lt;BR&gt;Nothing,&lt;BR&gt;LocalIntranet,&lt;BR&gt;Internet,&lt;BR&gt;Everything&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;#endregion&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;#region&lt;/FONT&gt; Levels&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; GetLevel(&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level)&lt;BR&gt;{&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;IEnumerator&lt;/FONT&gt; policyEnumerator = &lt;FONT color=#008080&gt;SecurityManager&lt;/FONT&gt;.PolicyHierarchy();&lt;FONT color=#008000&gt;&lt;BR&gt;// Move through the policy levels to the Machine policy level.&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;while&lt;/FONT&gt; (policyEnumerator.MoveNext())&lt;BR&gt;{&lt;FONT color=#008080&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;PolicyLevel&lt;/FONT&gt; currentLevel = (&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt;)policyEnumerator.Current;&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (currentLevel.Label == level.ToString())&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; currentLevel;&lt;/DIV&gt;}&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;return&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;;&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;#endregion&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;#region&lt;/FONT&gt; PermissionSets&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; GetPermissionSet(&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetPermissionSet(level, Name, &lt;FONT color=#0000ff&gt;false&lt;/FONT&gt;);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; GetPermissionSet(&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name, &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; Create)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetPermissionSet(GetLevel(level), Name, Create);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; GetPermissionSet(&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; pl, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetPermissionSet(pl, Name, &lt;FONT color=#0000ff&gt;false&lt;/FONT&gt;);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; GetPermissionSet(&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; pl, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name, &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; Create)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;foreach&lt;/FONT&gt; (&lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; ps &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; pl.NamedPermissionSets)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;if&lt;/FONT&gt; (ps.Name == Name) &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; ps;&lt;/DIV&gt;}&lt;/DIV&gt;&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 40pt"&gt;if&lt;/FONT&gt; (Create)&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt;(Name);&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;return&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; GetPermissionSet(&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; pl,&lt;FONT color=#008080&gt;DefaultPermissions&lt;/FONT&gt; p)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetPermissionSet(pl, p.ToString());&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; GetPermissionSet(&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level, &lt;FONT color=#008080&gt;DefaultPermissions&lt;/FONT&gt; p)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetPermissionSet(level, p.ToString());&lt;/DIV&gt;}&lt;/DIV&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; SetNamedPermissionSet(&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; pl,&lt;FONT color=#008080&gt;NamedPermissionSet&lt;/FONT&gt; ns)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;if&lt;/FONT&gt;(pl.GetNamedPermissionSet(ns.Name) != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;pl.ChangeNamedPermissionSet(ns.Name,ns);&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;else&lt;/FONT&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;pl.AddNamedPermissionSet(ns);&lt;/DIV&gt;&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;#endregion&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;#region&lt;/FONT&gt; Code groups&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; GetCodeGroup(&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetLevel(level).RootCodeGroup;&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; GetCodeGroup(&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetCodeGroup(GetLevel(level), Name);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; GetCodeGroup(&lt;FONT color=#008080&gt;Levels&lt;/FONT&gt; level, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name, &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; Recursive)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetCodeGroup(GetLevel(level), Name, Recursive);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; GetCodeGroup(&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; pl, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetCodeGroup(pl.RootCodeGroup, Name);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; GetCodeGroup(&lt;FONT color=#008080&gt;PolicyLevel&lt;/FONT&gt; pl, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name, &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; Recursive)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetCodeGroup(pl.RootCodeGroup, Name, Recursive);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; GetCodeGroup(&lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; InGroup, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;return&lt;/FONT&gt; GetCodeGroup(InGroup, Name, &lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;);&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;public&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; &lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; GetCodeGroup(&lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; InGroup, &lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; Name, &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; Recursive)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;if&lt;/FONT&gt; (Name == &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;) &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; InGroup;&lt;FONT color=#008080&gt;&lt;BR&gt;CodeGroup&lt;/FONT&gt; res = &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;;&lt;FONT color=#0000ff&gt;&lt;BR&gt;foreach&lt;/FONT&gt; (&lt;FONT color=#008080&gt;CodeGroup&lt;/FONT&gt; gr &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt; InGroup.Children)&lt;BR&gt;{&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;if&lt;/FONT&gt; (gr.Name == Name)&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;res = gr;&lt;FONT color=#0000ff&gt;&lt;BR&gt;break&lt;/FONT&gt;;&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (Recursive)&lt;BR&gt;{
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;res = GetCodeGroup(gr, Name, Recursive);&lt;FONT color=#0000ff&gt;&lt;BR&gt;if&lt;/FONT&gt; (res != &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;) &lt;FONT color=#0000ff&gt;break&lt;/FONT&gt;;&lt;/DIV&gt;}&lt;/DIV&gt;}&lt;FONT color=#0000ff&gt;&lt;BR&gt;return&lt;/FONT&gt; res;&lt;/DIV&gt;}&lt;/DIV&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;#endregion&lt;/DIV&gt;&lt;/FONT&gt;&lt;BR&gt;}&lt;FONT color=#0000ff&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV ondblclick="var o = parentNode.firstChild;o.sel =1;o.click()" style="DISPLAY: none; BACKGROUND-COLOR: #dcdcdc"&gt;&lt;B&gt;. . .&lt;/B&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;!-- 
End of code block----&gt;&lt;img src ="http://blogs.vbcity.com/hotdog/aggbug/5907.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Robert Verpalen</dc:creator><title>Whidbey: retrieving all SQL server instances</title><link>http://blogs.vbcity.com/hotdog/archive/2005/06/06/2031.aspx</link><pubDate>Mon, 06 Jun 2005 03:55:00 GMT</pubDate><guid>http://blogs.vbcity.com/hotdog/archive/2005/06/06/2031.aspx</guid><description>&lt;P&gt;One of the things that was always an issue (at least for me ;-) ) was to get a list of all sql servers available to the machine the code was run at.&lt;/P&gt;
&lt;P&gt;Sure, there was the sqldmo,netserverenum&amp;nbsp;and even a method using odbc, but each needed api calls (or interop). But for those of you interested: great news:&amp;nbsp;whidbey has the requiring of the information build in !!!!&amp;nbsp;:-)&lt;BR&gt;The&amp;nbsp;&lt;A href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/winfx/ref/ns/system.data.sql/c/sqldatasourceenumerator/sqldatasourceenumerator.asp"&gt;SqlDataSourceEnumerator&lt;/A&gt; gives back a datatable with information on the available servers. (See the link to find out precisely what information)&lt;/P&gt;
&lt;P&gt;From .net 2.0 and up, filling a listbox with the server-names can be as simple as:&lt;BR&gt;&lt;FONT size=2&gt;listBox1.DisplayMember = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"ServerName"&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;listBox1.DataSource = System.Data.Sql.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;SqlDataSourceEnumerator&lt;/FONT&gt;&lt;FONT size=2&gt;.Instance.GetDataSources();&lt;/P&gt;&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/hotdog/aggbug/2031.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Robert Verpalen</dc:creator><title>Hotdog's guide to maintainable code</title><link>http://blogs.vbcity.com/hotdog/archive/2005/05/11/1841.aspx</link><pubDate>Wed, 11 May 2005 08:55:00 GMT</pubDate><guid>http://blogs.vbcity.com/hotdog/archive/2005/05/11/1841.aspx</guid><description>&lt;P&gt;&lt;FONT size=2&gt;This guide holds a couple of points to what my personal view is regarding what sort of code is well maintainable. They are only my opinion and therefore by no means actual rules. Some subjects may seem quite obvious, but nonetheless these points are often not used. &lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;The points are used as general as possible to programming languages in general. Most things are the same in procedural as well as object oriented environment. Sometimes reference are made to language specific elements in eg vba, vb6, vb.net or C#, but mostly it's just general programming. &lt;BR&gt;The most simple rule: most copy and paste is bad! Cut and paste to a new function or method is much better. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;The guide is a work in progress one, adding things as they come along. At this stage it's a looooong way from finished. For pseudo code a vb'ish approach is chosen, because this can be read by most programmers. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;B&gt;&lt;A name=Index&gt;Index:&lt;/A&gt;&lt;/B&gt; &lt;BR&gt;&lt;A href="#constants"&gt;Constants&lt;/A&gt; &lt;BR&gt;&lt;A href="#structures"&gt;Structures&lt;/A&gt; &lt;BR&gt;&lt;A href="#loops"&gt;Loops&lt;/A&gt; &lt;BR&gt;&lt;A href="#splitcode"&gt;Split code&lt;/A&gt; &lt;A href="#objects"&gt;&lt;BR&gt;Use objects&lt;/A&gt; &lt;BR&gt;&lt;A href="#stronglytyped"&gt;Structures&lt;/A&gt; &lt;A href="#wrappers"&gt;&lt;BR&gt;Wrappers&lt;/A&gt; &lt;BR&gt;&lt;A href="#documentation"&gt;Documentation&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;/P&gt;&lt;A name=constants&gt;
&lt;H3&gt;constantly use constants (or variables)&lt;/H3&gt;
&lt;P&gt;&lt;/A&gt;It doesn't have to be a constant, it can also be a variable, but reuse that value! If you have to use a value twice, put it in a constant if possible, otherwise a variable. It's that simple. It may be more work to set up, but it can save you a whole lot of headaches! The same with calculations, don't copy and paste them! If you need them twice, put the result in a variable or function. &lt;/P&gt;
&lt;P&gt;A simple example: a tax percentage in calculations. Now here's something that's used a lot and might never change, but what if it does? In the Netherlands the percentage is 19% (for normal products and rates, food products and some other exemptions use a different percentage) It's very easy to simply use 1.19 each time to calculate the price including taxes. A previous employer used to do that and of course everything worked fine. Now the luck was, so far that value itself hasn't changed. The consequences would be enormous. It is used in global code, in forms, in reports and a simple search and replace of 19 would not be possible. What would be safer is to define a constant (double 0.19) and reuse that. For getting the price including taxes, you could use a function. That way: change the constant, and everything works ok. Reusing a value hard coded will give non compile errors which means a lot of harm can be done before the user ever finds out that he has calculated profits wrong for an extended period. And you know who'll get the blame.. (and rightly so in this case :-/ ) &lt;BR&gt;Having the calculation and value in one place is not only the best for if the value itself changes. Once I got the request of having the taxes variable per clienth, since the customer also had Belgian and German customers himself, for whom the percentage was different. He didn't expect this to be a big adaptation, but it certainly was! It would have been an adaptation anyhow, but there was no way I could guarantee that everything was calculated in the right manner, because all over the place the 19 was hard coded. This particular piece of software was written in Access (hey not my choice ;-) ) which made it harder: it could be used in reports, in calculated fields in a form and in macro's. Luckily the latter weren't used, but in forms and reports, that value could not be found unless going through all the seperate forms in designmode: no search and replace possible in those. &lt;FONT size=1&gt;As a sidenote, I ended up writing a tool that searched through all fields in all forms and in all reports, but all that could have been avoided simply by using function. It did have to be a function in this case, because the customer country is important as well, so the function needed at least 2 parameters. Changing the function would cause compilation to show all the points that need to be altered. Access is a bad example in this case because the calculated fields in forms and reports are never compiled. That's why I think Access is great for (and intended for) quick projects, but not for resale projects&lt;/FONT&gt; &lt;BR&gt;The above is an example with a very rigid value, but I've seen primary keys used in this way -shock- . Yep, using a pkey hard coded is dangerous in itself, but it was used multiple times in the code and I don't mean with a variable.... You can imagine the fun that could create when dealing with a development backend versus a production backend... Besides: the readability is often much easier when using named variables. &lt;BR&gt;Don't even get me started on repeated calculations :-p Ever seen this:&lt;I&gt; If (somecalculation) &amp;gt; 0 then functionA(somecalculation) else functionB(somecalculation)&lt;/I&gt; A setup like this means that the calculation is always done twice (once for the comparisson and once for one of the blocks). Not only does this give an overhead, but it also means that if you want to alter the calculation, you need to do it three times. If the blocks are this small, you will notice that the calculation is redone, but with a couple of lines between them, you may miss that second calculation. All that could be prevented by simply assigning the result to a temporary variable. Not that much effort and much safer. &lt;/P&gt;
&lt;P&gt;&lt;FONT color=red&gt;wrong:&lt;/FONT&gt; &lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color=blue&gt;function PrepareProductA_Order(Q as integer)&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Q mod 4 &amp;lt;&amp;gt; 0 then&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; display message: "the quantity has to be a multitude of 4"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if CheckNumberOfBoxes(Q/4)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CreateLabel(Q/4,4)&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SubtractBoxes(Q/4) &lt;BR&gt;&lt;FONT color=blue&gt;end of function&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;In the example CreateLabel is a function that creates a barcode label and needs the number of boxes and the number of products per box. SubtractBoxes edits the value of boxes in stock. A logical next step would be to subtract the ProductA quantity or whatever, but more things miss from the code. No result is being returned for example, but that's outside the focus of what the example is meant for ;-) Better would be: 
&lt;BLOCKQUOTE&gt;&lt;FONT color=blue&gt;Constant ProductAperBox = 4 &lt;BR&gt;&lt;BR&gt;function PrepareProductA_Order(Q as integer)&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if Q mod ProductAperBox &amp;lt;&amp;gt; 0 then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;display message: "the quantity has to be a multitude of " &amp;amp; ProductAperBox&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;boxes as integer = Q/ProductAperBox&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if CheckNumberOfBoxes(boxes)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CreateLabel(boxes,ProductAperBox )&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SubtractBoxes(boxes)&lt;BR&gt;&amp;nbsp;&lt;FONT color=blue&gt;end of function&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Lots of variations might be possible on the code, but the general line is: don't hard code values unless necessary (retrieving the value out of an user editable backend might be better) and if you do hard code them: do it once. &lt;/P&gt;
&lt;P&gt;Another example: this I saw not only at my previous work, but is a very commonly seen scenario. Of course it isn't wrong, but if you add or remove&amp;nbsp;a control in this scenario, you have to do it at 2 places. Sounds easy enough, but it's also easily forgotten.&lt;BR&gt;This example only has 4 fictional controls, but actual code exists with a page filling blocks.&lt;BR&gt;&lt;FONT color=#ff0000&gt;wrong:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color=blue&gt;if&amp;nbsp;&lt;FONT color=#808080&gt;SomeCriteriumStatementHere&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control1.Enabled = true&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control2.Enabled = true&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control3.Enabled = true&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control4.Enabled = true&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;else&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control1.Enabled =&amp;nbsp;false&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control2.Enabled =&amp;nbsp;false&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control3.Enabled =&amp;nbsp;false&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control4.Enabled = false&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;
&lt;P&gt;Better:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color=blue&gt;booleanVariable b =&amp;nbsp;&lt;FONT color=#808080&gt;SomeCriteriumStatementHere&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control1.Enabled =&amp;nbsp;b&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control2.Enabled =&amp;nbsp;b&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control3.Enabled =&amp;nbsp;b&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control4.Enabled = b&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Better still: use &lt;A href="#loops"&gt;loops&lt;/A&gt;&amp;nbsp;The example above still depends on a repitition of code which could also be 'dangerous'. See the &lt;A href="#loops"&gt;loops&lt;/A&gt;&amp;nbsp;section if you want to know why ;-)&lt;/P&gt;
&lt;P&gt;&lt;A href="#index"&gt;Back to index&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;
&lt;P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;H3&gt;Structurize with structures&lt;/H3&gt;
&lt;P&gt;One much occuring scenario is that an address (like in the real world you know, not like one of those pointer thingies)&amp;nbsp;is used. For that address a couple of variables of different types are used. But those variables are rarely needed individually, mostly the entire address is used. Then can't we pass the address as a whole, as a single element. Of course we can :)&lt;/P&gt;
&lt;P&gt;For an example why don't we take something not so everyday as an address of person data. With those by now we know what to expect and use structures right away (don't you ;-) )&lt;BR&gt;Let's take a simple scenario where a program keeps score. Important for procedures in this point in time is just the Name and score.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color=blue&gt;-- under construction --&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;IIn the beginning days the only choice we had of keeping data indexed, was with a 'multi-dimensional' array. As long as you're working on that bit of code your head knows exactly what arr(0,1,3) points to. You may even have it documented (you should anyway ;-) ), but having to change something a couple of months later on is a headache generating business. &lt;BR&gt;And what for? If we make a structure (as it's called in .net, the vb6 and vba equivalent is a Type) or even a class, that array can contain a much, much clearer picture of what it contains. Granted, if you want to &lt;A href="#loops"&gt;Loop&lt;/A&gt; a lot, the multidimensional array can be more convenient, but languages such as the .net ones, can implement that behaviour with reflection. &lt;/P&gt;
&lt;P&gt;Can't remember of languages of Turbo Pascal had something as types, but they have been around for quite some time now. Still they were one of the unknowns to a lot of vb6 programmers. The main reason of this was probably that many available examples still used multi-dimensional arrays. Don't get me wrong, sometimes multi-dimensional arrays are still needed. It will depend on the situation whether a structure is used or a multidimensional array, but often the latter is used unnecessarily.&lt;/P&gt;
&lt;P&gt;--Example coming later --- &lt;/P&gt;
&lt;P&gt;&lt;A href="#Index"&gt;Back to index&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;
&lt;P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;A name=loops&gt;
&lt;H3&gt;Use loops&lt;/H3&gt;
&lt;P&gt;Loops are one of the first thing that were introduced into programming, because that simply was the only way that you could ensure for example going through an entire collection of unknown length. At the most basic level, this simply means that the 'next' returns to the memory address the first line of the 'for' began, until a criterium is met which jumps to the address after the 'next'.&lt;/P&gt;
&lt;P&gt;Loops are mostly used for going through collections, but why limit yourself to existing collections? In the constants section, the following example was used:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color=blue&gt;booleanVariable b =&amp;nbsp;&lt;FONT color=#808080&gt;SomeCriteriumStatementHere&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control1.Enabled =&amp;nbsp;b&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control2.Enabled =&amp;nbsp;b&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control3.Enabled =&amp;nbsp;b&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Control4.Enabled = b&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Nothing wrong with that code on itself, but what a shame of putting .enabled every time... This on itself may be quickly enough done, but now you decide, it has to be enabled, but readonly. Search and replace, yeah sure, why not. Now you decide you want to make it readonly and set a tooltip. You get the picture.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color=blue&gt;Array controls = &lt;FONT color=#000000&gt;{Control1,Control2,Control3,Control4}&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;booleanVariable b =&amp;nbsp;&lt;FONT color=#808080&gt;SomeCriteriumStatementHere&lt;BR&gt;&lt;FONT color=#0000ff&gt;foreach&lt;/FONT&gt; &lt;FONT color=#000000&gt;LoopControlVariable&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt; controls&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LoopControlVariable.Enabled = b&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Adding controls is simply adding to the array. Changing the behaviour for all is simply changing inside the loop. The array creation itself depends on the language being used, but there's always an easy way to create one(although in vb6/vba I generally had to create inbetween functions using a paramarray :-/ ) The controls in the example are called neatly called ControlX, making another loop possible, but actual controls won't be that neatly numbered of course. If you use the same collection multiple times, that of course can be put in its own functions or declared at the form initialization.&lt;BR&gt;&lt;/P&gt;&lt;/A&gt;&lt;A href="#Index"&gt;Back to index&lt;/A&gt; 
&lt;HR&gt;
&lt;BR&gt;
&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;
&lt;H3&gt;Split up code&lt;/H3&gt;
&lt;P&gt;Long blocks of code are often the hardest to debug. It is unclear, what portion does what. Even when commented start of this and end of that, what the debugger is looking at, is a long list of text. Splitting that block of code into several sub-methods is easier to look at and helps with the reusability.&lt;/P&gt;
&lt;P&gt;This section will be a somewhat abstract one, since there are no clear outlines as to when code should be split up. Then again, if you have seen methods that fill a couple of pages, you'll hopefully agree with the need of splitting up code.&lt;/P&gt;
&lt;P&gt;In the 'old' days, blocks of code were all that was possible. Methods did not exist. The code lines were numbered and you could goto/gosub such a line, but no matter how much I liked the old C64, that's not something I'd choose for now ;-)&lt;BR&gt;Even with the procedural programming that was introduced next, you'll still have some scenarios that will call for long blocks of code because of all the variables used, but in the OOP world, that's no excuse either.&lt;/P&gt;
&lt;P&gt;For more on the latter,&amp;nbsp;there's the&amp;nbsp;'&lt;U&gt;&lt;FONT color=#800080&gt;Use objects'&lt;/FONT&gt;&lt;/U&gt; section, but to start with the more general approach, imagine a form constructor (or load event), which initializes that form. It sets up a new dataconnection, it determines which controls should be disabled for the current user and builds up a (context)menu specific for that same user.&lt;/P&gt;
&lt;P&gt;You could say they sound like specific steps, and so they also can be easily implemented: a method for each step. This may sound like overkill at first, but keeping those steps separated will also prevent variables interfering with each other. Though the downside could be that more variables may have to be declared, because they can no longer be reused, this also helps with adapting the code at a later point. -- if there is an amount of variables reused in the methods, implementing an object instead should be considered --&lt;/P&gt;
&lt;P&gt;If the 1st advantage is readability (and thus maintainability), the 2nd advantage would be the reusability. If the current-user changes or his/her rights change, steps 2 and 3 would have to be done a 2nd time. Keeping that in mind, the structure of 3 methods for the 3 steps, is not entirely what we want.&lt;/P&gt;
&lt;P&gt;As you might have commented in yourself already, having steps 2 and 3 completely separated, would call for determining the current user twice and the way the current user is determined may change some time as well. The first step there of course would be to use a function.&lt;BR&gt;The 2nd is to have one method that calls the methods for steps 2 and 3. This method can be seen as the method that sets the user options. All in all, instead of one potentially large block, the layout would look more like:&lt;FONT color=#0000ff&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT color=blue&gt;Method SetDataConnection&lt;BR&gt;&lt;BR&gt;UserObject function GetCurrentUser() &lt;/FONT&gt;&lt;FONT color=#008000&gt;(this can be a global&amp;nbsp;function&amp;nbsp;)&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;Method SetUser&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#000000&gt;UserObject UserVariable = GetCurrentUser()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SetControls(UserVariable)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CreateMenu(UserVariable)&lt;/FONT&gt;&lt;BR&gt;End Method&lt;/FONT&gt;&lt;BR&gt;(for those languages that support overloading, an extra option would be to insert an extra method:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method SetUser(UserObject))&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;Method SetControls(UserObject)&lt;BR&gt;&lt;BR&gt;Method CreateMenu(UserObject)&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I realize all too well, that this would be too much overkill if the steps themselves are just a couple of lines of code. Unless I need to reuse them, I would keep those lines together in the load event as well. But still neatly in their own little blocks, so if they needed to be split after all, methods could be created quickly.&lt;BR&gt;All in all, it depends on how large the block is becoming and not always will we be able to have anticipated the code-growth, but it's something to keep in the back of our heads, just in case we will need to split that code up later. And of course, if it's known from the beginning that the code will become a large block, split it up right away.&lt;BR&gt;Finally the example above would cause double coding if the menu creating and control enabling were entangled in the same loop or used a lot of the same variables. Be sure to think of creating an object in that case!&lt;/P&gt;
&lt;P&gt;&lt;A href="#Index"&gt;Back to index&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;A name=objects&gt;
&lt;H3&gt;Use objects&lt;/H3&gt;
&lt;P&gt;As&lt;/A&gt; described in the&amp;nbsp;&lt;A href="#structures"&gt;Structures&lt;/A&gt;&lt;A name=objects&gt; section, keeping multiple related values inside a structure (= also an object) keeps them nicely together and easier to pass around.&lt;/A&gt;&amp;nbsp;But now we want to be able to do all sorts of things with those values, we need to check if an address is valid or if a user has specific rights. Or maybe we just have to do a lot of calculations and keep a subresult.&lt;/P&gt;
&lt;P&gt;Now what is often seen, is that a bunch of methods are added, that take the structure as a parameter or worse yet if no structures are used, a lot of loose variables. But the whole intention of OOP is that a method can be called from within that object itself. &lt;/P&gt;
&lt;P&gt;Although the difference in a lot of modern OOP languages no longer exists in this manner, for this guide we'll see structures as objects that just contain values (think of vb6 types) and objects as elements that can also contain methods/functions and properties.&amp;nbsp;In this viewing point, all structures are objects, but an object doesn't have to be a structure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;For the sake of mentioning it: in modern languages as .net, structures can have methods and functions as well. The difference is in how they are stored, but that's outside the scope of this guide. There are several articles on structures versus objects on the internet if you look for them.&lt;/P&gt;
&lt;P&gt;Objects and OOP is not just something invented for the fancy words. They really can make your programming life a lot easier. Further than that, they make some programming that seemed almost impossible, much easier. We just mustn't forget to use those options.&lt;/P&gt;
&lt;P&gt;&lt;A href="#Index"&gt;Back to index&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;A name=stronglytyped&gt;
&lt;H3&gt;Keep things strongly typed&lt;/H3&gt;
&lt;P&gt;&lt;/A&gt;&lt;A href="#Index"&gt;Back to index&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;A name=wrappers&gt;
&lt;H3&gt;Wrap things up&lt;/H3&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/A&gt;&lt;A href="#Index"&gt;Back to index&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;
&lt;HR&gt;
&lt;BR&gt;&lt;BR&gt;
&lt;P&gt;&lt;/P&gt;&lt;A name=documentation&gt;
&lt;H3&gt;Document your code&lt;/H3&gt;
&lt;P&gt;&lt;/A&gt;Yeah, yeah, I know, is probably your first reaction. At least it would be if I read this :D Still, this very point is the most easily neglected. Especially when in the middle of developing, the start goes well, documenting the important functions. Then you delete that function and all documentation was for nothing. That's the main reason I skip documentation, until there's a form of final draft. Only.... then you're busy with something else. &lt;/P&gt;
&lt;P&gt;I wouldn't be able to tell you at which stage you should document. There may be alot of opinions on that subject, but the truth is: "it always depends". Many times documentation you will call a function and find it undocumented. Although late, this might be a good time to do a quick documentation (assuming it is your function). Since you're calling it, you'll probably know at that time what it does. The details will come back to you when going through it. But 2 months later, you'll have to dive much deeper to recollect the same. Let alone when working with multiple people on the same project. Especially .net has great methods to document functions and classes (with the summarize tags), making even creating an msdn style help interface a breeze, but you will still need to document. &lt;BR&gt;The bottom line: if you skip such a basic part as doing a basic documentation, you may have a lot more work laid out for you later on. &lt;BR&gt;&lt;B&gt;NB&lt;/B&gt;: I'm absolutely &lt;B&gt;not&lt;/B&gt; talking about those anoyingly long 'rules' that some companies implement on each and every function described with every function described. Commentary should be useful, not obligatory. &lt;/P&gt;
&lt;P&gt;eg. some pseudecode (green is commentary, it's only pseudocode, so I didn't include any tags or commentary characters): &lt;/P&gt;
&lt;P&gt;This is &lt;FONT color=red&gt;&lt;B&gt;useless&lt;/B&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT color=green&gt;---------------------------------------------------------------------- &lt;BR&gt;function: GetCurrentUserName &lt;BR&gt;---------------------------------------------------------------------- &lt;BR&gt;&lt;BR&gt;description: returns name of current user &lt;BR&gt;&lt;BR&gt;returns: name of current user &lt;BR&gt;&lt;BR&gt;returntype: string &lt;BR&gt;&lt;BR&gt;parameters: none &lt;BR&gt;&lt;BR&gt;----------------------------------------------------------------------&lt;/FONT&gt;&lt;FONT color=blue&gt; &lt;BR&gt;string-function GetCurrentUserName&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return CurrentUser.Name&lt;BR&gt;&lt;FONT color=blue&gt;&amp;nbsp;end of function&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;Some companies expect comment blocks like this, so the programmer makes them, but adds nothing. The only effect the commentary has, is a Homer Simpson 'duh' reaction. Now imho it only makes finding code harder. I've seen the example above where the comment block is much larger then the function itself with non helpful commentary. Even where the function was only one line and the name of the function said everything that it did, it had about 6 lines of commentary formed as in the example above. &lt;BR&gt;If you have a piece of code with a lot of these functions underneath eachother, this can be very annoying. Of course this is just an opinion. If you include commentary, make sure it says something (and otherwise keep it short ;-) ), eg: 
&lt;BLOCKQUOTE&gt;&lt;FONT color=green&gt;returns the name of the user as it was validated in the current thread. &lt;BR&gt;For more info see &lt;I&gt;reference to CurrentUser property&lt;/I&gt; &lt;BR&gt;---------------------------------------------------------------------&lt;/FONT&gt;&lt;FONT color=blue&gt; &lt;BR&gt;string-function GetCurrentUserName&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return CurrentUser.Name&lt;BR&gt;&lt;FONT color=blue&gt;&amp;nbsp;end of function&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The line&amp;nbsp; (------) is optional and will depend on the IDE being used. In some IDE's the separation between functions wil be clear enough. In the .net designer, the summery and other xml tags make lines as this unnecessary. &lt;/P&gt;
&lt;P&gt;&lt;A href="#Index"&gt;Back to index&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;/P&gt;&lt;A name=""&gt;
&lt;H3&gt;&lt;/H3&gt;&lt;/A&gt;&lt;A href="#Index"&gt;Back to index&lt;/A&gt; &lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/hotdog/aggbug/1841.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Robert Verpalen</dc:creator><title>Website for my wife</title><link>http://blogs.vbcity.com/hotdog/archive/2005/04/23/1616.aspx</link><pubDate>Sat, 23 Apr 2005 02:41:00 GMT</pubDate><guid>http://blogs.vbcity.com/hotdog/archive/2005/04/23/1616.aspx</guid><description>&lt;P&gt;The website: &lt;A href="http://www.colourfulnails.tk/"&gt;www.colourfulnails.tk&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;My wife sets arificial nails and one of the rooms in our house has been turned into a salon. Of course that also meant that she needed a website. To be truthful, I never actually made a website before, and my first endeavours with JavaScript and HTML in general were with the &lt;A href="http://blogs.vbcity.com/hotdog/archive/2004/09/11/280.aspx"&gt;RTF to HTML converter&lt;/A&gt;&amp;nbsp;(BTW, I noticed&amp;nbsp;&lt;A href="http://www.submain.com/Default.aspx"&gt;PrettyCode.print&lt;/A&gt;&amp;nbsp; has conversion to HTML build into it, so anyone interested in that kind of conversion is probably a lot better off by using PrettyCode)&lt;BR&gt;So this was a nice oppertunity to try out some 'webbing' and once again I have to say I like the build up of web objects and how they interact with JavaScript (although debugging is a pain in the ... uhm... nose for example. Since the whole thing was done from ground up, that is, no use of existing scripts, there was a lot of debugging involved :-( )&lt;/P&gt;
&lt;P&gt;Anyway, the result is in the &lt;A href="http://www.colourfulnails.tk/"&gt;link&lt;/A&gt;&amp;nbsp;above and my wife asked me to share it on this blog (the more hits the merrier I suppose ;-) ), although for non Dutch speakers that website will mean little and the style may not appeal to the male viewers, perhaps the lady population has some comments how some changes might attract them more to get artificial nails. :-) (First thing would be pictures, but there are no pictures on the site yet, we need to get or borrow a digital cam first :-/ )&lt;/P&gt;&lt;img src ="http://blogs.vbcity.com/hotdog/aggbug/1616.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>