<?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>Advent Digerati &#187; Practicum</title>
	<atom:link href="http://blog.adventdigerati.com/tag/practicum/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.adventdigerati.com</link>
	<description>Where Life meets Geek</description>
	<lastBuildDate>Mon, 26 Jul 2010 00:49:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Dynamic-Sql Act III</title>
		<link>http://blog.adventdigerati.com/2008/12/dynamic-sql-act-iii/</link>
		<comments>http://blog.adventdigerati.com/2008/12/dynamic-sql-act-iii/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 00:24:27 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Theory]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Practicum]]></category>

		<guid isPermaLink="false">http://blog.adventdigerati.com/?p=24</guid>
		<description><![CDATA[All RDb queries are structured in a strict syntax. This is a simple axiom which can and will be exploited by our experiment on the most fundamental level: building the tree. The elementary fact is that whatever comes next must be related to something which has preceded it. It is this relationship which we will [...]]]></description>
			<content:encoded><![CDATA[<p>All RDb queries are structured in a strict syntax. This is a simple axiom which can and will be exploited by our experiment on the most fundamental level: building the tree. The elementary fact is that whatever comes next must be related to something which has preceded it. It is this relationship which we will use to link and unlink our tree.</p>
<p>Using our <a href="http://blog.adventdigerati.com///dynamic-sql-act-ii">previous example</a>, we can already see how rapidly a RDb can gain entities and relationships as correctly storing information can require many additional entities. For our &#8220;intelligent SQL constructor,&#8221; the system will need to weed through the myriad of tables to get to find the fastest path from start to finish.</p>
<p>Now suppose we expand our example yet again and include a second path between <code>Baby</code> and <code>Deceased</code>: &#8220;A Baby can be born and soon after become Deceased.&#8221; This new relationship throws a monkey wrench in some interfaces, as the most direct path from Baby to Deceased is now a single hop. For some users, that we may abstract the fact a Person will become Deceased can lead to erroneous expectations either from the developer or the user; in either event, this is a discrepancy which will cost patrons and development costs in the end.</p>
<p>So how can we expose this fact? My personal inclination is to be explicit is possible. By describing to users what you, as the developer, were intending, harmful reactions should realistically be cut to a minimum. To do this, the system will need to be mathematically aware of how the RDb is structured and what the relationships imply. As proposed in <a href="http://blog.adventdigerati.com/2008/11/dynamic-sql-act-i/trackback/">the exposition</a>, knowledge of existing information, its meaning, and a relation to other algorithms should help us greatly.</p>
<p>The first tool we&#8217;ll need is a mathematical expectation of how to go from Baby to Deceased. Because of the wonders of modern medicine, users expect that life for a Baby does not cease until having consumed a significant time on Earth. From the data-modeling standpoint, this is to trace the relationship from Baby to Deceased through the Person entity. However, some UIs may not account for this and choose the direct, 1-hop, relationship.</p>
<p>From a user&#8217;s standpoint, this is misleading. &#8220;I&#8217;m calculating social security checks for the elderly; why do the results include a dozen records which are extraneous?&#8221; The system&#8217;s presumption that it must follow the most direct path from Baby to Deceased seems flawed, though &ndash; for the criteria &ndash; its data may be perfectly correct. Shouldn&#8217;t we instead initially propose to follow the path with the highest probability of success?</p>
<p>In such an example, based on our knowledge of the use of the system, we estimate that there are ten times the number of records for paths between Baby to Deceased using the Person table as without. Taking this into account, we almost assuredly are retrieving the right result set for social security calculations. Then, for the remaining ten percent, we offer the option to &#8220;trim&#8221; the Person entity from our query.</p>
<p>Additionally, what the system hasn&#8217;t exposed here is the semantic relationship the surmised from the entities provided. Perhaps the results <i>were</i> appropriate for what was provided, just not what was expected. This is the second tool we must produce: a means of exposing to the user our presumption of the semantic meaning of their query. This is, admittedly, less for our system to act upon than to influence what the user will input next, or perhaps withdraw and try again.</p>
<p>By now it might sound familiar to problems faced in graph theory. At the moment, there are two that I can think of which aptly fit into this scenario: maximal flow and minimal cut. Both are incredibly annoying problems with surprisingly low-tech solutions. They also both make use of our mathematical model tool we prescribed earlier. An improvement to this theory which deserves its own article will be proposed at the end of the article.</p>
<p>Luckily, there are means to do all of these things when given a well thought-out framework. Semantic ties can be stored within the framework and the mathematical model can be derived quickly from the data via a few SQL queries. (I already anticipate the cries of outrage over additional SQL queries, but those drawbacks will be addressed in the conclusion; so please, save your flames until the end of the series.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.adventdigerati.com/2008/12/dynamic-sql-act-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic-SQL Act II</title>
		<link>http://blog.adventdigerati.com/2008/12/dynamic-sql-act-ii/</link>
		<comments>http://blog.adventdigerati.com/2008/12/dynamic-sql-act-ii/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 05:19:25 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Practicum]]></category>

		<guid isPermaLink="false">http://blog.adventdigerati.com/?p=16</guid>
		<description><![CDATA[In my last post, I set the stage for a miniseries of posts regarding dynamic SQL construction. This is a problem many software vendors face: Allowing the user direct-access to the database is a huge red flag, and one many engineers strain to avoid. Should there be no alternative, however, great care should be allotted [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://blog.adventdigerati.com/2008/11/dynamic-sql-act-i/trackback/">last post</a>, I set the stage for a miniseries of posts regarding dynamic SQL construction. This is a problem many software vendors face: Allowing the user direct-access to the database is a <i>huge</i> red flag, and one many engineers strain to avoid. Should there be no alternative, however, great care should be allotted in making the users&#8217; experience as friendly as possible, (while, of course, keeping the user safe from dismantling their own data).</p>
<p>Typically for relational database schemas, (RDb&#8217;s), this results in a tree-generating interface which abstracts the actual syntax away from the user. In theory, it&#8217;s an excellent way to afford the power user the ability to generate near-infinite custom reporting tools and also help bug-fixing by relying on a few, axiomatic functions.</p>
<p>This doesn&#8217;t come without cost, however. Since a relational database is, by definition, segregated into distinct entities, it can be difficult for a program to discern which relationship between two entities to choose. This decision can be critical and time-sensitive for a user. As mentioned in the previous post, if a Person can choose a Profession to be a Painter or a Plumber but not both, then software which attempts to offer criteria based on these relationships should be contextually aware of what the user is asking for.</p>
<p>Most often, problems like these are kept to a minimum by not offering choices too complex for the system to evaluate in a reasonable time. For instance, let&#8217;s continue our previous example and introduce two new entities/tables called <code>Baby</code> and <code>Ghost</code>. These have the relationships &#8220;A <code>Baby</code> grows up to be a <code>Person</code>&#8221; and &#8220;A <code>Person</code> can die and become a <code>Ghost</code>.&#8221; For our system, we would like to hide the fact that between the Person and Ghost steps, the person who dies must be listed as <code>Deceased</code>. This is much the same as we do not store the Person&#8217;s profession as a line-item, but rather as a separate listing &ndash; perhaps with dates they started and ended a particular job. To the user, the details should be available but not mandatory, and requiring the Deceased entry could be an undue hastle and cost precious processing time.</p>
<p>Thusly, our system has to be quite intelligent. It must realize that the <code>Baby</code> becomes a <code>Person</code>, which can obtain none or many <code>Profession</code>s, will become <code>Deceased</code>, and could be believed to return as a <code>Ghost</code>. To keep the system under control, an interface is often limited to entities only two relationships, (&#8220;two-hops&#8221;), away from those already specified. Keeping up with our requirement for interface ease-of-use, the next logical step is to define a way to recursively discern these two-hop relationships and offer the user a means to resolve conflicts or ambiguous decisions. In so doing, we could offer the <code>Baby</code> and <code>Ghost</code> entities, (a four-hop relationship), from the start.</p>
<p>The question then becomes, &#8220;What tools will we need to perform such an operation?&#8221; Handily enough, I believe we have the capability, even on the Web, with JavaScript and proper algorithm implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.adventdigerati.com/2008/12/dynamic-sql-act-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic-SQL Act I</title>
		<link>http://blog.adventdigerati.com/2008/11/dynamic-sql-act-i/</link>
		<comments>http://blog.adventdigerati.com/2008/11/dynamic-sql-act-i/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 07:53:16 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Theory]]></category>
		<category><![CDATA[Practicum]]></category>

		<guid isPermaLink="false">http://blog.adventdigerati.com/?p=14</guid>
		<description><![CDATA[Sometimes I wonder if I ever learned anything in my collegiate Computer Science classes. After all, most (whom I&#8217;ve heard) would say that, unless you&#8217;re going to be developing The Next Big Thing, then you&#8217;re wasting valuable time and money on cheap beer and expensive lectures. My father always said that &#8220;If you want to [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I wonder if I ever learned anything in my collegiate Computer Science classes. After all, most (whom I&#8217;ve heard) would say that, unless you&#8217;re going to be developing The Next Big Thing, then you&#8217;re <i>wasting</i> valuable time and money on cheap beer and expensive lectures. My father always said that &#8220;If you want to party, go to college; if you want an education, get a job.&#8221; This, for some, may hold true. The expensive lectures I was no stranger to; the cheap beer, however, I tried hard not to touch with a 39 &#189; foot pole.</p>
<p>But, no matter how dumb you play, something seeps in. That&#8217;s how you weed good teachers from the mediocre ones: they can disseminate knowledge without you even knowing it. They&#8217;re kind of like God, in a way; sometimes the vague answers and delayed responses aren&#8217;t intended as insults or shirking, it&#8217;s a device to make you think and learn for yourself. Sometimes, when you think you need a helicopter to save you, a properly thrown life vest will do just fine.</p>
<p>While at Pittsburgh, I had a tough-as-nails professor for my algorithms class. I spent so many nights compiling Java code until 3AM when my throat was sore from too much tea and my eyes bled zeros and ones, but I got the programs working to spec and in on time. It was, for all intents and purposes, a trial by fire<sup><a href="#1">1</a></sup>. At the end of it, I thought I would forget everything and never use an iota of what it tought me for anything practical in my career. This view was incredibly, humerously, short-minded.</p>
<p>For a while, it was correct. Still, something lingered, and I should be glad it did. What remained was a desire to apply what I&#8217;d learned to what already existed. Solving old problems with more efficient solutions is always a challenge. It&#8217;s why neural networks and packet routing have evolved. But with these challenges comes personal and professional rewards, not the least of which is the ability to re-use the mental framework for the problem solved.</p>
<p>One of my least-favorite problems was graph search. (There&#8217;s a reason no one but mathematicians specialize in developing, proving, or otherwise entrenching themselves in graph theory.) Yet, graph searching is one of the most widely-applicable skills a software architect can develop. Case in point: dynamic SQL construction.</p>
<p>As a mental exercise in theory and practice, there are several parts to this post, interleaved with time for mental stretching, retractions, and analyses &amp; comments. (This is also no coincidence, as for those literary-educated readers the scaffolding is of the classical drama; enjoy.) This is <b>Act I: Exposition</b>.</p>
<p>In my experiment, there are three factors:
<ul>
<li>tree complexity,</li>
<li>semantic-path evaluation, and</li>
<li>reasonable application to graph theory.</li>
</ul>
<p> Tree complexity is the time and effort required to maneuver &#8216;blindly&#8217; from one entity to another, 2-hop-away, entity in a database. Semantic-path evaluation is the real-world implication of the statement&#8217;s conjoined entities. For instance, using the tables Painter, Plumber, and Person, a Person can become a Painter or a Plumber but each has a specific role and though both may use water they may not be what we intended to achieve. Without predefining rules, the system will have to build an assumption based on the entities provided. Lastly, while possibly obvious, the application to graph theory may need to be spelled out; this will probably be spent the least time developing.</p>
<p>If you can think of anything I&#8217;ve missed or misunderstood, constructive criticizm is encouraged! Act II: WYSIWYG will hopefully follow soon.</p>
<p><sup><a name="1">1</a></sup>Taking the class alone isn&#8217;t the Pitt CS Trial by Fire. Taking 1520 and 1550 <i>in the same semester</i> is. To exit both classes with B&#8217;s was a personal accomplishment, as well as bragging rights.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.adventdigerati.com/2008/11/dynamic-sql-act-i/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lost in Translation</title>
		<link>http://blog.adventdigerati.com/2008/11/lost-in-translation/</link>
		<comments>http://blog.adventdigerati.com/2008/11/lost-in-translation/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 06:01:22 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Practicum]]></category>

		<guid isPermaLink="false">http://adventtechnorati.wordpress.com/?p=40</guid>
		<description><![CDATA[As a programmer, if you&#8217;ve ever been tasked with migrating any system from one implementation to another, then you have undoubtedly ran aground on technical issues ranging from missing or underperforming data structures, inefficient algorithms, or a combination of these and any number of other issues. It doesn&#8217;t matter if it&#8217;s merely going from one [...]]]></description>
			<content:encoded><![CDATA[<p>As a programmer, if you&#8217;ve ever been tasked with migrating any system from one implementation to another, then you have undoubtedly ran aground on technical issues ranging from missing or underperforming data structures, inefficient algorithms, or a combination of these and any number of other issues. It doesn&#8217;t matter if it&#8217;s merely going from one language to another or across platforms, the inevitability of technical conundrums is inescapable.</p>
<p>This is not to say, however, that they are insurmountable. Often, in fact, when we stop trying to over-engineer our system and evaluate the situation as it is, we can make optimizations beyond our expectations. As a simple &#8220;for instance,&#8221; presuming we have a determinant for a conditional that is initially a free-text entry. According to this pretense, Boolean evaluation can take as little as the first byte in the string or as much as the full text of the string; thus, for sake of computation time, memory, and most of all maintainability, it should be avoided at high cost. Compare this with replacing this free-text with a numerically-indexed list of choices and the Boolean evaluation drops to a static value. (Even better, most implementations of bit-wise integer comparison are executed as close to machine code as possible.)</p>
<p>But, inevitably, there are cases which solutions such as these are not so prevalent or obvious. <i>For instance</i>, when implementing join-context SQL conditionals as PHP, it can take a tremendous amount of derived and out of band knowledge to perform the translation. Combine this with already complex logic, (nested XORs, negated string comparisons, and cross-table lookups), and the code can get slow and ugly very fast. So what do you do as an engineer with an email, the SQL, and a pat on the back? Get a game plan.</p>
<p>It&#8217;s more important to pencil in a strategy for defining your criteria than going off of pre-existing assumptions. For one measure, repeated calculations in the original may be consolidated as a single conditional whose value is stored and later addressed; the processing efficiency alone is worth the change when scaling up to enterprise-level datasets. Additionally, as I stated above, changing data types of pre-existing conditionals can be a great boon as well, and performing integer arithmetic is <i>always</i> faster than <code>strcmp</code>.</p>
<p>Once the parameters are defined, we zoom out to observe the algorithm. Keeping in mind the practice degrades maintainability, nesting some repeated conditionals can save processing power down the line. But don&#8217;t get nesting-happy; (especially with code you&#8217;re simply translating and didn&#8217;t have the mental inception for) you&#8217;ll forget why two conditionals had been nested or why their order mattered so much. This is where your formal logic class enters the picture. Class, what is {A, B, C, D} &amp; {A, B, C}? Of course it&#8217;s {A, B, C}; it&#8217;s also &not;{D}. The optimization, however slight, of changing
<pre><code>if($var == A OR $var == B OR $var == C) { something_true(); }</code></pre>
<p> to
<pre><code>if($var != D) { something_true(); }</code></pre>
<p> may not increase performance by leaps and bounds, but if you&#8217;re deep in the code anyway why wouldn&#8217;t you shave off the time?</p>
<p>Now, after the code is written and tested, there is much rejoicing. The only thing we now have to contend with is if the translation needs to change. And while we may not, (and hopefully will not), go back to square-one with our evaluation, we should at least take the time to consider where we may have gone wrong in our previous implementations and where we can continue to go right.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.adventdigerati.com/2008/11/lost-in-translation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
