<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>coada.net</title>
	
	<link>http://www.coada.net</link>
	<description>Just another WordPress weblog, but this one is mine</description>
	<pubDate>Wed, 27 May 2009 01:12:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Coadanet" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="coadanet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>FreeBSD “thin” client</title>
		<link>http://www.coada.net/dev/freebsd-thin-client.html</link>
		<comments>http://www.coada.net/dev/freebsd-thin-client.html#comments</comments>
		<pubDate>Wed, 27 May 2009 01:11:47 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Dev]]></category>

		<guid isPermaLink="false">http://www.coada.net/?p=297</guid>
		<description><![CDATA[For now, this is just a semi post (published so I won&#8217;t forget to update it when I have more time).
The client PXE boots properly, auto starts Apache, X and Firefox, but Firefox won&#8217;t work. 
Problem: Firefox needs to lock on various sqlite databases it keeps in /userhome/.mozilla/firefox and as that fs was actually a nfs [...]]]></description>
			<content:encoded><![CDATA[<p>For now, this is just a semi post (published so I won&#8217;t forget to update it when I have more time).</p>
<p>The client PXE boots properly, auto starts Apache, X and Firefox, but Firefox won&#8217;t work. </p>
<p>Problem: Firefox needs to lock on various sqlite databases it keeps in /userhome/.mozilla/firefox and as that fs was actually a nfs export, it couldn&#8217;t. </p>
<p>Solution: md fs mounted on /userhome/.mozilla + untar the content of that directory after system boots.</p>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/VrO1UlWUuww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/dev/freebsd-thin-client.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Why you should shut up if you see me coding</title>
		<link>http://www.coada.net/featured-articles/why-you-should-shut-up-if-you-see-me-coding.html</link>
		<comments>http://www.coada.net/featured-articles/why-you-should-shut-up-if-you-see-me-coding.html#comments</comments>
		<pubDate>Sat, 18 Apr 2009 12:12:08 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Featured Articles]]></category>

		<category><![CDATA[Rants]]></category>

		<category><![CDATA[akward]]></category>

		<category><![CDATA[awkard]]></category>

		<category><![CDATA[programmers]]></category>

		<category><![CDATA[stfu]]></category>

		<guid isPermaLink="false">http://www.coada.net/?p=287</guid>
		<description><![CDATA[Most people consider programmers to be awkward because they don&#8217;t like to be interrupted while working or they don&#8217;t like to chat while working. This is as false as it can get: we like (and in the same time dislike) doing this as the next profession. We simply can&#8217;t.
 
Imagine you are a carpenter. Most of [...]]]></description>
			<content:encoded><![CDATA[<p>Most people consider programmers to be awkward because they don&#8217;t like to be interrupted while working or they don&#8217;t like to chat while working. This is as false as it can get: we like (and in the same time dislike) doing this as the next profession. We simply can&#8217;t.</p>
<p> </p>
<p>Imagine you are a carpenter. Most of your job will be sawing off pieces of wood, drilling holes and the likes. Non mind stretching tasks. Of course you can chat while you saw. Now you have to join 3 pieces of wood together. What do you do? Keep talking and somehow join them? No, you stop blabbering and think how are you going to do that. </p>
<p> </p>
<p>How about a mathematician? Does he chat with anyone while he solves a math problem? Try disturbing him and he will send you straight to hell. How about an artist? Will you interrupt one while he is creating a new piece? No, because he will kick your behind while sending you to hell. What about speaking with a mathematician while he sharpens his pencil, or with a painter while he prepares a new canvas, or with a musician while he plays a well reversed piece? You might be astonished to learn that he can talk (I don&#8217;t know about flying thoug&#8230;) and that&#8217;s because, this task is not mentally challenging as solving a math problem, painting something new or creating a new piece of music. A programmer is supposed to solve a problem, compose a new piece of music or paint a new picture for most of the work day. We don&#8217;t have as many repetitive tasks as other professions and along with the sheer difficulty of writing there is little brain power remaining to be allocated on chatting or paying attention to blabber. </p>
<p> </p>
<p>Do an experiment: go to Wikipedia, search for whatever comes to your mind at that moment and read the page. Then write on paper (or type) 3 paragraphs about what you just read while you tell two jokes. See if you can do it.</p>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/Js_B0uN6YAU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/featured-articles/why-you-should-shut-up-if-you-see-me-coding.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Web Development and Template Engines</title>
		<link>http://www.coada.net/rants/web-development-and-template-engines.html</link>
		<comments>http://www.coada.net/rants/web-development-and-template-engines.html#comments</comments>
		<pubDate>Wed, 11 Feb 2009 09:11:48 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.coada.net/?p=221</guid>
		<description><![CDATA[While half of the web dev community was arguing about what not to use to build your webpage, master Alpha Blogger Jeff Atwood dropped a bomb on the heads of template engines lovers: template engines are pointless. Of course, answers were not late to pop up, on blogs and reddit. 
Why did these template engines appeared anyway? [...]]]></description>
			<content:encoded><![CDATA[<p>While half of the web dev community was arguing about what not to use to build your webpage, master Alpha Blogger Jeff Atwood dropped a bomb on the heads of template engines lovers: <a href="http://www.codinghorror.com/blog/archives/001223.html" target="_blank">template engines are pointless</a>. Of course, answers were not late to pop up, <a href="http://www.codesoftly.aaronoliver.com/2009/02/ill-give-you-my-template-when-you-pry-it-from-my-cold-dead-hands.html" target="_blank">on blogs</a> and <a href="http://www.reddit.com/r/programming/comments/7ve1f/ill_give_you_my_template_when_you_pry_it_from_my/" target="_blank">reddit</a>. </p>
<p>Why did these template engines appeared anyway? Because, back in the dark ages of web development, a little after the prehistoric time (cgi and stuff), there was this <strong>bad</strong> practice that poisonned developers life: <strong>spaggeti code</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">...
&nbsp;
[server side code to connect to the database]
&nbsp;
Page title
&nbsp;
[server side code to query the db and get some results]
display those results 
&nbsp;
[server side code to get some other results]
display these other results
&nbsp;
etc</pre></div></div>

<p>If you want to see some real world examples, get phpNuke or an older phpBB. There must be some fossils somewhere on the intertubes. </p>
<p>So, what did the scientists do?</p>
<p>They started by adding some sistematization to the scripts, like doing the whole data retrieve on top of the script and the output to the bottom. You could tell the designer: &#8220;Dude, don&#8217;t touch anything from here to here or I&#8217;ll kill you, infidel!&#8221; and that worked. </p>
<p>Then, because this wasn&#8217;t enough, the mighty scientists invented THE TEMPLATE ENGINES.</p>
<p>They did this to <strong>allow </strong>the developer to separate application logic from the data presentation. To be honest, I never felt that anyone is forcing me to mix them up and my application logic code was nicely up there in the top of the script, while the html part was way down there on the bottom. I usualy also had a comment line in between, the &#8220;don&#8217;t touch this part or I&#8217;ll kill you&#8221; part. </p>
<p>The scientists also believed that by introducing a new language, the template language, the designers could work on your script too. The reason why Smarty gained so much more popularity over patTemplates, apart the fact Smarty was/is developed by the php.net guys,  was a Dreamweaver plugin that allowed users to do a bunch of stuff to the Smarty tags. For the younger generation, Dreamweaver was the <span style="text-decoration: line-through;">abomination</span> tool of choice for the 2000 and something era web designers to convert the psd/png images to html files (for the ones that actually did that&#8230;) But, I never found a designer that couldn&#8217;t grasp the simple PHP skills needed to do the display tasks, but was able to learn a template engine language. May my coffee be sour if I lie to you!</p>
<p>Yet another feature that was advertised by some template engines, was <strong>caching</strong>. Most people, managers, developers, designers, missunderstood this and the myth, that by using a template engine your application became faster, was born. Actually, the engine was marely caching its own operations so your scripts were exactly as fast as they were before you started using the template engine. If they didn&#8217;t suddenly became slower.</p>
<p>The only real benefits the template engines introduced were a <strong>forced</strong> organisation of the code and, in some rare cases, a way for the designer to mess with the scripts and stop bothering you.</p>
<p>Fast forward a couple of 3 years and now, the new toy for the web developers are the frameworks. <strong>The biggest benefit they introduced was code separation by task</strong> (<a href="http://blog.wekeroad.com/blog/nothing-to-say/" target="_blank">this part is in bold because this is what Jeff Atwood does</a> and the link is there for the same reason). As most of the frameworks implement a variation of the MVC pattern, you already have specific places where to write specific code: put the data code in the model, the bussiness part in the controller and the display in the view. Unless you have a special ability to do things wrong, there is no way to write spagetti code in this setup. So, the biggest benefit of the template engines is no longer needed. </p>
<p>However, now you are in danger of producing <strong>tag soup</strong>. Your web cooking abillities are dimished, from the delicious spagetti to the dull soup. And the web scientists considered now is the proper time to tell the designer to &#8220;keep your fingers out of my soup&#8221; and invented the code generating code. Very usefull thing if you write autogenerating forms. At least you don&#8217;t have to learn another language.</p>
<p> </p>
<p><strong><a href="http://blog.objectmentor.com/articles/2009/02/06/on-open-letter-to-joel-spolsky-and-jeff-atwood" target="_blank">Lawsuit material interlude</a></strong></p>
<p>First candidate is <a href="http://www.codinghorror.com/" target="_blank">Jeff Atwood</a>. He pokes template engines because they tend to get complicated.</p>
<blockquote><p>[...] but you can see where templating naturally tends toward a frantic, unreadable mish-mash of code and template &#8212; <a href="http://www.codinghorror.com/blog/archives/001155.html">Web Development as Tag Soup</a>. If your HTML templates can&#8217;t be kept simple, they&#8217;re not a heck of a lot better than the procedural string building code they&#8217;re replacing. And this is not an easy thing to stay on top of, in my experience. The daily grind of struggling to keep the templates from devolving into tag soup starts to feel every bit as grotty as all that nasty string work we were theoretically replacing.</p></blockquote>
<p>Dear Jeff, I suppose you are familiar with an ancient programming concept, called <strong>functions</strong>. You know, you get a bunch of code, give it a name and replace all instances of that code with the name. Your code will look cleaner and it will be easy to maintain. Most &#8220;non sucky&#8221; template engines have something similar to functions, the sub-templates. Using the same principle, you can split your huge, unmaintainable and messy template and it will became smaller and easier to maintain. I am a genius!</p>
<p>Next on list is <a href="http://www.codesoftly.aaronoliver.com/2009/02/ill-give-you-my-template-when-you-pry-it-from-my-cold-dead-hands.html" target="_blank">Aaron Oliver</a>: </p>
<blockquote><p>By keeping markup <strong>very</strong> far away from business logic, the core logic is more stable and there&#8217;s less temptation to mingle concerns.</p></blockquote>
<p>You think your template code is better than Jeff&#8217;s mixed code? How is mixing VB with HTML worse than mixing Template Language code with HTML? They are both examples of mixing code with markup. There is no difference between a bad tag soup and a cocktail of VB and HTML, with JavaScript on top for flavour! </p>
<p>As a conclusion, you both are terrible wrong. There is nothing inherently wrong about any of the solutions, apart the guy that is criticising. Both complain the other solution is ugly, unmaintainable and a pain in the ass. But they are like that because of your own inability to do better. It&#8217;s like saying you drive too fast because the gas pedal is easy to push.</p>
<p> </p>
<p><strong>Enough fun, let&#8217;s go back to serious stuff, young </strong><strong><a href="http://starwars.wikia.com/wiki/Padawan" target="_blank">padawan</a></strong></p>
<p><strong>The problem</strong> at hand is easy to describe: get some data from somewhere and display it to the user. </p>
<p>What are the solutions for this? Answers below.</p>
<p> </p>
<p><strong>1) Plain scripts</strong></p>
<pre>1) Get and prepare the input parameters (from POST, GET etc).
2) Fetch the data.
3) Prepare the data for output.
4) Output all the html, mixing code and markup.</pre>
<p>This is the one and only <strong>real</strong> solution to the problem, all others are based on this and are just ways to accomplish the same thing easier. </p>
<p><em>Use this everywhere, if you can master it.</em></p>
<p> <br />
<strong> 2) Framework with no templates for output</strong></p>
<p>Same as above, but helps you separate the logic parts of the script and reuse the code. It will automatically prepare the input parameters (if the framework is a good one), gives you some premade data fetching code and it is pretty clear where you need to insert the display part, the mix of code and markup. </p>
<p><em>This is a smarter alternative to the first solution. However, it adds some overhead.</em></p>
<p> </p>
<p><strong>3) Plain scripts with a template engine</strong></p>
<p>Same as the first solution, but you use a template engine to forcefully separate your main language from the markup. </p>
<p><em>Use this if you don&#8217;t want the overhead added by a framework and you find that mixing main code with markup it&#8217;s worse than mixing template language with the markup. You still get to learn a new mini language. Or you are a lucky guy that knows that smart designer.</em></p>
<p> </p>
<p><strong>4) Framework with a template engine</strong></p>
<p>Separation with even more overhead. </p>
<p><em>Use this if the overhead doesn&#8217;t bother you and you work with that smart designer.</em></p>
<p> </p>
<p><strong>5) Plain scripts with markup generating code</strong></p>
<p>Instead of writing markup by hand, some generator is used. The code and markup mix is hidden below a layer of functions/objects.</p>
<p><em>Use this if you don&#8217;t require any advanced markup skills. Also, see point 7 below.</em></p>
<p> </p>
<p><strong>6) Framework with markup generating code</strong></p>
<p>OOP at it&#8217;s max. However, the generator might not be perfect and some complicated workarounds might be needed.</p>
<p><em>Use this if you like all the benefits of a framework, are not bothered with the limitations and you have doubts about your markup skills.</em> </p>
<p> </p>
<p><strong>7) Plain script/framework with ajax</strong></p>
<p>Instead of doing all the work on the server side, the display is delegated to the browser. The browser is already re-parsing your output to render it on the screen. You send data in a format the browser will understand (XML or Json), with no display indicators and the browser will display it as it sees fit. However, no browser can do that by itself and another application needs to be build, that will instruct the browser on how to display your data. While each of the logic tasks are now completly separated, the web server might not like it if your biggest bottleneck is the HTTP request itself and not the data fetching or processing.</p>
<p>This is a special case of the solutions 5 and 6. </p>
<p><em>Use this if you know exactly how your clients will react and the HTTP request is your main bottleneck: intranet apps.</em> </p>
<p> </p>
<p><strong>Conclusion: </strong>as you can see, all solutions are based on 4 simple steps (see the first solution). If you have problems using the first solution, then you will have problems using any other solution. In the end, use whatever you want, but stop bashing other solutions just because you fail to use it properly.</p>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/g6wOy5EvHqk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/rants/web-development-and-template-engines.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>CMT - Utils</title>
		<link>http://www.coada.net/dev/cmt-utils.html</link>
		<comments>http://www.coada.net/dev/cmt-utils.html#comments</comments>
		<pubDate>Wed, 04 Feb 2009 18:59:34 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Dev]]></category>

		<category><![CDATA[c++]]></category>

		<category><![CDATA[cmt]]></category>

		<category><![CDATA[multiplatform]]></category>

		<category><![CDATA[visual c++]]></category>

		<guid isPermaLink="false">http://www.coada.net/?p=163</guid>
		<description><![CDATA[CMT will require some utility functions, eg get the directory where I can write my temporary files, get the directory where I will keep the config files and so on.
For the regular windows developer, this might seem like a pointless task, because you can write stuff in the registry. I am not the regular windows [...]]]></description>
			<content:encoded><![CDATA[<p>CMT will require some utility functions, eg get the directory where I can write my temporary files, get the directory where I will keep the config files and so on.</p>
<p>For the regular windows developer, this might seem like a pointless task, because you can write stuff in the registry. I am not the regular windows developer and I&#8217;d rather keep away from the registry. And, I want to have the same format for the config files, both on Windows and on the other platforms (Linux or FreeBSD). </p>
<p>There are some differences where a good programmer would store the config files. For windows, this should look like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">X:\Documents and Settings\<span style="color: #000000; font-weight: bold;">%</span>username<span style="color: #000000; font-weight: bold;">%</span>\Application Data\myapp\</pre></div></div>

<p>and on Linux or FreeBSD, it should look like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/%</span>username<span style="color: #000000; font-weight: bold;">%/</span>.myapp<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Hopefully, wxWidgets provides as with a function to get the <strong>home</strong> directory for an user,</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wxFileName::GetHomeDir</pre></div></div>

<p>However, we still have a problem. On Windows, that function will return </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">X:\Documents and Settings\<span style="color: #000000; font-weight: bold;">%</span>username<span style="color: #000000; font-weight: bold;">%</span>\</pre></div></div>

<p>while on Linux/FreeBSD it will return</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/%</span>username<span style="color: #000000; font-weight: bold;">%/</span></pre></div></div>

<p>As you can see, the Linux/FreeBSD output is enough for my task, I can append .appname and I have the path to the directory where I can write my stuff.<br />
On windows, what I get from this function is not enough. I still need to append &#8220;Application Data&#8221;, which on Windows installs with a different language than English, is translated too.</p>
<p>Msdn suggests using <em>SHGetFolderPath</em> with <em>CSIDL_APPDATA</em> parameter to get the full path to the Application Data folder for each user. And this works, from my experience with other windows projects, also for non english installs. </p>
<p>Some code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">bool</span> CApplicationSettings<span style="color: #008080;">::</span><span style="color: #007788;">GetConfigDirectory</span><span style="color: #008000;">&#40;</span>wxString <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span>confdir<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">bool</span> bRet <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
	bRet <span style="color: #000080;">=</span> CApplicationSettings<span style="color: #008080;">::</span><span style="color: #007788;">GetApplicationDataPath</span><span style="color: #008000;">&#40;</span>confdir<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>bRet<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
                <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>confdir.<span style="color: #007788;">Length</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		     confdir <span style="color: #000080;">=</span> wxFileName<span style="color: #008080;">::</span><span style="color: #007788;">GetHomeDir</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
                <span style="color: #008000;">&#125;</span>
                confdir.<span style="color: #007788;">append</span><span style="color: #008000;">&#40;</span>wxFileName<span style="color: #008080;">::</span><span style="color: #007788;">GetPathSeparator</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	        confdir.<span style="color: #007788;">append</span><span style="color: #008000;">&#40;</span>wxT<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;.cmt&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
            	confdir.<span style="color: #007788;">append</span><span style="color: #008000;">&#40;</span>wxFileName<span style="color: #008080;">::</span><span style="color: #007788;">GetPathSeparator</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">return</span> bRet<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">bool</span> CApplicationSettings<span style="color: #008080;">::</span><span style="color: #007788;">GetApplicationDataPath</span><span style="color: #008000;">&#40;</span>wxString <span style="color: #000040;">&amp;</span>amp<span style="color: #008080;">;</span>path<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// _WIN64 is for 64 bit only, _WIN32 is always defined on Windows</span>
	<span style="color: #0000ff;">bool</span> bRet <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
        path <span style="color: #000080;">=</span> wxT<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #339900;">#ifdef _WIN32</span>
	TCHAR szPath<span style="color: #008000;">&#91;</span>MAX_PATH<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">BOOL</span> ret <span style="color: #000080;">=</span> SHGetFolderPath<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">NULL</span>,CSIDL_APPDATA , <span style="color: #0000ff;">NULL</span>, <span style="color: #0000dd;">0</span>, szPath <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #666666;">// add checks</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>ret<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
              <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
	path.<span style="color: #007788;">append</span><span style="color: #008000;">&#40;</span>szPath<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #339900;">#endif</span>
	<span style="color: #0000ff;">return</span> bRet<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>If the code runs on Linux/FreeBSD, <em>GetApplicationDataPath</em> will return true and the path will be empty. So, go on and use wxWidgets function to get the home dir, attach .cmt and return true.<br />
If the code runs on Windows and there are any problems getting the App Data dir, the function will return false. If the function correctly got the App Data dir, we attach .cmt and return true.</p>
<p><a href="http://www.tractionthroughaction.com/developmentdiary" target="_blank">Someone</a> suggested to read the enviroment variables <em>%APPDATA%</em> for Windows and <em>$HOME</em> for Linux/FreeBSD. This solution seems simpler to implement and if I get enough time, I will research it to see if there are any drawbacks.</p>
<p>However, as this functionality is internal to the <em>CApplicationSettings</em> class, its users won&#8217;t be affected by a change at a latter time.</p>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/GFgWUNd2Xcc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/dev/cmt-utils.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>CMT Interlude: how to use OOP</title>
		<link>http://www.coada.net/dev/cmt-interlude-how-to-use-oop.html</link>
		<comments>http://www.coada.net/dev/cmt-interlude-how-to-use-oop.html#comments</comments>
		<pubDate>Mon, 02 Feb 2009 16:28:36 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Dev]]></category>

		<category><![CDATA[application design]]></category>

		<category><![CDATA[interlude]]></category>

		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.coada.net/?p=131</guid>
		<description><![CDATA[Most textbooks about OOP I read, say you should use classes to describe abstract types. They also say you should use inheritance, when you want to add more functionality to a base class. And the last thing they say, among many others, is to use multiple inheritance to build complex types, that match in functionality [...]]]></description>
			<content:encoded><![CDATA[<p>Most textbooks about OOP I read, say you should use classes to describe abstract types. They also say you should use inheritance, when you want to add more functionality to a base class. And the last thing they say, among many others, is to use multiple inheritance to build complex types, that match in functionality all the base classes.</p>
<p>While I agree with the first two statements, I totally disagree with the last one. And this interlude should clarify that.</p>
<p>Before I go on with my rant, I want to explain a bit the philosophy I use when dealing with OOP: you always have to work with <strong>consumers</strong> and <strong>providers</strong>. </p>
<p>The <strong>consumer</strong> is the user of your class or class hierarchy. The consumer doesn&#8217;t care <strong>how</strong> your class does its job, but only that your class does it, when it does it or why it doesn&#8217;t. </p>
<p>The <strong>provider</strong> is your class or class hierarchy. Think about it as a mini library, the user of your library doesn&#8217;t care how you do your job as long as you do it.</p>
<p> </p>
<p>In <a href="http://www.coada.net/dev/cable-modem-tester.html">CTM</a> I have a base class that describes the Cable Modem abstract type. All other objects from my project will have to work with this abstract type and are only interested in the modem status, synchronized or not and they don&#8217;t care how the object gets that status. My consumers won&#8217;t even care about the cable modem type, they just need a text that describes the modem so they can show that to the user. So, my CModemDetailsBase describes the abstract type my application works with.</p>
<p>In the future I plan to add more modem types to my application. So, I wrote a second class, CWebstarModem, that inherits from CModemDetailsBase class and contains the specific logic for this kind of modem. However, my consumers won&#8217;t care if they use a Webstar modem or any other type of modem as long as they can simply ask the modem object about it&#8217;s status. I added new functionality to a base class, but internal only. </p>
<p>I agree with the second statement from my first paragraph, but I&#8217;m not always using inheritance: I use it only and just only I want my extended class to be used as my base class. If I get no benefit from inheritance, I&#8217;m not using it. Examples below.</p>
<p><strong>Good way</strong>: in my project, so far, I have a CModemDetailsBase and a CWebstarModem that inherits from the base class. Later, I will add a CSNMPModem and a CHTTPModem, first dealing with modems that allow you to query them through SNMP and the second with modems, like my current modem, that let you get the status through HTTP. This way, I will have to write the connection code for each type of modem just once. I still have my original functionality in place, allow the consumers to threat my objects in the same way and properly reuse code. </p>
<p><strong>Bad way</strong>: let&#8217;s suppose you want to add checking functionality to your form fields. You want a simple method to have the fields in the form checked for proper values. One solution would be to extend the form fields classes, text box, checkbox, radio buttons etc and add the checking functionality. Not such a good idea, because now you will have to extend all types of form fields. Not to mention you will mix GUI code to controller code. </p>
<p>A better way to solve this problem would be to build a new type of object, CFormField, which will have a GUI member, the textbox, the checkbox, etc and a checking member, which will deal only with the value checking. Now, you can build a class hierarchy that deals only with checking values, instead of building a class hierarchy that deals with all kinds of mixes, CEmailTextbox, CNameTextbox, CNameSelect etc. Also, you can re-use the checkers in other places, outside of a form, let&#8217;s say to check if values coming from a web service are valid.</p>
<p>The second example has a third solution, which illustrates the third statement from the first paragraph, the one I disagree with. You could build a new class, that inherits from both GUI element and checking element. Now, you have an object, that is in the same time a GUI element and a checking element. This implies you already have the checking classes hierarchy and it assumes you will build all the mixes you need, like in the second example. Complexity of your code will go up, it will be harder to debug and what not.</p>
<p> </p>
<p>In the end, here are some thumb rules for working with OOP:</p>
<ol>
<li><strong>Never aggregate problems.</strong> Have a class solve one problem. If the problem can be split, use as many classes as sub problems you have. Detach the sub problem details from the main problem as much as possible. For this, never inherit from more than one base class.</li>
<li><strong>Hide as much as you can.</strong> Keep the implementation details hidden from the consumer. Show them only what they need to see. This way, you keep your objects as decoupled as possible and make code re usability easier.</li>
<li><strong>Keep the choices at a minimum.</strong> Your consumers should focus on solving their own problem, instead of trying to figure out how to use your provider.</li>
</ol>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/1GdT8IPzmTA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/dev/cmt-interlude-how-to-use-oop.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Cable Modem Tester - Journey to a multiplatform app</title>
		<link>http://www.coada.net/dev/cable-modem-tester.html</link>
		<comments>http://www.coada.net/dev/cable-modem-tester.html#comments</comments>
		<pubDate>Mon, 02 Feb 2009 13:27:44 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Dev]]></category>

		<category><![CDATA[application design]]></category>

		<category><![CDATA[cmt]]></category>

		<guid isPermaLink="false">http://www.coada.net/?p=121</guid>
		<description><![CDATA[In this series, I want to document the process of making a multiplatform application. I will try to post about everything I do while building this app, from design decisions, to writing the scripts that will build it. However, you should not see this as some sort of tutorial, but instead as my take on [...]]]></description>
			<content:encoded><![CDATA[<p>In this series, I want to document the process of making a multiplatform application. I will try to post about everything I do while building this app, from design decisions, to writing the scripts that will build it. However, you should not see this as some sort of tutorial, but instead as my take on the subject, along with the bad decisions I might take. </p>
<p>This post will also server as some sort of index, for every other post related to the project. </p>
<p>There are no rules, no 40 hours work week, no only open source libs, nothing. Only what I believe it&#8217;s best for the task at hand.</p>
<p>The application I chose is Cable Modem Tester, or CMT. I want to build this app because it shouldn&#8217;t require lots of coding and it will actually be useful to me: my ISP has some problems with the signal and the modem desyncs itself exactly when you expect it less. This way, when my connection is down, I will know from start if the problem is with my router or the ISP (not that I had any problems with the router from the moment I set it up, back in the days when FreeBSD 6.0 was a rc).</p>
<p> </p>
<p>Other articles:</p>
<p><a href="http://www.coada.net/dev/cmt-1.html">initial requirements and design</a></p>
<p><a href="http://www.coada.net/dev/cmt-utils.html" target="_self">utils</a></p>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/TGrV0rvzm-o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/dev/cable-modem-tester.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>CMT - Initial requirements and design</title>
		<link>http://www.coada.net/dev/cmt-1.html</link>
		<comments>http://www.coada.net/dev/cmt-1.html#comments</comments>
		<pubDate>Mon, 02 Feb 2009 13:16:39 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Dev]]></category>

		<category><![CDATA[application design]]></category>

		<category><![CDATA[c++]]></category>

		<category><![CDATA[cmt]]></category>

		<category><![CDATA[curl]]></category>

		<category><![CDATA[visual c++]]></category>

		<category><![CDATA[visual studio]]></category>

		<category><![CDATA[wxwidgets]]></category>

		<guid isPermaLink="false">http://www.coada.net/?p=115</guid>
		<description><![CDATA[WORK IN PROGRESS
First article: initial requirements and design
I want a CLI application, that will get as parameters the cable modem url and a refresh time. It will print the status of the cable modem (syncronised or not). The only reliable way to get this data from the cable modem that I know of at this [...]]]></description>
			<content:encoded><![CDATA[<p><strong>WORK IN PROGRESS</strong></p>
<p><strong>First article: initial requirements and design</strong></p>
<p>I want a CLI application, that will get as parameters the cable modem url and a refresh time. It will print the status of the cable modem (syncronised or not). The only reliable way to get this data from the cable modem that I know of at this point is through the web interface. Some isp&#8217;s like my own, will block access to other ways to check the modem.</p>
<p><a href="http://www.coada.net/dev/ctm-interlude-how-to-use-oop.html">Interlude: How to use OOP</a></p>
<p>Because there are many types of cable modems used, I want an object that will gather the required data by itself and have a way to present that data to a consumer. So, my object should know about:</p>
<ol>
<li>initialisation, with the cable modem type (maybe also the url and port) and refresh time.</li>
<li>a start method, that will put the object in &#8220;data retrieve&#8221; mode.</li>
<li>a stop method, that will change the &#8220;data retrieve&#8221; mode to a &#8220;stop mode&#8221;.</li>
<li>cleanup, to allow the object to clean the mess.</li>
<li>get the syncronisation status, to allow a consumer to get the connection state.</li>
</ol>
<p>My object should automaticaly gather the data it needs, after put in &#8220;data retrieve&#8221; mode. Thus, it will need to start a thread and do the http transfer and file processing in that thread. An user of this object should only care to start, stop and ask the object for the data.</p>
<p>I will be using cUrl library to perform the http requests. Probably, I will also use wxWidgets for the portable threads and later for the GUI.</p>
<p> </p>
<p>Preparation:</p>
<p>- set up a Visual Studio Solution</p>
<p>- set up the project to use curl</p>
<p>- set up the project to use wxWidgets</p>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/1Jj7aTxHO80" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/dev/cmt-1.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>… on working from home</title>
		<link>http://www.coada.net/featured-articles/on-working-from-home.html</link>
		<comments>http://www.coada.net/featured-articles/on-working-from-home.html#comments</comments>
		<pubDate>Fri, 30 Jan 2009 13:29:52 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Featured Articles]]></category>

		<category><![CDATA[Rants]]></category>

		<category><![CDATA[home]]></category>

		<category><![CDATA[home office]]></category>

		<category><![CDATA[manager]]></category>

		<category><![CDATA[office]]></category>

		<category><![CDATA[productivity]]></category>

		<category><![CDATA[regular people]]></category>

		<category><![CDATA[regular worker]]></category>

		<category><![CDATA[working from home]]></category>

		<guid isPermaLink="false">http://www.coada.net/?p=59</guid>
		<description><![CDATA[Working from home is a way more complicated problem than it seems. Here are some reasons why you are not allowed to work from home.]]></description>
			<content:encoded><![CDATA[<p>Working from home is a way more complicated problem than it seems. Here are some reasons why you are not allowed to work from home.</p>
<p> </p>
<p>Most people work just to get in a paycheck and not because they like their work or care to do a better job. For them, if your company sold last month just enough to pay for everything, it&#8217;s enough. No need to improve, no need to change. For them, work is just a necessarily evil, not a way to accomplish something. Their &#8220;work&#8221; is being in the office for 8 hours and the actual work they do is just an afterthought. These are the people that want to be promoted because of the perks of the higher position and not because they feel they can do a better job. These are the people that expect automatic promotion or rises after a set amount of time. You know these people exist, but everywhere you look, on the Internet, on TV, you see only the guys that did exactly the opposite of them and you might be tempted to believe the &#8220;regular&#8221; guys are a minority. This is not true because there is nothing one can write about them, thus there is nothing you can read about them either. Keep this in mind, while your primary goal at the company you work for is to improve your work, the others just want their paycheck and go home with it.</p>
<p> </p>
<p>While there are some people that can properly work from home, most can&#8217;t. And it&#8217;s not because you can&#8217;t communicate face to face with your coworkers, but most of us can&#8217;t focus properly when at home. You need a great deal of self discipline to work from home. There are plenty of distractions, from TV to kids, pets and daily home routine (do the dishes, cook, get out the garbage, do the laundry etc). Also, some of us are pretty much lost if there is no senior to tell them what to do. Also, most people won&#8217;t find something rewarding and fun in the work they do, but in the things they do while &#8220;at work&#8221;: speak with coworkers during lunch breaks, the usual chit-chat from the office, the stuff they are used to see as fun from the school days. And you can&#8217;t do all that if you are at home.</p>
<p> </p>
<p>There are two reasons why you are not allowed to work from home.</p>
<p> </p>
<p> </p>
<p><strong>The first reason</strong> is the impact of you working from home will have on the &#8220;regular&#8221; workers. They will fail, because of the numerous distractions and when being denied to do it again, they will conclude that &#8220;working from home&#8221; is just a perk, not a way to work. As their only work measurement unit is the amount of time you spend in the office, the manager will end up with a bunch of disgruntled workers and nobody wants that. So, instead of making you as productive as you can get, the manager will try to keep the full team as productive as it can get, even if this means he is wasting you. </p>
<p> </p>
<div id="attachment_74" class="wp-caption aligncenter" style="width: 384px"><a href="http://www.wetherobots.com/2008/07/29/good-job/"><img class="size-full wp-image-74" title="We The Robots: Good Work, part 1" src="http://www.coada.net/wp-content/uploads/2009/01/wtr_good_job_1.jpg" alt="We The Robots: Good Work, part 1" width="374" height="290" /></a><p class="wp-caption-text">We The Robots: Good Work, part 1</p></div>
<p><strong>The second reason</strong> is the simple fact that today&#8217;s managers are yesterday regular workers. They simply can&#8217;t imagine there are smart ways to improve productivity and they genuinely believe that the only way to get more work done is to stay more in the office. These guys are the ones that will deny you having a second display, or a better chair, or a better desk. These are the guys that will push 20 people in a small space reasoning that you need space only for a keyboard and a display and the office noise is just something you get to deal with. These are the guys that will try to apply to your problems, solutions from a totally different and irrelevant industry.</p>
<div id="attachment_73" class="wp-caption aligncenter" style="width: 385px"><a href="http://www.wetherobots.com/2008/07/29/good-job/"><img class="size-full wp-image-73" title="We The Robots, Good Work, part 2" src="http://www.coada.net/wp-content/uploads/2009/01/wtr_good_job_2.jpg" alt="We The Robots, Good Work, part 2" width="375" height="290" /></a><p class="wp-caption-text">We The Robots, Good Work, part 2</p></div>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/RW5bSI5A3Ts" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/featured-articles/on-working-from-home.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Hello World!</title>
		<link>http://www.coada.net/charlie/hello-world-2.html</link>
		<comments>http://www.coada.net/charlie/hello-world-2.html#comments</comments>
		<pubDate>Fri, 02 Jan 2009 11:29:24 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Charlie]]></category>

		<category><![CDATA[Campbell]]></category>

		<category><![CDATA[dwarf]]></category>

		<category><![CDATA[hasmter]]></category>

		<guid isPermaLink="false">http://www.coada.net/test_area/wp/?p=20</guid>
		<description><![CDATA[Charlie is my Campbell&#8217;s dwarf hamster and she was born on March 16, 2008.
]]></description>
			<content:encoded><![CDATA[<p>Charlie is my Campbell&#8217;s dwarf hamster and she was born on March 16, 2008.</p>

<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc01992' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc01992-150x84.jpg" width="150" height="84" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc01993' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc01993-150x84.jpg" width="150" height="84" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc01994' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc01994-84x150.jpg" width="84" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc01995' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc01995-84x150.jpg" width="84" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc02010' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc02010-150x84.jpg" width="150" height="84" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc02011' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc02011-150x84.jpg" width="150" height="84" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc02012' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc02012-150x84.jpg" width="150" height="84" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc02013' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc02013-150x84.jpg" width="150" height="84" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc02014' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc02014-150x84.jpg" width="150" height="84" class="attachment-thumbnail" alt="" /></a>
<a href='http://www.coada.net/charlie/hello-world-2.html/attachment/dsc02023' title='Charlie'><img src="http://www.coada.net/wp-content/uploads/2009/02/dsc02023-150x84.jpg" width="150" height="84" class="attachment-thumbnail" alt="" /></a>

<img src="http://feeds.feedburner.com/~r/Coadanet/~4/HxYBu5H47Zo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/charlie/hello-world-2.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://www.coada.net/dev/hello-world.html</link>
		<comments>http://www.coada.net/dev/hello-world.html#comments</comments>
		<pubDate>Thu, 01 Jan 2009 16:14:26 +0000</pubDate>
		<dc:creator>coditza</dc:creator>
		
		<category><![CDATA[Audio]]></category>

		<category><![CDATA[Dev]]></category>

		<category><![CDATA[Lists]]></category>

		<guid isPermaLink="false">http://www.coada.net/test_area/wp/?p=1</guid>
		<description><![CDATA[Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
]]></description>
			<content:encoded><![CDATA[<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
<img src="http://feeds.feedburner.com/~r/Coadanet/~4/TZ6MyiLa3XI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.coada.net/dev/hello-world.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
