<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Just Enough Technology &#187; Tips</title>
	<atom:link href="http://justenoughtechnology.com/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://justenoughtechnology.com</link>
	<description>The passion to see business leverage technology both powerfully and economically</description>
	<lastBuildDate>Thu, 20 May 2010 00:18:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Create Singleton in C#</title>
		<link>http://justenoughtechnology.com/create-singleton-in-csharp/</link>
		<comments>http://justenoughtechnology.com/create-singleton-in-csharp/#comments</comments>
		<pubDate>Tue, 11 May 2010 04:02:57 +0000</pubDate>
		<dc:creator>Dave Ranck</dc:creator>
				<category><![CDATA[Architecture and Design]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://justenoughtechnology.com/?p=309</guid>
		<description><![CDATA[One of the most basic and most useful object patterns is the Singleton design pattern. A Singleton is a class of which there will only be one instance created at any time. All users of the Singleton class will all use the same instance. This is great for a wide range of applications such as [...]


Related posts:<ol><li><a href='http://justenoughtechnology.com/find-a-string-between-2-strings/' rel='bookmark' title='Permanent Link: Find a String Between 2 Strings'>Find a String Between 2 Strings</a></li>
<li><a href='http://justenoughtechnology.com/restore-sql-database/' rel='bookmark' title='Permanent Link: Restore SQL Database'>Restore SQL Database</a></li>
<li><a href='http://justenoughtechnology.com/title-case-csharp/' rel='bookmark' title='Permanent Link: Title Case in C#'>Title Case in C#</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>One of the most basic and most useful object patterns is the Singleton design pattern. A Singleton is a class of which there will only be one instance created at any time. All users of the Singleton class will all use the same instance. This is great for a wide range of applications such as cached values and lookups or utilities that execute quickly. The Design Patterns book by Gamma et al . describes the structure of a basic Singleton. We&#8217;ll describe how to create one in C#. </p>
<p> <span id="more-309"></span>
<p>The classic approach to creating a Singleton looks like this:    </p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> SingletonGamma
 {
      <span class="kwrd">private</span> <span class="kwrd">static</span> SingletonGamma instance;
      <span class="kwrd">private</span> SingletonGamma()  { }

      <span class="kwrd">public</span> <span class="kwrd">static</span> SingletonGamma Instance
     {
         get </pre>
<pre class="csharpcode">         {
            <span class="kwrd">if</span> (instance == <span class="kwrd">null</span>) { instance = <span class="kwrd">new</span> SingletonGamma(); }
            <span class="kwrd">return</span> instance;
         }
     }
 } </pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>
  </p>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>The basic approach is&#160; to create a private constructor and an Instance method that returns the current instance if available, or returns a new instance if there is no current instance. We call that &quot;lazy instantiation&quot;. The problem with this approach in C# is that it is not strictly thread-safe. That is, it is possible for 2 threads to create separate instances is some circumstances. This is not what we are looking to do. This approach does have an advantage in that there is a hook-point to do post-instantiation processing if required. In .Net though, this is not the approach usually recommended</p>
<p>The following example takes advantage of the better handling of variable ambiguity in .Net (vs. C++) to create a thread-safe Singleton:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">sealed</span> <span class="kwrd">class</span> SingletonCSharp
    {
        <span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">readonly</span> Singleton instance = <span class="kwrd">new</span> SingletonCSharp();

        <span class="kwrd">private</span> SingletonCSharp() { }

        <span class="kwrd">public</span> <span class="kwrd">static</span> SingletonCSharp Instance
        {
            get
            {
                <span class="kwrd">return</span> instance;
            }
        }
    }</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>
  <br />This is the preferred approach in C# and is adequate for most programs. There are other approaches that allow for more flexibility and still maintain thread safety, but they introduce unnecessary complexity for most programs. Note the read only instance property that can only be set during instantiation and the sealed keyword that prevents inheritance of the class which could introduce unwanted side effects, such as secondary instances. This is a simple and straightforward approach to the design pattern. The only downside is the lack of flexibility to have non-standard constructors. For most applications, that will not be an issue.</p>


<p>Related posts:<ol><li><a href='http://justenoughtechnology.com/find-a-string-between-2-strings/' rel='bookmark' title='Permanent Link: Find a String Between 2 Strings'>Find a String Between 2 Strings</a></li>
<li><a href='http://justenoughtechnology.com/restore-sql-database/' rel='bookmark' title='Permanent Link: Restore SQL Database'>Restore SQL Database</a></li>
<li><a href='http://justenoughtechnology.com/title-case-csharp/' rel='bookmark' title='Permanent Link: Title Case in C#'>Title Case in C#</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://justenoughtechnology.com/create-singleton-in-csharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 God Mode</title>
		<link>http://justenoughtechnology.com/windows-7-god-mode/</link>
		<comments>http://justenoughtechnology.com/windows-7-god-mode/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 17:34:53 +0000</pubDate>
		<dc:creator>Dave Ranck</dc:creator>
				<category><![CDATA[Business and Technology]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://justenoughtechnology.com/windows-7-god-mode/222/</guid>
		<description><![CDATA[Just found a little tip / secret for Windows 7 that&#8217;s been making the rounds on the Internet. It enables “GodMode” – a term created by the Windows 7 development team. This secret “mode” provides a single place to access all the important Windows settings without having to drill down through a multitude of menus [...]


Related posts:<ol><li><a href='http://justenoughtechnology.com/windows-azure-now-available/' rel='bookmark' title='Permanent Link: Windows Azure Now Available'>Windows Azure Now Available</a></li>
<li><a href='http://justenoughtechnology.com/146/' rel='bookmark' title='Permanent Link: Windows Azure Videos'>Windows Azure Videos</a></li>
<li><a href='http://justenoughtechnology.com/move-user-profile-to-2nd-drive-in-win-7/' rel='bookmark' title='Permanent Link: Move User Profile to 2nd Drive in Win 7'>Move User Profile to 2nd Drive in Win 7</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just found a little tip / secret for Windows 7 that&#8217;s been making the rounds on the Internet. It enables “GodMode” – a term created by the Windows 7 development team. This secret “mode” provides a single place to access all the important Windows settings without having to drill down through a multitude of menus and folders in Control Panel. This tip is one of my favorites.</p>
<p><strong>Here’s how to do it:</strong></p>
<ol>
<li>Create a new folder.</li>
<li>Rename the folder to <strong>GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}</strong>(note that you can change the “GodMode” text, but the following period and code number are essential).</li>
<li>The folder icon will change to  — double click it to show the <em>GodMode</em> window.<br />
<img class="alignleft" style="border: 0pt none; margin-left: 6px; margin-right: 6px;" src="http://justenoughtechnology.com/wp-content/uploads/2010/02/Win7GodFolder_small.jpg" border="0" alt="Win7GodFolder" hspace="6" width="56" height="64" align="left" /></li>
</ol>
<p><span id="more-222"></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The image below shows what you see in the GodMode window. There a host of links to utilities and settings. Having them all in one place is extremely convenient. This secret trick appears to work in Windows 7 32 and 64 bit, Windows Server 2008 32 bit and Vista 32 bit. BUT, it seems to crash Vista 64 bit. You have been warned <img src='http://justenoughtechnology.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><img src="http://justenoughtechnology.com/wp-content/uploads/2010/02/Win7GodModeList.jpg" border="0" alt="Win7GodModeList" /></p>
<div class="bjtags">Tags:  <a rel="tag" href="http://technorati.com/tag/Windows+7">Windows+7</a>, <a rel="tag" href="http://technorati.com/tag/God+Mode">God+Mode</a>, <a rel="tag" href="http://technorati.com/tag/Vista">Vista</a>, <a rel="tag" href="http://technorati.com/tag/Windows+Server+2008">Windows+Server+2008</a>, <a rel="tag" href="http://technorati.com/tag/Control+Panel">Control+Panel</a>, <a rel="tag" href="http://technorati.com/tag/Configuration">Configuration</a></div>


<p>Related posts:<ol><li><a href='http://justenoughtechnology.com/windows-azure-now-available/' rel='bookmark' title='Permanent Link: Windows Azure Now Available'>Windows Azure Now Available</a></li>
<li><a href='http://justenoughtechnology.com/146/' rel='bookmark' title='Permanent Link: Windows Azure Videos'>Windows Azure Videos</a></li>
<li><a href='http://justenoughtechnology.com/move-user-profile-to-2nd-drive-in-win-7/' rel='bookmark' title='Permanent Link: Move User Profile to 2nd Drive in Win 7'>Move User Profile to 2nd Drive in Win 7</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://justenoughtechnology.com/windows-7-god-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
