<?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>tomrochette.com &#187; Programmation</title>
	<atom:link href="http://www.tomrochette.com/category/programmation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tomrochette.com</link>
	<description>What&#039;s up with my life</description>
	<lastBuildDate>Sat, 17 Dec 2011 23:30:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHPUnit &#8211; PHP Fatal error: require_once(): Failed opening required &#8216;PHPUnit/Util/Filter.php&#8217;</title>
		<link>http://www.tomrochette.com/phpunit-php-fatal-error-require_once-failed-opening-required-phpunitutilfilter-php/</link>
		<comments>http://www.tomrochette.com/phpunit-php-fatal-error-require_once-failed-opening-required-phpunitutilfilter-php/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 00:14:53 +0000</pubDate>
		<dc:creator>tomzx</dc:creator>
				<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://www.tomrochette.com/?p=656</guid>
		<description><![CDATA[A friend of mine was trying to install PHPUnit on his mac (OS X Lion), but unfortunately, he got stuck during the process. At some point, he was faced with this error being displayed. We both looked at the problem and first made sure that said file existed. It was the case, weird&#8230; A bit [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine was trying to install PHPUnit on his mac (OS X Lion), but unfortunately, he got stuck during the process.</p>
<p>At some point, he was faced with this error being displayed. We both looked at the problem and first made sure that said file existed. It was the case, weird&#8230;</p>
<p>A bit of googling will reveal that this is frequently fixed by appending the path to the pear folder to your php include_path (defined in your php.ini). But in his case, that was already done and it still wasn&#8217;t working.</p>
<p>Next up was to check permissions problem. Not having read permissions on the file would of been an easy one to fix, but again, this was not the cause of the problem.</p>
<p>At this point you might be asking yourself, how come the file exists, you have permission to read it, but yet, you can&#8217;t&#8230;</p>
<p>Well, the actual problem was that his OS was set up such that the maxfiles was set to 256 and PHPUnit had already reached that amount of open files.</p>
<p>To check if you have the same problem, try running phpunit using <strong>sudo dtruss -f -t open phpunit</strong> (Linux users will want to use <strong>strace -e open phpunit</strong>). In your output, you should see the files being opened. At some point, you&#8217;ll find <strong>Err#24</strong>, which indicates &#8220;To many file descriptors opened&#8221;. If you have this problem, then the following should help you fix it.</p>
<p>The solution to this problem is quite easy. What you&#8217;ll want to do is increase the maximum number of descriptors that can be used by a process. You can do it temporarily with <strong>ulimit -S -n 1024</strong> (to use 1024 instead of 256). Another way is to edit it and keep those settings (until you change them again) is to use <strong>launchctl limit maxfiles 1024 unlimited</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomrochette.com/phpunit-php-fatal-error-require_once-failed-opening-required-phpunitutilfilter-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPUnit not outputting coverage-html</title>
		<link>http://www.tomrochette.com/phpunit-not-outputting-coverage-html/</link>
		<comments>http://www.tomrochette.com/phpunit-not-outputting-coverage-html/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 01:31:45 +0000</pubDate>
		<dc:creator>tomzx</dc:creator>
				<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://www.tomrochette.com/?p=643</guid>
		<description><![CDATA[I&#8217;ve been using PHPUnit recently to test a Kohana application I&#8217;m developing as my last semester project for my bachelor&#8217;s degree. At some point during the development, code coverage generation decided to stop working on my desktop (my remote CI still had no problem). I started diagnosing the problem, being on Windows, I thought it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using PHPUnit recently to test a Kohana application I&#8217;m developing as my last semester project for my bachelor&#8217;s degree.</p>
<p>At some point during the development, code coverage generation decided to stop working on my desktop (my remote CI still had no problem).</p>
<p>I started diagnosing the problem, being on Windows, I thought it could be due to the &#8220;poor job&#8221; I had done on installing php, pear and phpunit. I didn&#8217;t want to go through the trouble or reinstalling everything though and just did the minimum: uninstall and reinstall phpunit. No success at that point.</p>
<p>I decided to go back a week or two in my SVN revisions, have it generate code coverage and get to the point were code coverage generation would fail. Took around 2 SVN &#8220;update to&#8221; to get to that point. After that, I tried updating the tests, but the new tests were using new features. So I updated the code first, then started updating the test files one by one. After a couple of files, I hit an interesting message:</p>
<p><strong>ErrorException [ 1 ]: Allowed memory size of 134217728 bytes exhausted (tried to allocate 543278 bytes) ~ C:\php\pear\Text\Template.php [ 134 ]</strong></p>
<p>I never had that message show up before, which is kind of strange. I would have expected PHP to tell me that same message everytime it tried to generate the documentation but couldn&#8217;t&#8230;</p>
<p>So, quick fix was for me to edit my php.ini so that the memory_limit = 256M instead of 128M.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomrochette.com/phpunit-not-outputting-coverage-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Serializing &#8220;anything&#8221; in C# using extensions</title>
		<link>http://www.tomrochette.com/serializing-anything-in-c-using-extensions/</link>
		<comments>http://www.tomrochette.com/serializing-anything-in-c-using-extensions/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 04:22:07 +0000</pubDate>
		<dc:creator>tomzx</dc:creator>
				<category><![CDATA[Informatique]]></category>
		<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://www.tomrochette.com/?p=615</guid>
		<description><![CDATA[I was recently interested in getting C# objects to serialize into XML so that I could save and load a configuration out of a file. Sadly, C# support for XML and serialization is far from the best stuff I&#8217;ve seen in programming. But anyway, here&#8217;s what this post is about: using DataContract with a bit [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently interested in getting C# objects to serialize into XML so that I could save and load a configuration out of a file. Sadly, C# support for XML and serialization is far from the best stuff I&#8217;ve seen in programming. But anyway, here&#8217;s what this post is about: using DataContract with a bit of extension magic to get anything to be serializable into XML!</p>
<p>One small problem when you use the Serializable attribute of C# is that you cannot serialize dictionary directly and we all know dictionaries are a VERY useful structure to have serialized. One easy way to have serializable dictionaries is to use the DataContract attribute instead. It implies a bit more code compared to the version where you use the Serializable attribute, but not that much more (mostly the WriteObject and ReadObject lines).</p>
<p>I haven&#8217;t coded any of this, so thanks to user <a href="http://stackoverflow.com/users/285678/loudenvier">Loudenvier</a> from <a href="http://www.stackoverflow.com">Stackoverflow.com</a>! This solution allows you to turn ANY object into an XML string representation. It also allows you to turn that string back into an object representation. Very useful.</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
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> SerializationExtensions
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">string</span> Serialize<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> T obj<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var serializer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DataContractSerializer<span style="color: #008000;">&#40;</span>obj<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>var writer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringWriter<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>var stm <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XmlTextWriter<span style="color: #008000;">&#40;</span>writer<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            serializer<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteObject</span><span style="color: #008000;">&#40;</span>stm, obj<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> writer<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> T Deserialize<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">string</span> serialized<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        var serializer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DataContractSerializer<span style="color: #008000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>var reader <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringReader<span style="color: #008000;">&#40;</span>serialized<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008000;">&#40;</span>var stm <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XmlTextReader<span style="color: #008000;">&#40;</span>reader<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span>serializer<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadObject</span><span style="color: #008000;">&#40;</span>stm<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>How to use example</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// dictionary to serialize to string</span>
Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&gt;</span> myDict <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008080; font-style: italic;">// add items to the dictionary...</span>
myDict<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">...</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008080; font-style: italic;">// serialization is straight-forward</span>
<span style="color: #6666cc; font-weight: bold;">string</span> serialized <span style="color: #008000;">=</span> myDict<span style="color: #008000;">.</span><span style="color: #0000FF;">Serialize</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">...</span>
<span style="color: #008080; font-style: italic;">// deserialization is just as simple</span>
Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>, <span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&gt;</span> myDictCopy <span style="color: #008000;">=</span> serialized<span style="color: #008000;">.</span><span style="color: #0000FF;">Deserialize</span><span style="color: #008000;">&lt;</span>Dictionary<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span>,<span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&gt;&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p><strong>Source:</strong> <a href="http://www.stackoverflow.com/questions/1124597/why-isnt-there-an-xml-serializable-dictionary-in-net/5941122#5941122">http://www.stackoverflow.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomrochette.com/serializing-anything-in-c-using-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enginuity series on GameDev.net</title>
		<link>http://www.tomrochette.com/enginuity-series-on-gamedev-net/</link>
		<comments>http://www.tomrochette.com/enginuity-series-on-gamedev-net/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 04:01:00 +0000</pubDate>
		<dc:creator>tomzx</dc:creator>
				<category><![CDATA[Programmation]]></category>
		<category><![CDATA[gamedev]]></category>

		<guid isPermaLink="false">http://www.tomrochette.com/?p=598</guid>
		<description><![CDATA[I&#8217;ve just stumbled upon a series of articles from Richard Fine that were written in 2003 which describes the basics of a game engine he calls Enginuity. It lays the foundations to basic memory management, logging, kernel and tasks management and much more. An extremely interesting read. Sadly, you can read in the articles that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just stumbled upon a series of articles from Richard Fine that were written in 2003 which describes the basics of a game engine he calls Enginuity. It lays the foundations to basic memory management, logging, kernel and tasks management and much more. An extremely interesting read. Sadly, you can read in the articles that this was projected to be a series of more than 8 articles, but it seems it stopped at the fifth article. If anyone knows where to find the rest (if it exists), I&#8217;d be grateful!</p>
<p><strong>On GameDev.net:</strong> <a href="http://www.gamedev.net/page/resources/_/reference/programming/game-programming/300/enginuity-part-i-r1947">Part 1</a> <a href="http://www.gamedev.net/page/resources/_/reference/programming/game-programming/300/enginuity-part-ii-r1954">Part 2</a> <a href="http://www.gamedev.net/page/resources/_/reference/programming/game-programming/300/enginuity-part-iii-r1959">Part 3</a> <a href="http://www.gamedev.net/page/resources/_/reference/programming/game-programming/300/enginuity-part-iv-r1973">Part 4</a> <a href="http://www.gamedev.net/page/resources/_/reference/programming/game-programming/300/enginuity-part-v-r2011">Part 5</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomrochette.com/enginuity-series-on-gamedev-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Marshal un hash avec proc</title>
		<link>http://www.tomrochette.com/marshal-un-hash-avec-proc/</link>
		<comments>http://www.tomrochette.com/marshal-un-hash-avec-proc/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 06:15:15 +0000</pubDate>
		<dc:creator>tomzx</dc:creator>
				<category><![CDATA[Programmation]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tomrochette.com/?p=503</guid>
		<description><![CDATA[Il arrive souvent que l&#8217;on veut écrire un hash imbriqué, tel que objet[:unevaleur][:unesecondevaleur] accédant à la valeur :unesecondevaleur du hash contenu dans objet[:unevaleur]. Voici une implémentation simpliste de la chose. 1 X = Hash.new &#123;&#124;h, k&#124; h&#91;k&#93; = Hash.new&#40;0&#41;&#125; Avec ce code, à chaque fois qu&#8217;on crée un hash non-existant dans X, on ajoute un [...]]]></description>
			<content:encoded><![CDATA[<p>Il arrive souvent que l&#8217;on veut écrire un hash imbriqué, tel que <strong>objet[:unevaleur][:unesecondevaleur]</strong> accédant à la valeur <strong>:unesecondevaleur</strong> du hash contenu dans <strong>objet[:unevaleur]</strong>. Voici une implémentation simpliste de la chose.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">X = <span style="color:#CC00FF; font-weight:bold;">Hash</span>.<span style="color:#9900CC;">new</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>h, k<span style="color:#006600; font-weight:bold;">|</span> h<span style="color:#006600; font-weight:bold;">&#91;</span>k<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#CC00FF; font-weight:bold;">Hash</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></td></tr></table></div>

<p>Avec ce code, à chaque fois qu&#8217;on crée un hash non-existant dans X, on ajoute un nouveau hash avec 0 comme valeur par défaut. Si maintenant on veut marshaller X, on obtient l&#8217;erreur suivante:</p>
<blockquote><p>Marshal.dump(X)<br />
TypeError: can&#8217;t dump hash with default proc</p></blockquote>
<p>On obtient cette erreur puisque, lorsqu&#8217;on crée X, on a passé un bloc à new ce qui fait que lorsqu&#8217;on veut le marshaller, Ruby n&#8217;est pas mesure de marshaller le proc associé.<br />
Afin d&#8217;être en mesure de marshaller X, il suffit simplement d&#8217;éliminer le proc en effectuant une copie vers un nouveau hash sans proc.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">Y = <span style="color:#CC00FF; font-weight:bold;">Hash</span>.<span style="color:#9900CC;">new</span>
X.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>h, k<span style="color:#006600; font-weight:bold;">|</span> Y<span style="color:#006600; font-weight:bold;">&#91;</span>h<span style="color:#006600; font-weight:bold;">&#93;</span> = X<span style="color:#006600; font-weight:bold;">&#91;</span>h<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#CC00FF; font-weight:bold;">Marshal</span>.<span style="color:#9900CC;">dump</span><span style="color:#006600; font-weight:bold;">&#40;</span>Y<span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tomrochette.com/marshal-un-hash-avec-proc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Développement logiciel sur plateforme Linux et Windows</title>
		<link>http://www.tomrochette.com/developpement-logiciel-sur-plateforme-linux-et-windows/</link>
		<comments>http://www.tomrochette.com/developpement-logiciel-sur-plateforme-linux-et-windows/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 02:13:45 +0000</pubDate>
		<dc:creator>tomzx</dc:creator>
				<category><![CDATA[Informatique]]></category>
		<category><![CDATA[Logiciels]]></category>
		<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://www.tomrochette.com/?p=265</guid>
		<description><![CDATA[Le domaine informatique a toujours été dominé par trois géants (du côté consommateur) : Linux, Windows et Macintosh. Les trois systèmes étant très différents, cela a toujours causé des complications aux programmeurs qui voulaient rendre leur code accessible à une plus grande population. Ainsi, ils devaient « porter » leurs codes vers une nouvelle plateforme, [...]]]></description>
			<content:encoded><![CDATA[<p>Le domaine informatique a toujours été dominé par trois géants (du côté consommateur) : Linux, Windows et Macintosh. Les trois systèmes étant très différents, cela a toujours causé des complications aux programmeurs qui voulaient rendre leur code accessible à une plus grande population. Ainsi, ils devaient « porter » leurs codes vers une nouvelle plateforme, soit pour passer de Windows à Macintosh ou encore de Linux vers Windows par exemple. Afin de diminuer cette tâche qui se verrait devenir répétitive, ces développeurs ont eut l’idée de regrouper les ensembles de codes similaires afin d’en former des librairies qu’ils pourraient réutiliser pour accélérer le développement d’applications futures.</p>
<p>Avec l’ensemble des librairies qui ont été codés avec le temps (GTK, FTLK, Qt, wxWidgets, OpenGL, SDL, etc.), la majorité des plateformes informatiques ont commencés à devenir de plus en plus uniformes, permettant ainsi de déployer un même code sur plusieurs machines utilisant des systèmes d’opérations différents. On observe de plus la présence d’environnements de développement intégrés (EDI) multi-plateformes tel que Netbeans, Eclipse et Code::Blocks. Toutefois, il reste à déterminer quelle plateforme est la plus apte à permettre un développement qui sera rapide, efficace et de qualité. Afin de débattre de cette question, il est nécessaire d’évaluer certains aspects essentiels à la création d’un logiciel. Un logiciel peut être très facile à programmer mais être de piètre qualité en termes de performance (facilité de développement). Il peut être très long à programmer mais ne rien coûter (coûts reliées au développement). Les outils que les plateformes nous offrent peuvent être flexibles mais nécessiter une grande connaissance de ceux qui les emploient. Pour le développeur qui souhaite vendre son logiciel, il faut aussi connaître les diverses restrictions qui s’appliquent lorsqu’on emploi une librairie. Bref, il s’agit ici d’un ensemble d’aspects que nous aborderons afin de déterminer quelle plateforme entre Windows et Linux convient le mieux à un programmeur.</p>
<div class="alert">Pour lire l&#8217;ensemble du texte: <a href='http://www.tomrochette.com/wp-content/uploads/2009/04/log2410-tom-rochette.pdf'>Télécharger le PDF</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tomrochette.com/developpement-logiciel-sur-plateforme-linux-et-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmer en objet PHP</title>
		<link>http://www.tomrochette.com/programmer-en-objet-php/</link>
		<comments>http://www.tomrochette.com/programmer-en-objet-php/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 00:06:26 +0000</pubDate>
		<dc:creator>tomzx</dc:creator>
				<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://www.tomrochette.com/?p=95</guid>
		<description><![CDATA[Suite à mon article La programmation orientée objet, je vais vous introduire à la POO (programmation orientée objet) version PHP, ce qui me permettra par la suite de vous en apprendre plus sur la programmation à grande échelle. Commençons donc par les bases. L&#8217;objet en PHP est semblable à celui dans les autres langages: il [...]]]></description>
			<content:encoded><![CDATA[<p>Suite à mon article <a href="http://www.tomrochette.com/la-programmation-orientee-objet/">La programmation orientée objet</a>, je vais vous introduire à la POO (programmation orientée objet) version PHP, ce qui me permettra par la suite de vous en apprendre plus sur la programmation à grande échelle.</p>
<p>Commençons donc par les bases. L&#8217;objet en PHP est semblable à celui dans les autres langages: il contient des attributs (variables) ainsi qu&#8217;un ensemble de méthodes nous permettant de le manipuler.</p>
<p>Afin de rendre ce texte aussi utile qu&#8217;agréable, voici donc un petit objet, qui est en fait une page html:</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Page <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Titre par défaut'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Je suis du contenu'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$title</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setTitle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$title</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setContent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> render<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;html&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;head&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;title'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/title&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/head&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;body&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/body&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/html&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>(oui, cette méthode render() est plutôt malpropre, mais pour les bien de la cause, on va souffrir un peu!)<br />
Ainsi, avec cet objet, il m&#8217;est possible d&#8217;afficher une page HTML dont je peux modifier dynamiquement le contenu ainsi que le titre. Par exemple</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Accueil'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setContent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Ceci est un contenu vraiment intéressant!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Me permet en 4 lignes d&#8217;afficher une page HTML complète (bien sûr il manque quelques tags pour la rendre valide w3c!)</p>
<p>Bon, maintenant voyons ce qui se passe vraiment. Premièrement, on a écrit la définition de notre objet, notre page doit avoir un titre et un contenu. Ce sont nos deux variables privées ($title et $content) car par défaut, un objet veut garder ses attributs (variables) à lui seul. Il en est le seul propriétaire et veut donc être le seul qui peut avoir le plaisir de les modifier. Bien sûr, il est possible de permettre aux autres de modifier ces variables en les rendant publiques, mais pourquoi gâcher le plaisir de notre objet???</p>
<p>Par la suite, on déclare deux méthodes qui permettent de modifier les variables par leur intermédiaire: setTitle($title) et setContent($content). La méthode __construct (débutant en PHP5) est l&#8217;équivalent du constructeur en C++. Lorsqu&#8217;on fait new Page(), il appelle le constructeur en lui donnant aucun attribut, il se contentera donc d&#8217;utiliser ceux par défaut. Finalement, la méthode render() permet l&#8217;affichage dans le navigateur du contenu précédemment affecté par les deux méthodes setTitle et setContent.</p>
<p>Pour ceux qui ne comprennent absolument rien de ce qui vient d&#8217;être dit, passons en mode ralenti <img src='http://www.tomrochette.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Ceci déclare un nouvel objet Page. Pour que PHP puisse utiliser un objet, il faut que celui-ci existe. Donc, en faisant new Page(), on dit à PHP &#8220;SVP mon Dieu, crée une Page sans attributs&#8221;. PHP, notre Dieu, fait. $page = permet d&#8217;attribuer ce nouvel objet à une variable pour le manipuler par la suite.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Accueil'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Ici, on dit à notre objet, par l&#8217;intermédiaire de la flèche qui signifie que l&#8217;on descend dans la branche d&#8217;héritage, que l&#8217;on veut qu&#8217;il exécute sa méthode setTitle avec comme paramètre le texte Accueil. Cela aura pour effet de modifier la variable interne $title de notre objet pour &#8216;Accueil&#8217;.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setContent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Ceci est un contenu vraiment intéressant!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Comme précédemment, on demande à notre objet d&#8217;exécuter sa méthode setContent pour modifier sa variable $content cette fois-ci. On lui attribut le texte &#8216;Ceci est un contenu vraiment intéressant!&#8217;.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Finalement, on demande à notre magnifique objet d&#8217;exécuter sa méthode render(), sans argument, qui retourne ses deux attributs formatés pour afficher une page HTML.</p>
<p>On voit donc que la POO en PHP est très similaire à celle en C++ ou autre langage OO. C&#8217;est compréhensible &#8230; on emploi les mêmes termes pour désigner les mêmes choses, non?</p>
<p>En conclusion, avec ce bref introduction à l&#8217;OO, je serais en mesure de vous montrer des scripts qui pourront vous permettre de gagner soit du temps, ou encore d&#8217;avoir bien du plaisir à voir la puissance que vous avez entre les mains. Enfin, il suffit seulement de savoir ce que l&#8217;on veut faire et comment on va s&#8217;y prendre pour y arriver.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomrochette.com/programmer-en-objet-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>La programmation orientée objet</title>
		<link>http://www.tomrochette.com/la-programmation-orientee-objet/</link>
		<comments>http://www.tomrochette.com/la-programmation-orientee-objet/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 03:28:50 +0000</pubDate>
		<dc:creator>tomzx</dc:creator>
				<category><![CDATA[Programmation]]></category>

		<guid isPermaLink="false">http://www.tomrochette.com/?p=83</guid>
		<description><![CDATA[Qu&#8217;y a-t&#8217;il de plus beau que la programmation orientée objet? Rien. La programmation orientée objet (ou POO) est un chef d&#8217;oeuvre en soi. Pourquoi? Parce que sa simplicité et sa rigueur en font l&#8217;une des meilleures façons de concevoir un logiciel, que se soit à l&#8217;aide de PHP, de C++ ou de tout autre langage [...]]]></description>
			<content:encoded><![CDATA[<p>Qu&#8217;y a-t&#8217;il de plus beau que la programmation orientée objet? Rien.</p>
<p>La programmation orientée objet (ou POO) est un chef d&#8217;oeuvre en soi. Pourquoi? Parce que sa simplicité et sa rigueur en font l&#8217;une des meilleures façons de concevoir un logiciel, que se soit à l&#8217;aide de PHP, de C++ ou de tout autre langage orientée objet.</p>
<p>Mais qu&#8217;est-ce qu&#8217;ont les programmes orientés objets de si orgasmiques? Et bien, un ensemble de choses. Je ne ferais qu&#8217;en citer quelques-uns :<br />
La possibilité d&#8217;écrire des classes réutilisables dans d&#8217;autres projets.<br />
La possible de partager du code avec d&#8217;autres tout en ayant la capacité de retravailler sur son code sans affecter celui des autres.<br />
La possibilité d&#8217;avoir des variables internes qui ne peuvent être travaillées par des processus externes.<br />
La liste continue&#8230;</p>
<p>Bon, commençons donc avec les rudiments de la POO, en langage C++.</p>
<p>Qu&#8217;est-ce qu&#8217;un objet? Et bien, il s&#8217;agit d&#8217;une classe, ou d&#8217;un ensemble d&#8217;information à propos d&#8217;un concept. Par exemple, la classe voiture pourrait être définie comme suit :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> Voiture
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
		Voiture<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> position_x <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span>, position_y <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> avancer<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> distance<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> reculer<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> distance<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		pair<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span> , <span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> obtenirPosition<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span><span style="color: #008080;">;</span> 
&nbsp;
	<span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
		<span style="color: #0000ff;">int</span> position_x_<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">int</span> position_y_<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Qu&#8217;est-ce que c&#8217;est que ce beau tas de code? Et bien, il s&#8217;agit de la déclaration de la classe voiture! Eh oui, vous avez découvert votre première classe! Bon, il s&#8217;agit ici d&#8217;une classe bien banale qui permettra à votre objet Voiture de se déplacer vers l&#8217;avant et vers l&#8217;arrière. Elle gardera les positions en x et en y (bien que puisque la voiture se déplace actuellement seulement selon l&#8217;axe des x, la position y nous est inutile).</p>
<p>Maintenant, attaquons-nous au code qui fera en sorte qu&#8217;il y ait de l&#8217;action. Premièrement, il faut un constructeur, c&#8217;est-à-dire que tout objet Voiture doit être construit avant de pouvoir fonctionner.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">Voiture<span style="color: #008080;">::</span><span style="color: #007788;">Voiture</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> position_x, <span style="color: #0000ff;">int</span> position_y<span style="color: #008000;">&#41;</span>
<span style="color: #008080;">:</span> position_x_<span style="color: #008000;">&#40;</span>position_x<span style="color: #008000;">&#41;</span>, position_y_<span style="color: #008000;">&#40;</span>position_y<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Ici, on utilise le même nom que la classe pour déclarer ce constructeur. Vous noterez l&#8217;utilisation de : avant position_x_ et position_y_. Il s&#8217;agit d&#8217;une liste d&#8217;initialisation, c&#8217;est-à-dire que ces valeurs seront initialisées avec les valeurs dans les parenthèses. Pourquoi donc faire cela?</p>
<p>En C++, la création d&#8217;objet ce fait de cette façon : premièrement, on crée les attributs (les variables private), puis on appelle le constructeur qui se charge alors de construire l&#8217;objet. S&#8217;il arrivait qu&#8217;un objet A était inclus dans un autre objet B, cela aurait pour effet d&#8217;initialiser l&#8217;objet A avec des paramètres par défaut. Or, faire cela implique créer un objet avec des paramètres qu&#8217;on va changer quelques instants après, ce qui est une perte d&#8217;efficacité et une preuve de manque d&#8217;intelligence (vous ne voudriez pas paraître stupide non?).</p>
<p>Bon, avec ce constructeur, votre objet peut être créé. Mais rien de plus. Faisons à présent les deux fonctions de déplacement :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> avancer<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> distance<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	position_x_ <span style="color: #000040;">+</span><span style="color: #000080;">=</span> distance<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> reculer<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> distance<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	position_x_ <span style="color: #000040;">-</span><span style="color: #000080;">=</span> distance<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Code très simple. Ajoute ou enlève à la valeur de position_x_, un de nos attributs internes.</p>
<p>Finalement, il nous faut une fonction qui sera en mesure de nous donner notre position en x et en y!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">pair <span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span> , <span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> obtenirPosition<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">return</span> make_pair<span style="color: #008000;">&#40;</span>position_x_, position_y_<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Avec ça, vous pouvez déjà faire une Voiture, la faire avancer et reculer et même obtenir sa position! Wow, vous avez presque le début d&#8217;un jeu de course entre les mains! À vous de repousser les limites maintenant.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomrochette.com/la-programmation-orientee-objet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

