<?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>bc-programming &#187; Theory</title>
	<atom:link href="http://bc-programming.com/blogs/category/theory/feed/" rel="self" type="application/rss+xml" />
	<link>http://bc-programming.com/blogs</link>
	<description>Programming, Possums, Ponies, and why you shouldn&#039;t mix any two.</description>
	<lastBuildDate>Wed, 16 May 2012 23:06:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>AMD &amp; Intel, Past, Present &amp; Future</title>
		<link>http://bc-programming.com/blogs/2012/03/amd-intel-past-present-future/</link>
		<comments>http://bc-programming.com/blogs/2012/03/amd-intel-past-present-future/#comments</comments>
		<pubDate>Sun, 25 Mar 2012 20:34:53 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[General Computing]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Theory]]></category>
		<category><![CDATA[AMD]]></category>
		<category><![CDATA[Bearbait]]></category>
		<category><![CDATA[CISC]]></category>
		<category><![CDATA[Concurrency]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Intel]]></category>
		<category><![CDATA[Parallelization]]></category>
		<category><![CDATA[Pentium]]></category>
		<category><![CDATA[RISC]]></category>
		<category><![CDATA[Superscalar]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=947</guid>
		<description><![CDATA[AMD, like Cyrix VIA, and Nextech (I believe was the name) were all clone makers, they made pin compatible processors for PCs. Their primary advantage was their lower cost. the AMD k5, designed to compete with the Pentium, as a Socket 5 processor just like the Pentium. The idea was that as a lower cost [...]]]></description>
			<content:encoded><![CDATA[<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2012/03/amd-intel-past-present-future/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><p>AMD, like Cyrix VIA, and Nextech (I believe was the name) were all clone makers, they made pin compatible processors for PCs.  Their primary advantage was their lower cost. the AMD k5, designed to compete with the Pentium, as a Socket 5 processor just like the Pentium. The idea was that as a lower cost alternative their processors could be used in machines instead of Intel&apos;s. AMD, specifically, excelled in integer operations, doing them a lot faster than the equivalent Intel Processor. So in some cases the AMD processor was not only cheaper but also a better choice, if it was for use in applications that did a lot of integer arithmetic. Nextech was working on a new processor to compete with the Pentium and the K6; AMD bought the company and relabelled the in-development Nextech chip the K6-2; the K6 and K6-2 are completely different processors, and not in any way the same (they were basically designed by two different companies). The K6-2 supported a set of 3-D extensions (much like MMX)- whether this was Nextech or AMD that implemented it, I don&apos;t remember- at the same time it supported MMX, and it&apos;s floating point performance no longer sucked ass, and was very nearly comparable to Intel&apos;s offering.</p>
<p>Over time, all the other clone vendors died, or were purchases; VIA, to my recollection, bought Cyrix, made a few processors (the VIA Samuel C3 being the only one I distinctly recall) and then killed their processor division entirely, focusing on their motherboards and embedded solutions. AMD became the only competitor to intel that had any &#8220;weight&#8221;. Also, as their processors became equal to Intels both in performance and price, they started being made using different Pin designs. I believe this was originally because the socket or slot for some Pentium processor was patented so AMD couldn&apos;t make a compatible equivalent; at the very least, the Pentium itself was named the Pentium- rather than the 586- in order to prevent other vendors from using the same name. </p>
<p>One interesting thing about the Pentium Processor is that it is the first CISC instruction set processor to be considered SuperScalar. This is because of it&apos;s pipeline architecture which allows it to, in many cases, execute two instructions per clock cycle. The Pentium came in two revisions; the earlier versions didn&apos;t have things like MMX, and in many cases had the infamous FPU issue (Intel Errata #23). The second generation came in higher clock speeds (90Mhz, 100Mhz,and 133Mhz, as opposed to the 50 and 75Mhz of their original incarnations), as well as any number of improvements, such as a smaller die size and an on-chip APIC. It didn&apos;t have MMX, that was the third revision, which came in even higher clock speeds, FSB/Clock:66/166,66/200,66/233,66/266  (mobile only for the last one). the third revision had MMX, a smaller still die size, lower voltage requirements, a 16KB write-back cache (compared to the earlier versions 8KB). The interesting thing about some pentium boards, including those designed for slot CPUs, is that a lot of them actually had two processor slots. Usually the second one was labelled &#8220;for testing only&#8221; but you could literally plug in another processor and have dual processors. The only downside is that you pretty much required Windows NT to use them (9x doesn&apos;t support multiple cores or processors). Heck that wouldn&apos;t even work with XP Home, which only supports a single physical processor.</p>
<p>AMD&apos;s lower cost offerings impacted Intel&apos;s market, so they came up with their own low-cost alternatives. Which isn&apos;t too surprising given they&apos;d been doing that for years, with the 386SX and 486SX, The 386SX being a slower variant of the 386DX, whereas the 486SX was a 486DX with it&apos;s FPU disabled. Installing the companion &#8220;co-processor&#8221;, the 487SX was actually installing a 486DX, which then took over all system operations from the SX. In addition, they created lower-cost upgrade capabilities for the 486, since the k5 was almost feature par with the pentium (and better in some ways, with 6 5-stage instruction pipelines rather than 2). To compete with this they created the Pentium &#8220;Overdrive&#8221; chip, which would be installed in a 486DX board, and take over all operations from the installed 486DX. Naturally, it was on a 486 board so some operations would still be slow, particularly bus transfers and DMA, but it sped up processor intensive tasks, and sped up a lot of tasks because of that. Later, with the K6 and K6-2 eating into their Pentium II Market share, they came up with another lower cost segment, the Pentium Celeron.</p>
<p>sidebar:*technically, the first Intel 6th generation processor was not the Pentium II, but rather the Pentium Pro*</p>
<p>Of important note is that the first Celerons were not Pentium processors, but rather Pentium II processors; it took a generation for Intel to catch on to AMD&apos;s low-cost niche tactic and come up with a response in the celeron. The Celeron was typically a slotted processor, at least all that I&apos;ve seen are. The basic difference is that it has less on-die cache, and no L2 cache (some revisions had 128KB, compare to the Pentium II&apos;s standard 512KB). Ironically, the Celeron usually performed much worse than the K6 and K6-2 it was designed to compete with; Not to mention the awkwardness of the slotted processor design. Even so, and particularly through partnerships with retail computer manufacturers, Intel was able to squeeze the Celeron boards into the market. (the &#8220;Barbie&#8221; and &#8220;Hot wheels&#8221; machines from mid to late 1998 are a good example of this, since they sported celeron processors). The Celeron Brand lives on, but it is still a lower cost alternative to their other offerings, and is almost never a wise choice for a desktop machine. Many users are woo&apos;d by the higher clock speed, but with so little cache, the clock speed barely compensates.</p>
<p>The 6th generation gave us the above Pentium II&apos;s, Celerons and K6-2s; the seventh gave us Pentium 2s&#8230;. Wait? P2s? What about Pentium III&apos;s and K6-2s? Well, they aren&apos;t 7th gen processors, since they are based on the same die as the sixth gen chips (for Intel, this was the Pentium Pro, for AMD, the K6-2).</p>
<p>The Original Pentium III was practically a Pentium 2 with SSE (MMX2) and a higher clock speed. An interesting sidebar is that the P6 chips from intel (pentium Pro, Pentium II, and Pentium III) are only fully utilized by NT versions of windows; since the Microops that the CISC instructions are reduced to are optimized for use with 32-bit code. windows 9x executes a good half of the time in 16-bit mode (for compatibility with older software, mostly) so you don&apos;t get the biggest improvement with it.</p>
<p>Intel failed miserably on their first attempts at a consumer-appealing x64 architecture. The Itanium was 64-bit, but it&apos;s execution of 32-bit code had to be fully emulated. It found some uses in business and servers, but it&apos;s limited ability with 32-bit code abhorred it&apos;s adoption in the consumer sector.</p>
<p>AMD created it&apos;s own 64-bit processors, but made it so that 64-bit was just another &#8220;mode&#8221; of the processor. In this way, 32-bit code could be run quite easy with minimal virtualization. Intel followed suite with their own extensions that implemented the same instruction set as AMD, making it compatible.</p>
<p>I&apos;m not nearly as familiar with their history after around the Pentium III/Athlon XP area.</p>
<p>The two are practically the same now. They offer consumers a choice, but at the same time that choice is practically useless. The fact is that we&apos;ve pretty much hit the architectural limit that different die configurations can give us, and we are not easily able to reduce the process further without invoking the dangers of quantum tunnelling. The best considerations for the future is to add more processor cores, and, even more important, have software that is better able to extort the best power from those cores. My opinion is that the big problem right now is not the hardware, or the software, but rather the programming languages that are dominant in the industry today, largely C/C++. What is needed is the adoption of one of the myriad languages that have built in support for concurrent execution of constructs; for example, some languages are able to compile a simple for iterative construct in a way that it can execute on separate cores. This approach is particularly powerful in a stateless environment, such as a functional language. to that end many functional languages include built-in concurrency support. What makes this particularly interesting is that most programmers think of &#8220;concurrency&#8221; and immediately think of threads; but threading is only one of the ways that concurrency can be achieved, and it is one of the least powerful, as well. Erlang, for example, takes the approach of sending messages between processes, instead of having different threads. Since Erlang is a functional&apos; language, most of it&apos;s constructs are largely stateless; this is as opposed to most imperative languages which are typically state-heavy. It is the abundance of state in our standardized&apos; programming languages that is causing the difficulties we are seeing with concurrency, not the cores or the implementations thereof. Consider for a moment that most of the benchmarking tools being used to compare processors are he written in C/C++. In order to trust the performance results, you have to trust that the code is making the best use of the available hardware. But the fact is that imperative stateful programming abhors concurrency; threads deadlock, and you have data synchronization issues and race conditions to deal with. So, while processor performance benchmarks might state that a Bulldozer is &#8220;worse&#8221; than another CPU, I move that that result is as much a testament to weaknesses in the program and the stateful imperative programming paradigm at least with regards to it&apos;s use with concurrent solutions. This is why I have never put faith in benchmarks; the fact is that any weakness being shown could easily be an oversight or problem with the software being used to test. If a benchmark tool only uses two threads, how can you trust it&apos;s result when it runs on 6 cores? And even if it was to use more, you&apos;re still placing your trust in how the program was written. And while one could argue that the test will show how a lot of current software and games run on a given system, it doesn&apos;t test the actual potential of that system; a properly written game could be written to take advantage of 6 cores and it would scream compared to running that program with fewer cores. At this point, concurrency is the answer to improving system speed, and in order to properly leverage concurrency, we don&apos;t just need more cores, but we need software and programming languages that provide built-in support for concurrency constructs. C/C++ simply does not offer this, and while I&apos;m sure a library could be written that does, there are already loads of languages that provide built-in support for concurrency in any number of different ways; either through C# and .NET&apos;s addition of parallel constructs in C# 5.0, or the ability of functional languages to make assumptions because the code is primarily stateless and thus easier to make parallelize.</p>
<p>Personally I don&apos;t have a preference for either. I used a K6-2 for nearly 5 years, a Pentium 4 for about a year, and am now using Intel Q8200 and a laptop with a Intel T3200 (I think). Maybe my next build wilent l be AMD, I don&apos;t know. Either way, I&apos;m not going to base any of my choices on how a given system performed with a piece of software. The heart of the matter is that I never trust software. I don&apos;t even trust software I wrote half the time. Software is a loose thread on a sock. If you pull out the thread, the sock is going to fall down regardless of how well formed the ankle is, and you cannot declare &#8220;this ankle sucks, because my sock keeps falling down&#8221; just as you cannot say &#8220;This hardware sucks, because this piece of software says so&#8221;.</p>
<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2012/03/amd-intel-past-present-future/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://bc-programming.com/blogs/2012/03/amd-intel-past-present-future/&via=BC_Programming&text=AMD & Intel, Past, Present & Future&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div> <p><a href="http://bc-programming.com/blogs/?flattrss_redirect&amp;id=947&amp;md5=6edbbbdbf796ee114429d8a5f73aedb7" title="Flattr" target="_blank"><img src="http://bc-programming.com/blogs/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2012/03/amd-intel-past-present-future/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=bc_programming&amp;popout=1&amp;url=http%3A%2F%2Fbc-programming.com%2Fblogs%2F2012%2F03%2Famd-intel-past-present-future%2F&amp;language=en_GB&amp;category=software&amp;title=AMD+%26%23038%3B+Intel%2C+Past%2C+Present+%26%23038%3B+Future&amp;description=AMD%2C+like+Cyrix+VIA%2C+and+Nextech+%28I+believe+was+the+name%29+were+all+clone+makers%2C+they+made+pin+compatible+processors+for+PCs.+Their+primary+advantage+was+their+lower+cost.+the...&amp;tags=AMD%2CBearbait%2CC%23%2CCISC%2CConcurrency%2CErlang%2CIntel%2CParallelization%2CPentium%2CRISC%2CSuperscalar%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Anagram Search program</title>
		<link>http://bc-programming.com/blogs/2010/11/anagram-search-program/</link>
		<comments>http://bc-programming.com/blogs/2010/11/anagram-search-program/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 10:16:33 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Theory]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Functional Programming]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=372</guid>
		<description><![CDATA[And now, for something  completely different- a post that actually is about programming. A short overview of anagrams and a breakdown of a common algorithm that is used for discovering them. Breakdown An anagram is one word that is another word when you rearrange the letters; for example, &#8220;deposit&#8221; and &#8220;posited&#8221; are anagrams of one [...]]]></description>
			<content:encoded><![CDATA[<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2010/11/anagram-search-program/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><p>And now, for something  completely different- a post that actually is about programming. A short overview of anagrams and a breakdown of a common algorithm that is used for discovering them.<br />
<h2> Breakdown </h2>
</p>
<p>
An anagram is one word that is another word when you rearrange the letters; for example, &#8220;deposit&#8221; and &#8220;posited&#8221; are anagrams of one another; as are &#8220;dare&#8221; and &#8220;dear&#8221;. The idea behind the algorithm is that, given a list of words, to find out which words are anagrams of one another. This sounds fairly simple- one could conceivably create a function That determines if two words are anagrams of one another (by looping through the characters, comparing length, etc) and then use that function on every single possible pairing of the words in a dictionary.</p>
<p>This approach is simple-minded, and will take an intractably long time based on the number of words. For example, Linux systems generally have a word dictionary located at /user/share/dict/words not unlike the one you can download  <a href="http://www.freebsd.org/cgi/cvsweb.cgi/src/share/dict/web2"> here </a> ; in this case, the dictionary contains over 235,923 different words. Simply iterating through every word and comparing it to every other word will take 235,923 squared calls to the aforementioned &#8220;isAnagram&#8221; function; that&#8217;s over 55,659,661,929 separate comparisons! Even if the IsAnagram Function only took a millisecond to execute, that&#8217;s still over 55,656,661 seconds, or over  <b> two years </b> . Clearly this is not a good solution.</p>
<p>One method that problems like these can be solved is to realize that the best way of going about it is to change the problem into something that will &#8220;sort itself out&#8221; so to speak. For example, rather then searching through every word and comparing it to every other word to find  a match, one would be better off finding out what the words that are anagrams have in common, and how we can use that to our advantage. In the case of anagrams, what they have in common is rather simple; they have the same letters. The question is, how can we leverage this in a way that makes it easier to find groups of words that are anagrams of one another?</p>
<p>If we were able to create a unique value that all anagrams share that can be used to correlate them, we can create a data structure and only iterate through the list of words a single time. This value is the sorted letters of the word.</p>
<p>For example, both posited and deposit, when their letters are sorted create deiopst; in fact, it seems quite logical to conclude that all words that are anagrams of each other will create the same sorted sequence. This makes the entire thing almost crystal clear.</p>
<p>Instead of comparing every word to every other word in a brute-force approach, we can instead use a List indexed by the sorted strings, where each item contains a list of the words found that &#8220;sort&#8221; to that set of letters. For each word, we sort the letters, and then we look in the dictionary; if there is a existing item for that sorted set, we add it to the list that is already there, otherwise, we add a new one. Rather straightforward. </p>
<p>This is in fact a very old algorithm, conceived as early as the 60&#8242;s. The original concept was merely to bring together those words that were anagrams; the list was sorted based on the sorted letter set of each word, meaning that words whose component letters sorted the same would be contiguous in the list.</p>
<p>Here is the implementation of the Program in C#:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">using System;</div>
</li>
<li class="li1">
<div class="de1">using System.<span class="me1">Collections</span>.<span class="me1">Generic</span>;</div>
</li>
<li class="li1">
<div class="de1">using System.<span class="me1">IO</span>;</div>
</li>
<li class="li2">
<div class="de2">using System.<span class="me1">Linq</span>;</div>
</li>
<li class="li1">
<div class="de1">using System.<span class="me1">Text</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">namespace anagrammer</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; class Program</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//anagrammer: takes a word list on the command line and finds all words that are anagrams of one another.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">static</span> <span class="kw4">void</span> Main<span class="br0">&#40;</span><span class="kw4">string</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> &nbsp;args<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span>@<span class="st0">&quot;&quot;</span><span class="st0">&quot;Anagrammer&quot;</span><span class="st0">&quot; program for loading and finding anagrams in a list of words.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st0">Nov. 13 2010 Written by Michael Burgwin (http://bc-programming.com)&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach <span class="br0">&#40;</span><span class="kw4">String</span> loopargument in args<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EmitAnagrams<span class="br0">&#40;</span>loopargument<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; public <span class="kw4">static</span> <span class="kw4">void</span> EmitAnagrams<span class="br0">&#40;</span><span class="kw4">String</span> wordfile<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StreamReader wordreader = File.<span class="me1">OpenText</span><span class="br0">&#40;</span>wordfile<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="st0">&quot;Processing file&#8230;&quot;</span> + wordfile<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">String</span> alltext = wordreader.<span class="me1">ReadToEnd</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">String</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> &nbsp;words = alltext.<span class="me1">Split</span><span class="br0">&#40;</span>new <span class="kw4">string</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> &nbsp;<span class="br0">&#123;</span> <span class="st0">&quot;<span class="es0">\n</span>&quot;</span> <span class="br0">&#125;</span>, StringSplitOptions.<span class="me1">RemoveEmptyEntries</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="st0">&quot;Total words read:&quot;</span> + words.<span class="me1">Length</span> +<span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EmitAnagrams<span class="br0">&#40;</span>words<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// &nbsp;&lt;summary&gt; </span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// sorts the characters in the string, and returns the resulting &quot;sorted&quot; string.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// &nbsp;&lt;/summary&gt; </span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// &nbsp;&lt;param name=&quot;sumstring&quot;&gt; String to sort. &lt;/param&gt; </span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// &nbsp;&lt;returns&gt; Sorted string of the characters in SumString. &lt;/returns&gt; </span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">static</span> <span class="kw4">String</span> sortchars<span class="br0">&#40;</span><span class="kw4">String</span> sumstring<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List &lt;char&gt; &nbsp;sortme = sumstring.<span class="me1">ToList</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sortme.<span class="me1">Sort</span><span class="br0">&#40;</span><span class="br0">&#40;</span>a, b<span class="br0">&#41;</span> =&gt; a.<span class="me1">CompareTo</span><span class="br0">&#40;</span>b<span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> new <span class="kw4">string</span><span class="br0">&#40;</span>sortme.<span class="me1">ToArray</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//return sumstring.ToList().Sort((a, b) =&gt; a.CompareTo(b)));</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp;public <span class="kw4">static</span> <span class="kw4">void</span> EmitAnagrams<span class="br0">&#40;</span><span class="kw4">String</span> <span class="br0">&#91;</span><span class="br0">&#93;</span> &nbsp;words<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//algorithm: create a Dictionary; the keys are ints which are the sum of the character values</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//of the strings within, and the element is a list of strings.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dictionary &lt;string , List&lt;String&gt; &gt; anagramdict = new Dictionary &lt;/string&gt; &nbsp;&lt;string , List&lt;string&gt; &gt;<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="st0">&quot;creating Dictionary lookup tables&#8230;&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="st0">&quot; &nbsp;Only considering words &gt; 4 characters.&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach <span class="br0">&#40;</span><span class="kw4">String</span> loopword in words<span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>loopword.<span class="me1">Length</span> &gt; <span class="nu0">4</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">String</span> hashcode = sortchars<span class="br0">&#40;</span>loopword.<span class="me1">ToLower</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List &lt;/string&gt; &nbsp;&lt;string&gt; &nbsp;listuse = <span class="kw2">null</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!<span class="br0">&#40;</span>anagramdict.<span class="me1">TryGetValue</span><span class="br0">&#40;</span>hashcode, out listuse<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listuse = new List &lt;/string&gt; &nbsp;&lt;string&gt; <span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listuse.<span class="me1">Add</span><span class="br0">&#40;</span>loopword.<span class="me1">ToLower</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anagramdict.<span class="me1">Add</span><span class="br0">&#40;</span>hashcode, listuse<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>!listuse.<span class="me1">Exists</span><span class="br0">&#40;</span><span class="br0">&#40;</span>w<span class="br0">&#41;</span> =&gt; <span class="br0">&#40;</span>w.<span class="me1">Equals</span><span class="br0">&#40;</span>loopword.<span class="me1">ToLower</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listuse.<span class="me1">Add</span><span class="br0">&#40;</span>loopword<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="st0">&quot;Finished! results:<span class="es0">\n</span><span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List &lt;keyvaluepair &lt;String, List&lt;String&gt; &gt;&gt; sortedanagrams = anagramdict.<span class="me1">ToList</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//sort the list based on the size of each List therein&#8230;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sortedanagrams.<span class="me1">Sort</span><span class="br0">&#40;</span><span class="br0">&#40;</span>a, b<span class="br0">&#41;</span> =&gt; a.<span class="me1">Value</span>.<span class="me1">Count</span>.<span class="me1">CompareTo</span><span class="br0">&#40;</span>b.<span class="me1">Value</span>.<span class="me1">Count</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach <span class="br0">&#40;</span>KeyValuePair &lt;string , List&lt;String&gt; &gt; looplists in sortedanagrams<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>looplists.<span class="me1">Value</span>.<span class="me1">Count</span> &gt; <span class="nu0">1</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach <span class="br0">&#40;</span><span class="kw4">String</span> loopstring in looplists.<span class="me1">Value</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">Write</span><span class="br0">&#40;</span>loopstring + <span class="st0">&quot;,&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;&lt;/string&gt; &nbsp;&lt;/keyvaluepair&gt; &nbsp;&lt;/string&gt; &nbsp;&lt;/char&gt; &nbsp;</div>
</li>
</ol>
</div>
<p>Here, I leverage Generics, and also nest Generic Classes within one another; note the Dictionary <string ,List<String> > type, which creates a Dictionary that indexes lists of Strings via a string; in this instance, it indexes the lists of anagramatic words by the sorted letters of that word (which is merely a string, since a string is by definition a list of letters). On the aforementioned dictionary file it took about half a second to process the entire file and create the output. The results can be found  <a href="http://www.bc-programming.com/downloads/files/anagramlist2.txt"> here </a> . The dictionary appears to have a few esoteric terms; also, as can be seen in the source, it ignores all words less then 5 characters in length. </string>  </p>
<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2010/11/anagram-search-program/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://bc-programming.com/blogs/2010/11/anagram-search-program/&via=BC_Programming&text=Anagram Search program&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div> <p><a href="http://bc-programming.com/blogs/?flattrss_redirect&amp;id=372&amp;md5=0636c50ed253f3eed33bf7bd4f472e31" title="Flattr" target="_blank"><img src="http://bc-programming.com/blogs/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/11/anagram-search-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=bc_programming&amp;popout=1&amp;url=http%3A%2F%2Fbc-programming.com%2Fblogs%2F2010%2F11%2Fanagram-search-program%2F&amp;language=en_GB&amp;category=software&amp;title=Anagram+Search+program&amp;description=And+now%2C+for+something%C2%A0+completely+different-+a+post+that+actually+is+about+programming.+A+short+overview+of+anagrams+and+a+breakdown+of+a+common+algorithm+that+is+used+for+discovering...&amp;tags=.NET%2CAlgorithms%2CC%23%2CFunctional+Programming%2Cblog" type="text/html" />
	</item>
		<item>
		<title>Metrics: they simply don&#8217;t work.</title>
		<link>http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/</link>
		<comments>http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 03:29:05 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Theory]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=84</guid>
		<description><![CDATA[Companies and businesses want to prosper. At the core, being a successful business means that you make a sizable revenue; But, when those start to falter, how do businesses determine the cause? They generally measure something; for a programming firm, this may be lines of code written. For a restaurant, perhaps the time it takes [...]]]></description>
			<content:encoded><![CDATA[<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><p>Companies and businesses want to prosper. At the core, being a successful business means that you make a sizable revenue; But, when those start to falter, how do businesses determine the cause? They generally measure something; for a programming firm, this may be lines of code written. For a restaurant, perhaps the time it takes for a customer to be seated, and so forth. And on the surface, it makes sense.</p>
<p>The problem is, it only makes sense, <em> in theory </em> . Why? because both methods are trying to tack a quantitative statement onto something that cannot be measured in this way; additionally, they forget the human factor.</p>
<p>Let&#8217;s look at a hypothetical situation; Programmer Joe. Programmer Joe has worked at a Software startup since it&#8217;s early days, and enjoys his job. However, one day, the CEO calls them all into the office to discuss declining revenue. Realistically, the revenue is declining because a competitor has just released a product that directly competes with the startup&#8217;s flagship software package. However,  management believes that the loose leash they&#8217;ve been keeping the programmers on is to blame; so one of the idea men determines that they should implement a management technique known as metrics. In this case- they start with something basic; each programmer&#8217;s performance will be judged directly correspondent to the number of lines of code they write.</p>
<p>Programmer Joe continues his work as normal; he notices some of his co-workers checking in code that re-rolls standard library routines, and cuts out excess code like this. One day he&#8217;s called into the Project Manager&#8217;s office.</p>
<p>&#8220;Joe&#8230; I don&#8217;t know quite how to explain this- maybe you can. Somehow, you&#8217;ve managed to accumulate a  [i] negative [/i]  lines per day metric&#8230; any idea how that is possible?&#8221;</p>
<p>&#8220;Well, I&#8217;ve noticed a lot of redundant code being checked in, and trimmed it down. the code still works the same way- it&#8217;s just faster; also, I&#8217;ve managed to fix half the bugs on the list just by doing that.&#8221;</p>
<p>The Project Manager may, in this case, take this particular information to the higher levels. they decide that the metric is flawed- what they need ot measure is lines of code written minus the number of bugs introduced.</p>
<p>A feature request arrives from a client near the end of the day, at 4:30PM. the Project Manager asks if Joe can look over the request and if he can maybe stay late to try to get some of those features implemented. So Joe spends the next three hours creating a prototype for the new feature and once he has the main functionality down he checks the code in and goes home. The next day, Joe continues his work on this new feature. However, he is once again called into the Project Manager&#8217;s office.</p>
<p>The Project manager hands Joe a large stack of papers.</p>
<p>&#8220;you know what those are, Joe?&#8221;</p>
<p>&#8220;No&#8230;&#8221;</p>
<p>&#8220;Those are the bug reports filed on code you&#8217;ve checked in recently.&#8221;</p>
<p>&#8220;All the code I&#8217;ve been working on recently has been a prototype&#8230; I haven&#8217;t yet gotten it fully integrated into the rest of the system.&#8221;</p>
<p>&#8230;</p>
<p>I think you can see where I was going there. basically, the fact is that havign a measuring metric that measures small fiobles in the entire process is doomed to cause hiccups within that process and even bring business to a standstill. In this case, rather then worry about the number of lines of code written or the number of bugs introduced, it might be better to focus on fixing the bugs and adding features; the number of lines of code in a project does not directly correspond to the quality of that project as a whole, and in some cases can even do so inversely.</p>
<p>In a strange coincidence, a local Coffee shop that Programmer Joe visits on his way to work had noticably changed. When Joe used to go though their drive thru to grab his morning coffee and a box of donuts for his colleagues, the staff were friendly and often asked him how things were going. Recently, however, Joe has felt like a piece of scrap metal on an assembly line. Once he got to the pay window, he would often hear audible grumbles of discontent as he simply reached into his pocket for his wallet. His donuts have often been obviously simply thrown in the box with little care, too. Joe couldn&#8217;t understand it, since these were the very same people that would serve him before. Eventually, Joe decided to go elsewhere for his morning coffee.</p>
<p>The previous paragraph is not an entire fabrication; in fact, I work at a location that does just this. They time every single drive thru customer&#8217;s time at the window, and it&#8217;s treated as the single most important measurement of performance in the entire store. I&#8217;d even go so far as to say it seems to be used to reflect directly customer satisfaction. However, this simply is not the case. The franchise, in particular, places a recommended limit of 42 seconds for waiting at the window. a reasonable time frame, depending on the volume of customers. However, at my location it has now been decreed that we shall not take longer then 30 seconds or, from what I hear of others, they will be verbally &#8220;abused&#8221; about it.</p>
<p>In any case, a little backstory is probably in order. Lately it would appear that revenue has been dwindling; there are far fewer customers then I remember coming in, at all times of the day. Additionally, various seemingly pedantic rules have been places on our release of such seemingly trite things as butters and napkins. It&#8217;s fair to assume in this case that they obviously want to bring business back up again- and that is certainly something anybody in that position would try to do.</p>
<p>However, with that said, they are going about it wrong. In the Retail and Customer Service industry- where almost all revenue is coming from consumers who purchase your product by coming to your establishment, the all-time, 100% most important thing for business is customer satisfaction. No exceptions. Interestingly enough, since this has started, I&#8217;ve gotten dozens of complaints from Customers who visit regularly about the shoddy way they were treated while going through the drive thru at some other time during the day. This certainly is not the fault of the workers at the time; since, as I said, they are essentially being &#8220;forced&#8221; to try to reduce times to &lt;30 seconds. But when you get customers, the main source of revenue for the store, complaining about something that is the result of a change to the store policy that was introduced to try to increase revenue it is pretty solid evidence that the technique has failed miserably.</p>
<p>The problem here is not that those in charge know, as well as anybody else, that customer satisfaction is the single most important thing to the stores success, but rather in that they have tried to assign a single metric to measure this particular quality. And they do not correspond. I certainly won&#8217;t argue that customers prefer fast service— it certainly is on their list of hopes when they enter a drive-thru to be out as fast as possible— but I think what one needs to realize is that having their orders (literally) thrown into their car for the sake of speed of service doesn&#8217;t please the customer. They aren&#8217;t going to think, &#8220;well, golly, they threw the sandwich right into the passenger seat and refused to carry on a quick little bit of small-talk while I waited, but damn, it took only 30 seconds, so I am going to say I am satisfied&#8221;. I&#8217;m sorry, but this does not happen. As long as a customer is not waiting an exceedingly long time for their purchase, they tend not to notice it. Think of it this way- there is the old adage where you can either have fast service, good service, or right service, but you can only choose two. I put forth that, for many consumers it also holds true that when one of these is omitted, and the other two are done in a way that exceeds their expectations, they are likely to generally be satisfied. For example, if a customer is greeted with courteous fervor, and perhaps a friendly conversation ensues in addition to their order being made perfect, they are less likely to notice that they had to wait in the line for a few minutes. Now, if they had to wait that same amount of time and they were treated brashly, they are more likely to take offense. In fact, the single most important thing to almost all customers is not the time they wait, or even the fact that their order is made perfectly to their specifications, but rather to be treated as people, and not as some mindless consumer whose particular interests and concerns are of no importance. The sad fact is using this particular measurement metric encourages the workers to do the latter.</p>
<p>The thing is, there are even further flaws in the mechanism. First, the device doesn&#8217;t even work half the time, so times come out skewed and sometimes two vehicles get counted in the same interval. Additionally, since the time measured is the entire time the customer is at the window, this is not simply a measure of the efficiency of the workers to get the product to the customer but also a test of how quickly the customer can pay for their product. if a customer needs to dig for change for 10 extra seconds after the employees have successfully finished their entire order and simply await payment, why is this 10-seconds attributed to the detraction of the employees? &#8220;Because we have no way of knowing&#8221; the people who read the recorded times may say. The issue here is that obviously if there is one fact you don&#8217;t know about what the measurement indicates then there are certainly more, and in fact it could even be put forth that the measurement is completely meaningless. a Customer could be at the window for 10 seconds and still not be pleased, be it because of the shoddy service received while being squeezed through in a tiny window of time, or because they got their order mixed up with another, or some other error instigated by the fact that inhuman demands are made of people there. On the converse, a person could wait for a entire minute at the window and still be perfectly pleased with their service, so using the measure of window time as some sort of barometer by which to judge the performance of a business is downright ridiculous, and this only multiplies when one considers that such time-based constraints are not placed on those consumers who decide to enter the establishment for their service.</p>
<p>And while the latter example has certainly acquired far more attention for personal reasons, it certainly is no more or less ludicrous then the software companies implementation; performance metrics have been tried in nearly every industry and in every industry they have failed to provide the hoped for results. The key here is that the measure is not strictly of customer satisfaction or even of revenue; but more directly, of the value of the business.</p>
<p>Value is a perception and must be communicated and measured to be  perceived as value. Value measurement is the process by which management  decides on operational performance measures that will enable them to  secure the the owners return on investment. Value measures must be  aligned with the business strategy positioning the business. Measurement  includes measuring lead factors and lag factors. Lead factors identify  performance measures that will proactively provide an indication of  whether objectives will be achieved or not. Lead factors allow  management to receive warning sign proactively. Lag factors measure how  successful management was in terms of creating value. Financial reports  are the ultimate lag measures of success. When a business lead measures  indicate that the business is performing well but the business lag  factors are showing the contradictory then it is time to review the lead  measures.</p>
<p>The value measurement process determines the  behaviour of the business and aligns the behaviour of human capital with  the value expectations of all stakeholders e.g. owners,  management, customers, employees and partners. Value should be measured  and reported on from every stakeholder&#8217;s perspective. A true balanced  scorecard will drive performance improvements for all five stakeholder  dimensions. This all applies to ANY business, regardless of industry.</p>
<p>Flipping quickly back to software, an excellent overview of the problems present with Performance metrics as used in that industry can be found here: http://discuss.joelonsoftware.com/default.asp?biz.5.304155.19 </p>
<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/&via=BC_Programming&text=Metrics: they simply don't work.&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div> <p><a href="http://bc-programming.com/blogs/?flattrss_redirect&amp;id=84&amp;md5=613f96bbdc1e08217cc885f997b7c40a" title="Flattr" target="_blank"><img src="http://bc-programming.com/blogs/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2010/02/metrics-they-simply-dont-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=bc_programming&amp;popout=1&amp;url=http%3A%2F%2Fbc-programming.com%2Fblogs%2F2010%2F02%2Fmetrics-they-simply-dont-work%2F&amp;language=en_GB&amp;category=software&amp;title=Metrics%3A+they+simply+don%26%238217%3Bt+work.&amp;description=Companies+and+businesses+want+to+prosper.+At+the+core%2C+being+a+successful+business+means+that+you+make+a+sizable+revenue%3B+But%2C+when+those+start+to+falter%2C+how+do+businesses+determine...&amp;tags=blog" type="text/html" />
	</item>
		<item>
		<title>Triple-Clicks revisited: implementing N-Clicks</title>
		<link>http://bc-programming.com/blogs/2009/11/triple-clicks-revisited-implementing-n-clicks/</link>
		<comments>http://bc-programming.com/blogs/2009/11/triple-clicks-revisited-implementing-n-clicks/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 15:59:30 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[subclassing]]></category>
		<category><![CDATA[Theory]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=22</guid>
		<description><![CDATA[In my previous entry, I discussed and provided code that would allow for the detection of Triple-Clicks on a window. By extending the provided architecture, it is relatively trivial to allow any number of consecutive clicks; for example, detecting pentuple clicks. The revisions are pretty easy; in my case, I created a structure to hold [...]]]></description>
			<content:encoded><![CDATA[<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2009/11/triple-clicks-revisited-implementing-n-clicks/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><p>In my previous entry, I discussed and provided code that would allow for the detection of Triple-Clicks on a window. By extending the provided architecture, it is relatively trivial to allow any number of consecutive clicks; for example, detecting pentuple clicks.</p>
<p> <span id="more-22">  </span> </p>
<p>The revisions are pretty easy; in my case, I created a structure to hold what I previous had in a few module-level variables, to keep track of various data about each consecutive &#8220;click set&#8221; if that is a proper word to use here. Things such as the first click position, the last click position (these will obviously be the same for the &#8220;first&#8221; consecutive click (which is just a single-click, really) but could be used in later clicks to compare the distance values used, retrieved via GetSystemMetrics() using the SM_DRAGX and SM_DRAGY constants,(or was it SM_XDRAG and SM_YDRAG&#8230;) and comparing these values with the difference between each successive click. The ideal solution would be to compare each click position with the first click position, so that the clicking cannot move across the object very far from where the first click took place. The logic is pretty simple, and should be easy to follow. The project can be downloaded from  <a href="http://bc-programming.com/downloads/files/multiclick.zip"> here </a> .This is a tad different then the previous one, and is instead implemented as a sort of  &#8220;game&#8221;.</p>
<p>There are a few design and User interface considerations when using Multiple clicks in your UI; the most prevalent is probably that unless you tell your users that they can triple-click or quadruple click, they likely will not try it- that is, it isn&#8217;t really that intuitive. Additionally, when you do implement this behaviour, remember that, for example, with a triple click, a double click was already fired and handled before that; so don&#8217;t make successive clicks do vastly different things. the ideal scenario is to use successive clicks to do the same thing, but change the scope; for example, Word allowed you to click,double-click, and triple click text. the first click sets the position of the cursor, the second click selects the word that the cursor is in, and a triple click selects a paragraph. (In the outlook editor it actually selects the sentence I think, but let&#8217;s not split hairs&#8230;). In fact, it would make sense to conclude that as an unsaid rule you should only use triple clicks to build on behaviour that the single and double-clicks before them have already done, just as word does. if you make triple-clicks do something esoteric, such as, for example, triple clicking a drawing to save, consider instead opting for a toolbar button or menu item to perform this task, or perhaps a key combination (or both). </p>
<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2009/11/triple-clicks-revisited-implementing-n-clicks/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://bc-programming.com/blogs/2009/11/triple-clicks-revisited-implementing-n-clicks/&via=BC_Programming&text=Triple-Clicks revisited: implementing N-Clicks&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div> <p><a href="http://bc-programming.com/blogs/?flattrss_redirect&amp;id=22&amp;md5=3965d436946ca86a4167d158f0899aeb" title="Flattr" target="_blank"><img src="http://bc-programming.com/blogs/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2009/11/triple-clicks-revisited-implementing-n-clicks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=bc_programming&amp;popout=1&amp;url=http%3A%2F%2Fbc-programming.com%2Fblogs%2F2009%2F11%2Ftriple-clicks-revisited-implementing-n-clicks%2F&amp;language=en_GB&amp;category=software&amp;title=Triple-Clicks+revisited%3A+implementing+N-Clicks&amp;description=In+my+previous+entry%2C+I+discussed+and+provided+code+that+would+allow+for+the+detection+of+Triple-Clicks+on+a+window.+By+extending+the+provided+architecture%2C+it+is+relatively+trivial+to...&amp;tags=blog" type="text/html" />
	</item>
		<item>
		<title>Programming languages: an opinion piece.</title>
		<link>http://bc-programming.com/blogs/2009/10/programming-languages-an-opinion-piece/</link>
		<comments>http://bc-programming.com/blogs/2009/10/programming-languages-an-opinion-piece/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 20:08:18 +0000</pubDate>
		<dc:creator>BC_Programming</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Theory]]></category>

		<guid isPermaLink="false">http://bc-programming.com/blogs/?p=4</guid>
		<description><![CDATA[An analysis of various programming paradigms, a representative from each, and why it doesn't matter.]]></description>
			<content:encoded><![CDATA[<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2009/10/programming-languages-an-opinion-piece/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><p>When entering the domain of programming, one finds a plethora of programming languages to choose from; and there are more being introduced nearly every day. Each language was designed for a purpose. From Assembly language, designed simply as a way to write machine code easier, to C, designed to be as &#8220;close to the machine&#8221; as possible without actually becoming a low-level language, and Perl, designed for text processing.</p>
<p>The interesting thing? They don&#8217;t have to be used as designed. Perl, while created by Larry Wall to make text processing of reports easier, has been applied in all sorts of problem domains effectively. Visual Basic can be used to write STDCall DLLs. Scripting languages, once relegated to creating silly animations to annoy users visiting web pages, has found use both on the desktop as well as server side web processing.</p>
<p>As the Information Technology industry has aged so too have the techniques used for programming. new techniques are tried all the time. Previously, the widely held winning formula was called &#8220;Structured programming&#8221; because, rather then using Goto&#8217;s or conditional jumps, the language itself contained constructed for &#8220;structuring&#8221; code, a method that allows the code to be more readable and organized. It also embraced a top-down approach, whereby the &#8220;function&#8221; is created before the routine that requires it. Original &#8220;pioneers&#8221; for this strategem are numerous, but the recognized &#8220;original breeds&#8221; are  Pascal and C. Pascal was created as a teaching tool. by enforcing a number of things widely held asgood programming practice as part of the language, it &#8220;conditioned&#8221; new programmers to keep these habits when they moved to other languages. As Pascal evolved, however, it was made more useful, and more applicable to the creation of real applications. C, on the other hand, was designed to allow programmers easy access to a wide variety of functions, both of the language as well as the &#8220;bare metal&#8221;. This &#8220;bare metal&#8221; approach was facilitated with &#8220;naked&#8221; functions as well as inline assembly.</p>
<p>The &#8220;Structured Programming&#8221; concept dominated the academic circles, and was implemented as a standard by programming firms the world over. However- there was a pattern to how it was used, and this pattern, once recognized, was used to develop the &#8220;next leap&#8221;.</p>
<p>Program source code that was &#8220;structured&#8221; had it&#8217;s many components separated into various modules, and procedures. Each module would often hold the structure definitions and the procedures to handle them. For example, a program designed to graph functions might have a module, perhaps, modFunctions, depending on the naming convention. This module would define the &#8220;structure&#8221;- or in memory representation &#8211; of the various properties of a function- the expression, range, etc. The routines in the module would be used to manipulate draw, set, and retrieve the various items stored in the structure.</p>
<p>Eventually, this was migrated into the structure itself- that is, a structure might be defined to hold both the data relevant to the function as well as pointers to routines that manipulated it. The common convention was that the first parameter to these routines would be a pointer to the structure being acted on.</p>
<p>This type of programming was first implemented in C, and it worked great. essentially, it combined the concepts of Functions, and the data they manipulated, and created a single entity- the resulting structure. Oftentime the only routine required was a function that returned a pointer to the structure, after initializing the various function pointers. this because known as a constructor.</p>
<p>The problem with this technique was simply that there was a lot of work involved with using this technique- initializing pointers and other &#8220;bookkeeping&#8221; type tasks. the concept, however, was solid. Languages sprung up that implemented this technique internally, and exposed only those parts of the &#8220;object&#8221; as it became known, that needed to be coded or used. The concept spread like wildfire. Languages that once conformed to the &#8220;structured&#8221; paradigm were adapted and given object-based features. Pascal variants known as &#8220;Object Pascal&#8221; which more fully implemented the loosely object-like syntax of Pascal itself, were created. C was extended into C++, implementing nearly all of the Object Oriented concepts, such as inheritance and interfaces, and so forth. BASIC, in the form of Visual Basic, got Object Based, and later, with VB4, loosely object oriented. Entire languages sprung up on the concept that a &#8220;purely&#8221; object-oriented language would be the best choice. An early language of this form- or more precisely, the first more popular language of this form, was Java.</p>
<p>With Java, everything was an object. a simple console application was comprised of at least one object. at this point, the code that created the objects, &#8211; the very &#8220;template&#8221; from which they were instantiated, were known as &#8220;classes&#8221;. it was not until a &#8220;class&#8221; was instantiated that it became an object.</p>
<p>While Java, with it&#8217;s pure Object Oriented approach, created clean code as opposed to a structured language, or half-object based language, it also had shortfalls. While Object Oriented Programming was a excellent concept- it couldn&#8217;t always be used to apply to everything, and oftentimes a short quick little program was all that was needed. Java was however well suited to internet applications, since it was also a byte-code based interpreted language.</p>
<p>Now that the Object Oriented approach has matured and entire frameworks have been created based on the concept, such as .NET, one cannot help but wonder wether the idea is to make it easier for the programmer or the user. Just because a language makes it easier to program, or a certain conceptual method of creating said program makes it trivial to do something, doesn&#8217;t mean that the user&#8217;s experience with the application is any better. What if a user requests a feature not implemented by the run-time? Sure, there are &#8220;native&#8221; method calls in almost all such language, but is this not, in some sense, an admittance of defeat? that the Object Oriented approach is not flawless? Or, perhaps it is less controversial- maybe it is simply a lesser admittance of failure on the part of the Object Oriented design set forth by the creator of the framework.  But the fact remains- the framework does not make implementing the feature easier. Is this not what the framework is for, however?</p>
<p>So the ultimate question is- are we any better, now, with class framework and libraries all around us, then we were when we had basic Input/output and generic function libraries, and were left to fend for ourselves with all sorts of mundane programming tasks that we now take for granted? </p>
<div id="fcbk_share"><div class="fcbk_like">
										<div id="fb-root"></div>
										<script src="http://connect.facebook.net/en_US/all.js#appId=224313110927811&amp;xfbml=1"></script>
										<fb:like href="http://bc-programming.com/blogs/2009/10/programming-languages-an-opinion-piece/" send="false" layout="button_count" width="450" show_faces="false" font=""></fb:like>
									</div></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://bc-programming.com/blogs/2009/10/programming-languages-an-opinion-piece/&via=BC_Programming&text=Programming languages: an opinion piece.&related=:&lang=en&count=horizontal" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div> <p><a href="http://bc-programming.com/blogs/?flattrss_redirect&amp;id=4&amp;md5=41531d4d726dc6a90276472875fef24a" title="Flattr" target="_blank"><img src="http://bc-programming.com/blogs/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://bc-programming.com/blogs/2009/10/programming-languages-an-opinion-piece/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=bc_programming&amp;popout=1&amp;url=http%3A%2F%2Fbc-programming.com%2Fblogs%2F2009%2F10%2Fprogramming-languages-an-opinion-piece%2F&amp;language=en_GB&amp;category=software&amp;title=Programming+languages%3A+an+opinion+piece.&amp;description=When+entering+the+domain+of+programming%2C+one+finds+a+plethora+of+programming+languages+to+choose+from%3B+and+there+are+more+being+introduced+nearly+every+day.+Each+language+was+designed+for...&amp;tags=blog" type="text/html" />
	</item>
	</channel>
</rss>

