<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>::raven::set</title>
	<atom:link href="http://ravenspoint.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ravenspoint.wordpress.com</link>
	<description>Day-to-Day Software Engineering at Raven&#039;s Point</description>
	<lastBuildDate>Sat, 28 Jan 2012 16:32:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ravenspoint.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>::raven::set</title>
		<link>http://ravenspoint.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ravenspoint.wordpress.com/osd.xml" title="::raven::set" />
	<atom:link rel='hub' href='http://ravenspoint.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Into the Cloud</title>
		<link>http://ravenspoint.wordpress.com/2012/01/28/into-the-cloud/</link>
		<comments>http://ravenspoint.wordpress.com/2012/01/28/into-the-cloud/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 11:53:30 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=18</guid>
		<description><![CDATA[For nearly a decade now I have been developing high performance, elegant windows desktop applications. In the meantime the rest of the world as been moving ‘into the cloud’. Such web applications were once sluggish and clunky, but the simplicity &#8230; <a href="http://ravenspoint.wordpress.com/2012/01/28/into-the-cloud/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=18&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For nearly a decade now I have been developing high performance, elegant windows desktop applications.</p>
<p>In the meantime the rest of the world as been moving ‘into the cloud’. Such web applications were once sluggish and clunky, but the simplicity of no user installation, universal availability and instant upgrades of the entire user base trumped all other considerations.</p>
<p>A year ago I delivered my fist web application. <a href="http://66.199.140.183:8000/guitar/default/index" target="_blank">Guitar </a>informs the user when their guitar was built and by whom, if they type in the serial number.  It is hardly complex, and there is no need for any great performance, but the result is rather neat. Behind the scenes there is a <a href="http://www.sqlite.org/" target="_blank">SQLITE </a>database to store all the information about guitars and their makers, a <a href="http://www.python.org/" target="_blank">PYTHON </a>script to decode the serial numbers and find the exact information in the database, the <a href="http://www.web2py.com/examples/default/what" target="_blank">WEB2PY </a>framework to generate the dynamic web pages and a <a href="http://www.lighttpd.net/" target="_self">LIGHTTPD </a>web server to communicate with the user.</p>
<p>Since then I have delivered several such applications, the most recent is <a href="http://medaim.fluxflex.com/medaim/default/index" target="_blank">MEDAIM </a>which estimates the effect of a planned media advertising buy.</p>
<p>The big issue that crops up with web applications is configuring and maintaining a server to host them.  It is not clear to me the best way to do this.</p>
<p>For desktop applications I can provide an installer which the client can distribute to the end users.  Almost everyone is familiar and comfortable with this.  Configuring and maintaining a server for a web application is quite intimidating to anyone who has not done this before, and is a cost that was often not considered when planning the project.</p>
<p>MEDAIM is hosted on <a href="http://www.fluxflex.com/">http://www.fluxflex.com</a> which is &#8216;free&#8217;, but installation and maintenance is a hassle.  I originally hosted it on my own server, which is far more convenient but it so very hard to compete with &#8216;free&#8217;.</p>
<p>Suggestions for making this go smoother would be most welcome!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=18&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2012/01/28/into-the-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>
	</item>
		<item>
		<title>Optometric Device Integrator</title>
		<link>http://ravenspoint.wordpress.com/2011/12/20/optometric-device-integrator/</link>
		<comments>http://ravenspoint.wordpress.com/2011/12/20/optometric-device-integrator/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 17:56:51 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=152</guid>
		<description><![CDATA[Optometrists (also known as ophthalmic opticians) are licensed medical professionals who prescribe and fit lenses to improve vision. They use several different devices to measure the patient&#8217;s eyes ( an Autorefractor Keratometer ), the lenses ( a lensmeter ) and &#8230; <a href="http://ravenspoint.wordpress.com/2011/12/20/optometric-device-integrator/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=152&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Optometry" target="_blank">Optometrists </a>(also known as ophthalmic opticians) are licensed medical professionals who prescribe and fit lenses to improve vision.</p>
<p>They use several different devices to measure the patient&#8217;s eyes ( an <a href="http://www.nidek-intl.com/products/examination/ark-560a.html" target="_blank">Autorefractor Keratometer</a> ), the lenses ( a <a href="http://www.nidek-intl.com/products/examination/lm-1800pd.html" target="_blank">lensmeter </a>) and the improvement a lens gives to the patient&#8217;s vision ( a <a href="http://www.nidek-intl.com/products/examination/rt-5100.html" target="_blank">refractor </a>).</p>
<p>The data gathered about each patient from the first two devices are used to create an initial setting for the third.</p>
<p>Raven&#8217;s Point has developed a software system for <a href="http://www.innovamed.com/about-innova">INNOVA Medical Ophthalmics</a> which gathers data from optometric measurement devices, stores the data for each patient from every source together in a database and downloads the data to the refractor when required.</p>
<p>RTLink is a client-server system. The clients, each communicating with one optometric device over a serial link, are linked by WiLAN to the database server which looks after all the data for the optometrist&#8217;s office in a SQLite database.</p>
<p><a href="http://ravenspoint.files.wordpress.com/2011/12/dfd1.jpg"><img src="http://ravenspoint.files.wordpress.com/2011/12/dfd1.jpg?w=640" alt="" title="RTLink Dataflow"   class="aligncenter size-full wp-image-157" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/152/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/152/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/152/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=152&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2011/12/20/optometric-device-integrator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>

		<media:content url="http://ravenspoint.files.wordpress.com/2011/12/dfd1.jpg" medium="image">
			<media:title type="html">RTLink Dataflow</media:title>
		</media:content>
	</item>
		<item>
		<title>Stackoverflow Reputation</title>
		<link>http://ravenspoint.wordpress.com/2011/12/07/stackoverflow-reputation/</link>
		<comments>http://ravenspoint.wordpress.com/2011/12/07/stackoverflow-reputation/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 16:26:01 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=147</guid>
		<description><![CDATA[I have just reached 4,000 reputation points on stackoverflow &#8211; the coding question and answer site It took three years. Since one person upvoting an answer gives 10 points, this implies that on average someone liked one of my answers &#8230; <a href="http://ravenspoint.wordpress.com/2011/12/07/stackoverflow-reputation/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=147&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have just reached 4,000 reputation points on stackoverflow &#8211; the coding question and answer site</p>
<p><a href="http://stackoverflow.com/users/16582/ravenspoint"><br />
<img src="http://stackoverflow.com/users/flair/16582.png?theme=clean" width="208" height="58" alt="profile for ravenspoint at Stack Overflow, Q&amp;A for professional and enthusiast programmers" title="profile for ravenspoint at Stack Overflow, Q&amp;A for professional and enthusiast programmers"><br />
</a></p>
<p>It took three years. Since one person upvoting an answer gives 10 points, this implies that on average someone liked one of my answers twice each week over those three years.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/147/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=147&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2011/12/07/stackoverflow-reputation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>

		<media:content url="http://stackoverflow.com/users/flair/16582.png?theme=clean" medium="image">
			<media:title type="html">profile for ravenspoint at Stack Overflow, Q&#38;A for professional and enthusiast programmers</media:title>
		</media:content>
	</item>
		<item>
		<title>Speaker to Robots</title>
		<link>http://ravenspoint.wordpress.com/2011/11/18/speaker-to-robots/</link>
		<comments>http://ravenspoint.wordpress.com/2011/11/18/speaker-to-robots/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 13:45:32 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[SCADA]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=82</guid>
		<description><![CDATA[Raven&#8217;s Point builds applications that speak to robots. ( Larry Niven&#8217;s science fiction stories feature a character named Chmee who is the alien ambassador to Earth.  His title, when translated into English, is Speaker-To-Animals ) PowerHeater.  This application controls and records wind turbine blade &#8230; <a href="http://ravenspoint.wordpress.com/2011/11/18/speaker-to-robots/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=82&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Raven&#8217;s Point builds applications that speak to robots.</p>
<p>( Larry Niven&#8217;s science fiction stories feature a character named Chmee who is the alien ambassador to Earth.  His title, when translated into English, is <a href="http://en.wikipedia.org/wiki/Speaker-to-Animals">Speaker-To-Animals</a> )</p>
<ul>
<li><strong>PowerHeater</strong>.  This application controls and records wind turbine blade production.  The strength of the composite materials used depends critically on a precise temperature profile imposed during a curing process lasting several days.  Hundreds of heaters, coolers, thermostats and temperature gauges are placed across the surface of the turbine blade, every one individually monitored, controlled and recorded by <strong>PowerHeater</strong> using the <a href="http://modbus.org/faq.php">Modbus</a> protocol.</li>
</ul>
<ul>
<li><strong>eCrew</strong>.  A modern sailboat has instruments measuring depth, wind speed and direction, and compass bearing.  Occasionally these readings are of vital importance, but usually the captain must watch wind and waves, sails and other sailboats, not the instruments.   <strong>eCrew</strong> monitors all the instruments using the <a href="http://en.wikipedia.org/wiki/NMEA_0183">NMEA</a> protocol, warning when a critical situation arises.</li>
</ul>
<ul>
<li><strong>VisControl</strong>.  The chair of a state senate chamber recognizes one of the senators. When the senator begins to speak, one of three cameras has already swung into position and is webcasting the perfect image. <strong>VisControl </strong>stores over 50 preset positions for each camera, automatically selecting and moving the cameras into position whenever the speaker changes, using the VISCA protocol over RS232.</li>
</ul>
<ul>
<li><strong>Proteus</strong>.  A tiny submersible on the end of a long cable threads its way through a pipe and into a huge concrete oil storage container under the North Sea.  Once in position, sonar scans the interior looking for damage and silt build up.  <strong>Proteus</strong> controls and records the sonar, calculating a real time three dimensional picture.   Proprietary protocol over boosted RS232.</li>
</ul>
<ul>
<li><strong>SLReader</strong>.  A wireless <a href="http://www.pgt.com/item/pgt-lite-2.html">detector </a>is used to identify isotopes.  SLReader configures, monitors, and downloads data from the device using the <a href="http://www.zigbee.org/">ZigBee </a>protocol.</li>
</ul>
<ul>
<li><strong>RTLink</strong>.  Connect the <a href="http://www.innovamed.com/Imaging-Measurement-Devices" target="_blank">different instruments</a> used to measure the optical properties of a patient&#8217;s eyes and eyeglasses, each with its own protocol, to a database server so the ophthalmic doctor can keep everything straight, helping to ensure that all the measurements are connected to the correct patients.</li>
</ul>
<div><span style="font-size:x-small;"><br />
</span></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=82&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2011/11/18/speaker-to-robots/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>
	</item>
		<item>
		<title>Dilemma</title>
		<link>http://ravenspoint.wordpress.com/2011/10/02/dilemma/</link>
		<comments>http://ravenspoint.wordpress.com/2011/10/02/dilemma/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 20:00:47 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=132</guid>
		<description><![CDATA[When people co-operate, things usually turn out well. If no-one co-operates, then everyone usually suffers. So the game plan is obvious, right? Wrong! If everyone else is co-operating, then some clever fellow will come along and take advantage. So now &#8230; <a href="http://ravenspoint.wordpress.com/2011/10/02/dilemma/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=132&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When people co-operate, things usually turn out well. If no-one co-operates, then everyone usually suffers. So the game plan is obvious, right?</p>
<p>Wrong! If everyone else is co-operating, then some clever fellow will come along and take advantage. So now the game plan is obvious, refuse to co-operate and take advantage of everyone who is naively co-operating.</p>
<p>Stupid! This is so obvious that no-one will co-operate, will they? And, yes, everyone will suffer.</p>
<p>This is clever?</p>
<p>This is a famous dilemma, with all sorts of significant analogies in the real world from Mutually Assured Destruction to the Tragedy of the Commons to the evolution of ethics in a godless universe.</p>
<p>There is a very simple solution, though it only becomes perfectly obvious by using mathematical simulation.</p>
<h2>The Nice Guy</h2>
<p>Let&#8217;s build a player who always co-operates &#8211; returns true whenever asked for a response.</p>
<pre>class cPlayerNiceGuy : cPlayerBase
{
public:
	cPlayerNiceGuy() : cPlayerBase( L"NiceGuy" ) {}
	bool Response( int , const cHistory&amp; )
	{
		return true;
	}
		cPlayerBase * Reproduce() { return new cPlayerNiceGuy; }

};</pre>
<p>Now build an ecology composed only of nice guys.</p>
<pre>	cEcology ecology;
	ecology.Add( (cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add( (cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add( (cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add( (cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add( (cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add( (cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add( (cPlayerBase *)new cPlayerNiceGuy() );</pre>
<p>The result of this simulation is:</p>
<pre>NiceGuy scored 1260
NiceGuy scored 1260
NiceGuy scored 1260
NiceGuy scored 1260
NiceGuy scored 1260
NiceGuy scored 1260
NiceGuy scored 1260</pre>
<p>As you would expect, everyone does equally well.</p>
<h2>The Black Hat</h2>
<p>Now lets introduce someone who tries to take advantage of all these nice guys, someone who always return false when asked for a response</p>
<pre>class cPlayerBlackHat : cPlayerBase
{
public:
	cPlayerBlackHat() : cPlayerBase( L"BlackHat" ) {}
	bool Response( int , const cHistory&amp; )
	{
		return false;
	}
	cPlayerBase * Reproduce() { return new cPlayerBlackHat; }

};

	cEcology ecology;
	ecology.Add((cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add((cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add((cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add((cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add((cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add((cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add((cPlayerBase *)new cPlayerBlackHat() );

BlackHat scored 2100
NiceGuy scored 1080
NiceGuy scored 1080
NiceGuy scored 1080
NiceGuy scored 1080
NiceGuy scored 1080
NiceGuy scored 1080</pre>
<p>Well now, the Black Hat has gained enormously at the expense of all the nice guys!</p>
<h2>Darwin</h2>
<p>So now we introduce a little &#8216;Darwinian Evolution&#8217; &#8211; we kill off the lowest scoring player and allow the highest scorer to reproduce.</p>
<p>After a few generations, we have these results:</p>
<pre>BlackHat scored 1140
BlackHat scored 1140
BlackHat scored 1140
BlackHat scored 1140
BlackHat scored 1140
NiceGuy scored 360
NiceGuy scored 360</pre>
<p>The non co-operative players have multiplied like rabbits and the few remaining co-operators are having a perfectly miserable time of it.</p>
<p>But notice that there are so few co-operators left to take advantage of that the Black Hats are now scoring LESS than the co-operators did when they were the only players.</p>
<h2>Tit For Tat</h2>
<p>Someone who initially co-operates, and then returns whatever the other did last time, tit for tat</p>
<pre>class cPlayerTitForTat : cPlayerBase
{
public:
	cPlayerTitForTat() : cPlayerBase( L"TitForTat" ) {}
	bool Response( int MyRole, const cHistory&amp; history )
	{
		if( ! history.size() )
			return true;
		return history.GetPartnerLastRespone( MyRole );
	}
	cPlayerBase * Reproduce() { return new cPlayerTitForTat; }

};
&lt;verbatim&gt;

Start with an even mixture of all the different players

&lt;verbatim&gt;
	ecology.Add( (cPlayerBase *)new cPlayerRandom() );
	ecology.Add((cPlayerBase *)new cPlayerBlackHat() );
	ecology.Add((cPlayerBase *)new cPlayerTitForTat() );
	ecology.Add((cPlayerBase *)new cPlayerNiceGuy() );
	ecology.Add( (cPlayerBase *)new cPlayerRandom() );
	ecology.Add((cPlayerBase *)new cPlayerBlackHat() );
	ecology.Add((cPlayerBase *)new cPlayerTitForTat() );
	ecology.Add((cPlayerBase *)new cPlayerNiceGuy() );</pre>
<p>The results after a few generations</p>
<pre>TitForTat scored 650
TitForTat scored 650
TitForTat scored 650
BlackHat scored 444
BlackHat scored 444
BlackHat scored 444
BlackHat scored 444</pre>
<p>The naive co-operators go quickly extinct, but the tit-for-tats are easily dominating the black hats. A few more generations and the Black hats will be exinct and the tit-for-tats will settle into a pure co-operative strategy, scoring as much as the naive co-operators ever did.</p>
<p>It is fun to try different combinations of starting populations and try to come up with a strategy that does better than tit-for-tat in a mixed population.</p>
<p>To do this, you will need a basic understanding of C++ programming and the code you can download from <a href="http://66.199.140.183/cgi-bin/dilemma.cgi/home" target="_blank">this repository</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=132&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2011/10/02/dilemma/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>
	</item>
		<item>
		<title>Database, tell me a little about yourself</title>
		<link>http://ravenspoint.wordpress.com/2011/08/18/database-tell-me-a-little-about-yourself/</link>
		<comments>http://ravenspoint.wordpress.com/2011/08/18/database-tell-me-a-little-about-yourself/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 13:36:56 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=107</guid>
		<description><![CDATA[Databases start off small.  Perhaps just a couple of tables with a few dozen columns.  What could be simpler or more obvious?  Then someone adds a feature or five, a few configuration options, ports the application to a new platform, &#8230; <a href="http://ravenspoint.wordpress.com/2011/08/18/database-tell-me-a-little-about-yourself/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=107&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Databases start off small.  Perhaps just a couple of tables with a few dozen columns.  What could be simpler or more obvious?  Then someone adds a feature or five, a few configuration options, ports the application to a new platform, a browser interface, half a dozen different languages.  Soon enough the database is a huge mess.  Yes, yes, someone should sit down and normalize the thing.  By now the application is selling on an app store for $2, so who can afford the effort to normalize?  Maybe then a summer student could at least document the database.  Sure, and we can add the student&#8217;s efforts to a million other badly formatted, half completed database design documents in obsolete MSWORD files.</p>
<p>You know what would be nice?  A way to self-document a database.  The documentation should be contained in the database itself, so it can move with the database, grow with the database, and keep pace with database engine technology and popular documentation presentation.</p>
<p>I would like something like <a href="http://www.stack.nl/~dimitri/doxygen/" target="_blank">Doxygen </a>for source code, but for a database.  Doxygen uses comments with a specified format, so that when the source code is read by the Doxygen application, pretty and up to data documentation is generated automatically.  The comments can be maintained in the normal course of editing the code, using any code editor without having to worry about special applications, but whenever required Doxygen can be used to generate the documentation for the latest code.</p>
<p>So, could we add a special table to our database which contains documentation of the other tables?  A table that can by updated by any database management tool, even raw SQL, but when read by a special application, will generate the documentation.</p>
<p>I mostly use <a href="http://www.sqlite.org/" target="_blank">SQLite </a>for my application databases.  Paweł Salawa offers a nice SQLite database management tool <a href="http://sqlitestudio.one.pl/index.rvt?act=about" target="_blank">SQLite Studio</a>.  The Studio is open source, written in TCL and has a sophisticated plugin system, so it was easy for me to add what I needed.</p>
<p>A simple example:</p>
<p>Suppose you have a database with the following table</p>
<pre>CREATE TABLE config ( pro, KEY );</pre>
<p>Now add a new table to document this, plus any other tables.</p>
<pre>CREATE TABLE __sqlite_studio_doc ( desc, _table, _column );</pre>
<p>Now add the documentation to the new table</p>
<pre>desc,   _table,   _column
True if PRO designer is running,   config,   pro
The license key,   config,   KEY
Stores configuration settings,  config,  __sqlite_studio_table</pre>
<p>The special _column value, __sqlite_studio_table, is used for the documentation for the table itself.</p>
<p>Pretty simple? Well, it is if you are familiar with maintaining a SQL database.  ( If you are not, why are you reading this? )</p>
<p>Now to generate the documentation.</p>
<p>Install SQLite Studio</p>
<p>Install the <a href="http://66.199.140.183/sqlitestudio/html_doc.tcl">new export plugin</a>.  ( Download link  to sqlitestudio-2.0.13\src\plugins\export )</p>
<p>Run the new export plugin HTML+DOC on your database.</p>
<p>The output will look like this, when viewed in a browser:</p>
<p><a href="http://ravenspoint.files.wordpress.com/2011/08/html_doc.jpg"><img class="aligncenter size-full wp-image-110" title="html_doc" src="http://ravenspoint.files.wordpress.com/2011/08/html_doc.jpg?w=640" alt=""   /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=107&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2011/08/18/database-tell-me-a-little-about-yourself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>

		<media:content url="http://ravenspoint.files.wordpress.com/2011/08/html_doc.jpg" medium="image">
			<media:title type="html">html_doc</media:title>
		</media:content>
	</item>
		<item>
		<title>No to noncompete clauses</title>
		<link>http://ravenspoint.wordpress.com/2011/07/09/no-to-noncompete-clauses/</link>
		<comments>http://ravenspoint.wordpress.com/2011/07/09/no-to-noncompete-clauses/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 14:27:13 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=87</guid>
		<description><![CDATA[I never sign contracts that contain noncompete clauses. A noncompete contract prevents employees or consultants from working for a competitor to their employer or client for a period, often as long as two years, after the employment or contract ends.  &#8230; <a href="http://ravenspoint.wordpress.com/2011/07/09/no-to-noncompete-clauses/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=87&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I never sign contracts that contain noncompete clauses.</p>
<p>A noncompete contract prevents employees or consultants from working for a competitor to their employer or client for a period, often as long as two years, after the employment or contract ends.  No compensation for this restriction is ever offered.  A list of specific competitors is not defined, so it is impossible to tell how wide or narrow the restriction might be until the lawyers start calling.</p>
<p>I was once offered a one month contract, if I signed a two year noncompete contract.  The company was a startup that had not been in existence for a year.  They would not budge on this, so I turned down the work.</p>
<p>This issue is currently being actively discussed in the US state of Massachusetts.  This article <a href="http://articles.boston.com/2011-07-03/business/29733744_1_noncompete-video-game-harmonix-music-systems">Some common sense on noncompete clauses &#8211; Boston.com</a> by  Scott Kirsner explains why noncompetes are being considered harmful both to employees and to community productivity and prosperity. ( A <a href="http://t.co/K6KqApE">follow-up article</a> by the same writer, is extended and with a rich collection of links to other resources )</p>
<p>Ten years ago Joel Spolsky wrote <a href="http://www.joelonsoftware.com/articles/fog0000000071.html">this column</a> on noncompetes and other evils that often hide in Non-Disclosure Agreements (NDAs).   Some things change slowly in this business.</p>
<p>It is not very often that I am asked to sign a noncompete, but it can be awkward.  The early stages of contract negotiation are delicate.  I am hoping that posting this now, while there are no negotiations underway, will make things more straightforward.  My objection is not to your noncompete clause, but to everyone&#8217;s!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=87&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2011/07/09/no-to-noncompete-clauses/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>
	</item>
		<item>
		<title>Designing a thread-safe copyable class</title>
		<link>http://ravenspoint.wordpress.com/2011/03/10/designing-a-thread-safe-copyable-class/</link>
		<comments>http://ravenspoint.wordpress.com/2011/03/10/designing-a-thread-safe-copyable-class/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 02:06:57 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=73</guid>
		<description><![CDATA[The straightforward way to make a class threadsafe is to add a mutex attribute and lock the mutex in the accessor methods The problem is that this makes the class non-copyable. This is important, especially if you want to store &#8230; <a href="http://ravenspoint.wordpress.com/2011/03/10/designing-a-thread-safe-copyable-class/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=73&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The straightforward way to make a class threadsafe is to add a mutex attribute and lock the mutex in the accessor methods</p>
<p><pre class="brush: cpp;">
class cMyClass {
  boost::mutex myMutex;
  cSomeClass A;
public:
  cSomeClass getA() {
    boost::mutex::scoped_lock lock( myMutex );
    return A;
  }
};
</pre></p>
<p>The problem is that this makes the class non-copyable.  This is important, especially if you want to store objects of the class in a container.</p>
<p>I can make things work by making the mutex a static. </p>
<p><pre class="brush: cpp;">
class cMyClass {
  static boost::mutex myMutex;
  cSomeClass A;
public:
  cSomeClass getA() {
    boost::mutex::scoped_lock lock( myMutex );
    return A;
  }
};

</pre></p>
<p>However, this means that every instance of the class blocks when any other instance is being accessed, because they all share the same mutex.</p>
<p>Theoretically, a class containing a non-static mutex can be made copyable by hand coding the copy constructor and assignment operator so as to leave out the mutex.  However, this is difficult and tedious to do properly, especially for a class with a large number of attributes that frequently change during development.</p>
<p>If a static mutex that blocks access to all instances of the class when one is blocked is not acceptable, then the best and simplest approach is to maintain the mutexes outside the class.  It might seem unfortunate to expose the inner workings of a class in this way, but the alternatives are way more complex, hence unreliable, and I frequently find significant optimizations when the mutexes are handled at the level of the code accessing the class.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=73&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2011/03/10/designing-a-thread-safe-copyable-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>
	</item>
		<item>
		<title>In or Out?</title>
		<link>http://ravenspoint.wordpress.com/2010/06/27/in-or-out/</link>
		<comments>http://ravenspoint.wordpress.com/2010/06/27/in-or-out/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 17:40:13 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=63</guid>
		<description><![CDATA[Is a point in two dimensions inside or outside a polygon? Theoretically this question is dead simple. Start at the point and draw a line parallel to the x-axis and continue until you reach infinity ( or as near to &#8230; <a href="http://ravenspoint.wordpress.com/2010/06/27/in-or-out/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=63&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Is a point in two dimensions inside or outside a polygon?</p>
<p>Theoretically this question is dead simple.  Start at the point and draw a line parallel to the x-axis and continue until you reach infinity ( or as near to infinity as makes any sense ).  As you go, count the occasions when your line crosses an edge of the polygon.  If the line crosses a polygon edge an odd number of times then the point was inside but if it crosses an even number of times then it must have been outside.</p>
<p>To get a feeling for how this works, imagine a simple square.  From a point inside, any line towards infinity must cross an edge once as it leaves the box.  From a point outside the line may never touch the box ( 0 is considered to be an even number ) or it may enter the box and then leave it, for two crossings.</p>
<p>Implementing this simple algorithm in computer code is quite a challenge, especially if you care about performance.  When you have some code that seems to work, testing all the special cases could consume days.  What if the point is on an edge?  On a corner?  What if the polygon is not simple, but has holes and several seperate components?</p>
<p><em>&#8220;I have seen farther by standing on the shoulders of giants.&#8221;</em> _ Isaac Newton</p>
<p>Many years ago an elegant little piece of code to determine if a point was inside a polygon was published by W. Randolph Franklin.  You can find it <a href="http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html">here </a>with a discussion of how to use it properly, but here is the code itself, all 7 lines of it:</p>
<p><pre class="brush: cpp;">
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
{
  int i, j, c = 0;
  for (i = 0, j = nvert-1; i testy) != (verty[j] &gt; testy)) 
       if ( ((verty[i]&gt;testy) != (verty[j]&gt;testy)) &amp;&amp;
            (testx &lt; (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
       c = !c;
  }
  return c;
}

</pre></p>
<p>Isn&#8217;t this quite wonderful?  Well, if you have ever tried to code the point inside a polygon problem, you would think it was just outstanding.</p>
<p>The snag is that it uses an ancient dialect of the C programming language, specifically arrays.  Arrays are horrible things, which generate endless bugs, off-by-one bugs and out-of-bounds bugs in particular.</p>
<p>Modern code avoids all these bugs ever occurring by using standard template library vectors.  So I have taken the liberty of translating Franklin&#8217;s code into modern C++</p>
<p><pre class="brush: cpp;">
/**

  Is a point inside the boundary

  @param[in] point  the point being tested

  @return 1 if the point is inside, 0 otherwise

  This code is modified James Bremner, to use the STL vector, from that of W. Randolph Franklin
  given here  http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

  */
int cBoundary::IsInside( c2d point ) const
{
	int c = 0;
	vector&lt;c2d&gt;::const_iterator j = myBoundary.end()-1;
	for ( vector&lt;c2d&gt;::const_iterator i= myBoundary.begin();
		i != myBoundary.end(); j = i++ )
	{
		if( (( i-&gt;y &gt; point.y ) != ( j-&gt;y &gt; point.y )) &amp;&amp;
			(point.x &lt; ( j-&gt;x - i-&gt;x ) * ( point.y - i-&gt;y ) / ( j-&gt;y - i-&gt;y ) + i-&gt;x ) )
			c  = ! c;
	}
	return c;

}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=63&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2010/06/27/in-or-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>
	</item>
		<item>
		<title>Timing</title>
		<link>http://ravenspoint.wordpress.com/2010/06/16/timing/</link>
		<comments>http://ravenspoint.wordpress.com/2010/06/16/timing/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 23:57:54 +0000</pubDate>
		<dc:creator>ravenspoint</dc:creator>
				<category><![CDATA[Software Engineering Tool]]></category>

		<guid isPermaLink="false">http://ravenspoint.wordpress.com/?p=28</guid>
		<description><![CDATA[Fast, Safe, Custom Software Engineering &#8211; Raven&#8217;s Point is focused on engineering software that delivers your solutions before you expect and with the greatest reliability. This the Raven&#8217;s Point mission statement. What does it mean? Partly it means that I &#8230; <a href="http://ravenspoint.wordpress.com/2010/06/16/timing/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=28&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Fast, Safe, Custom Software Engineering &#8211; Raven&#8217;s Point is focused on engineering software that delivers your solutions before you expect and with the greatest reliability.</em></p>
<p>This the Raven&#8217;s Point mission statement.  What does it mean?  Partly it means that I specialize in delivering more quickly than the competition individually designed and coded software that is carefully tested and documented.</p>
<p>It also means that the programs I deliver run extremely fast, making the best use of optimizing compilers and high speed multi-core hardware.</p>
<p>I enjoy re-arranging computer code so that it goes faster.</p>
<p>Re-arranging code is dangerous.  It is very easy to break something that was previously working.  An <a href="http://ravenspoint.wordpress.com/2010/06/12/unit-testing/">effective test framework</a> and a good set of regression tests are vital to prevent one step forward causing ten steps backward.  No-one needs the wrong results reached ten times faster.</p>
<p>Re-arranging code is also seductive.  Even if you do not do any harm, you can spend a lot of time achieving nothing.  It usually turns out that a program spends most of its time executing a very few lines of code, but it can be very difficult to guess which lines these are going to be.  Before optimizing, it is necessary to measure carefully and find exactly where the bottleneck is that will repay being optimized.</p>
<p>::raven::set::cRunWatch is a code timing profiler which can tell exactly how long a program spends executing every piece of code.</p>
<p>It is just two files, so it is easy to integrate with your projects, and requires adding exactly one line to instrument a piece of code.</p>
<p>To start profiling:</p>
<p><pre class="brush: cpp;">
raven::set::cRunWatch::Start();
</pre></p>
<p>Notes:<br />
*  This can be done anywhere, but usually early in the main function.<br />
*  This can be called without creating an instance of the profiler.<br />
*  If not called, all cRunWatch methods become no-ops<br />
*  If called with a zero parameter, all cRunWatch methods become no-ops.</p>
<p>To profile a code scope:</p>
<p><pre class="brush: cpp;">
raven::set::cRunWatch runwatch(&quot;&lt;unique name of scope&gt;&quot;);
</pre></p>
<p>Notes:<br />
*  This should be done as the first line of the scope.<br />
*  The scope is usually a function, but can be any pair of curly braces {}</p>
<p>To write a report to standard output:</p>
<p><pre class="brush: cpp;">
raven::set::cRunWatch::Report();
</pre></p>
<p>Notes:<br />
*  This can be done anywhere, but usually at the end of the main function.<br />
*  This can be called without creating an instance of the profiler.</p>
<p>Example of Use</p>
<p><pre class="brush: cpp;">

void highly_optimised_subroutine()
{
raven::set::cRunWatch runwatch(&quot;highly_optimised_subroutine&quot;);
Sleep( 2 );
}

void badly_written_function()
{
raven::set::cRunWatch runwatch(&quot;badly_written_function&quot;);
for (int k = 1; k &lt; 1000; k++ )
{
highly_optimised_subroutine();
}
}

void well_written_function()
{
raven::set::cRunWatch runwatch(&quot;well_written_function&quot;);
for (int k = 1; k &lt; 10; k++ )
{
highly_optimised_subroutine();
}
}

int _tmain(int argc, _TCHAR* argv[])
{
raven::set::cRunWatch::Start();

well_written_function();
badly_written_function();

raven::set::cRunWatch::Report();

return 0;
}

</pre></p>
<p>Report produced:</p>
<pre>
raven::set::cRunWatch code timing profile
Scope                          Calls   Mean (secs)           Total
highly_optimised_subroutine     1008      0.002923        2.946213
badly_written_function             1      2.926662        2.926662
well_written_function              1      0.026161        0.026161
</pre>
<p>You can obtain raven::Set::cRunWatch from <a href="http://66.199.140.183/cgi-bin/ravenset.cgi">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ravenspoint.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ravenspoint.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ravenspoint.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ravenspoint.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ravenspoint.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ravenspoint.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ravenspoint.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ravenspoint.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ravenspoint.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ravenspoint.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ravenspoint.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ravenspoint.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ravenspoint.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ravenspoint.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ravenspoint.wordpress.com&amp;blog=14181478&amp;post=28&amp;subd=ravenspoint&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ravenspoint.wordpress.com/2010/06/16/timing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/88053c615681f90c888b3b50a67c2a4c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ravenspoint</media:title>
		</media:content>
	</item>
	</channel>
</rss>
