<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>oop &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/oop/</link>
	<description>Feed of posts on WordPress.com tagged "oop"</description>
	<pubDate>Sat, 19 Jul 2008 23:52:21 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Mitos de la programación - ¿OOP? II]]></title>
<link>http://mundogris.wordpress.com/?p=135</link>
<pubDate>Sat, 19 Jul 2008 16:53:31 +0000</pubDate>
<dc:creator>elhombregris</dc:creator>
<guid>http://mundogris.wordpress.com/?p=135</guid>
<description><![CDATA[Siguiendo con el post anterior. Esto me recuerda uno de los mitos más difíciles de desterrar de la]]></description>
<content:encoded><![CDATA[<p>Siguiendo con el post anterior. Esto me recuerda uno de los mitos más difíciles de desterrar de la programación orientada a objetos, y uno de los más polémicos. En general un buen diseño en objetos te asegura un buen grado de reusabilidad, pero no es una garantía. Decir que trabajar con objetos te asegura la reusabilidad es una exageración, una falacia. No alcanza con usar programación orientada a objetos para hacer tu código reusable, y tampoco un lenguaje que no provee features del OOP está menos predispuesto a la reusabilidad solo por el hecho de no soportar OOP.</p>
<p>Por ahí acá resulta medio contradictorio lo que digo, siendo que es inevitable para mi hablar de reusabilidad cuando hablo del paradigma de objetos. En parte esto es porque no considero como un uso apropiado del paradigma aquello que no busque una buena reusabilidad de los algoritmos creados. Sin embargo hay que evitar enseñar a los que introducen en este paradigma que la reusabilidad se obtiene sin costo alguno. En particular hay que evitar dar a entender la reusabilidad como una característica del OOP. Se puede hacer tanto código reusable como pasta-code en OOP como en paradigma procedural o en el paradigma funcional.</p>
<p>En pocas palabras, la reusabilidad no es una característica del OOP, no hay garantías de ello prácticamente en ningún paradigma. PERO, diseñar a partir de simular los procesos reales (característico de OOP), sumado a un cuidado diseño orientado a la reusabilidad, generalmente concluyen en un sistema fácilmente mantenible.</p>
<p>En el foro de ADVA tuvimos con algunos usuarios una discusión bastante acalorada sobre el lenguaje C++ y en general sobre ciertos aspectos del paradigma de objetos. Uno de los temas tocados fue sobre la reusabilidad. Quiero extraer algunos fragmentos de esta discusión. Por ejemplo <a href="http://www.adva.com.ar/foro/index.php?topic=4514.msg26979#msg26979">acá comento sobre la crítica academica al OOP en temas de reusabilidad y la propuesta del GoF y los patrones de diseño</a>:</p>
<blockquote><p>Algo en lo que insisto siempre es en destronar el mito del OOP como facilitador de la reusabilidad. Usar OOP no garantiza reusabilidad, por el contrario, una de las críticas académicas más fuertes al OOP es que la reusabilidad por herencia resulta en malas prácticas que afecta la mantenibilidad (esa palabra es un trabalenguas) del sistema. En contraposición, el paradigma procedural tiene un modelo de reusabilidad mucho más organizado, que genera una mayor independencia entre componentes.</p>
<p>Sobre esto, el "Grupo de los Cuatro" (Gang of Four) popularizo los términos de "white-box reuse" (reusabilidad a caja abierta) y "black-box reuse" (reusabilidad a caja cerrada). La reusabilidad a caja abierta, o reusabilidad por herencia, es la que es criticada por generar dependencias entre los componentes a la hora de hacer tareas de mantenimiento. La reusabilidad a caja cerrada, o reusabilidad por interfases, es la usada en el paradigma procedural y la que el GoF propone recuperar en el paradigma OO mediante patrones de diseño.</p></blockquote>
<p>Ahí tengo que admitir que elegí mal las palabras. Puntualmente el OOP, bien usado, puede resultar un facilitador de la reusabilidad. El punto importante es que la reusabilidad no es una garantía, en ningún paradigma de la programación. En particular es una crítica académica que el OOP favorece practicas incorrectas de reusabilidad, pero esto está originado en el mismo ámbito académico que enseña mal el paradigma de objetos.</p>
<p><a href="http://www.adva.com.ar/foro/index.php?topic=4514.msg27067#msg27067">Acá hay otro extracto de esa discusión donde observo los comentarios de Stroustrup sobre el lenguaje C++ y el paradigma de objetos</a>:</p>
<blockquote><p>Me tome el tiempo de releer los capítulos iniciales del libro de Stroustrup. En ningún momento plantea el paradigma de objetos como una mejora a la reusabilidad, lo cual era de esperarse, sería una promesa ridícula. En el prefacio habla del OOP como una técnica de abstracción de datos más "flexible y eficiente", lo cual es cierto. Dice "Cuando se les utiliza bien, estas técnicas producen programas más cortos y más fáciles de comprender y mantener". Esto último es en general cierto con el paradigma de objetos. El punto clave es el "buen uso". Después habla del type safety sobre todo.</p>
<p>En el primer capítulo hace una reseña filosófica sobre el lenguaje, donde dice que el lenguaje C está pensado como un "lenguaje cercano a la máquina", y los agregados que se hicieron en C++ son para hacer un "lenguaje cercano al problema a resolver". Hace una reseña bastante interesante que quiero compartir:</p>
<p>"El lenguaje proporciona al programador un conjunto de herramientas conceptuales; si éstas resultan inadecuadas para una tarea, sencillamente se las ignorara. (...) No se puede garantizar el buen diseño y la ausencia de errores sólo por la presencia o ausencia de características específicas del lenguaje."</p></blockquote>
<p>Es rescatable esto último que dice Stroustrup, y sobre como la intención de C++ es acercar al programador al problema a resolver, esto es en realidad cierto no solo para C++ sino para el paradigma de objetos en general.</p>
<p>Continuo más adelante sobre el tema para no alargar innecesariamente el post.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Mitos de la programación - ¿orientado a objetos?]]></title>
<link>http://mundogris.wordpress.com/?p=132</link>
<pubDate>Fri, 18 Jul 2008 19:10:06 +0000</pubDate>
<dc:creator>elhombregris</dc:creator>
<guid>http://mundogris.wordpress.com/?p=132</guid>
<description><![CDATA[Esto me dejo pensando.
Mas allá del charlatanerio, hay mucho que se dice sobre la programación ori]]></description>
<content:encoded><![CDATA[<p><a href="http://phpsenior.blogspot.com/2008/07/internet-est-lleno-de-charlatanes.html">Esto me dejo pensando.</a></p>
<p>Mas allá del charlatanerio, hay mucho que se dice sobre la programación orientada a objetos, que realmente no lo es. Cosas como esta superan la norma:</p>
<blockquote><p>La persistencia es uno de las caracteristicas del POO.</p></blockquote>
<p>La programación orientada a objetos es solo UNO de los tantos paradigmas para el modelado de algoritmos, y la persistencia NO es una de sus características.</p>
<p>Sus características son:</p>
<ol>
<li>La abstracción orientada a la simulación de los procesos reales.</li>
<li>La encapsulación de los actores (objetos/entidades que participan del algoritmo), o sea, la distinción entre interfase y funcionamiento interno.</li>
<li>La herencia y el polimorfismo, o sea, la organización taxonómica de los actores y su capacidad de actuar como cualquiera de los tipos que la herencia le permita.</li>
</ol>
<p>Eso es todo. Cualquier otra cosa que se diga del POO es hablar demás.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Vezető PHP fejlesztő]]></title>
<link>http://spillerlaszlo.wordpress.com/?p=234</link>
<pubDate>Thu, 17 Jul 2008 12:53:28 +0000</pubDate>
<dc:creator>Spiller László</dc:creator>
<guid>http://spillerlaszlo.wordpress.com/?p=234</guid>
<description><![CDATA[Média területen piacvezető multinacionális cégcsoporthoz keresünk munkatársakat Web 2.0 és k]]></description>
<content:encoded><![CDATA[<p>Média területen piacvezető multinacionális cégcsoporthoz keresünk munkatársakat Web 2.0 és közösségi portál témájú projektekhez. A cégcsoport több olyan oldalt is üzemeltet, melyek a világ leglátogatottabb 100 weboldala, illetve Magyarország leglátogatottabb 10 weboldala között szerepelnek. Az új fejlesztések mind a tartalom, mind pedig az alkalmazott technológiák alapján szintén a világ élvonalába tartoznak. Komoly, tőkeerős háttér biztosítja a nyugodt munkát, a kiemelt bérezést és a szakmai fejlődést.</p>
<p>A Feladat:</p>
<ul>
<li>PHP alapú nemzetközi portálrendszerek fejlesztése egy professzionális csapatban</li>
<li>Meglévő rendszerek továbbfejlesztése, illetve kreatív új ötletek kidolgozása<br />
 </li>
</ul>
<p>Szakmai elvárások:</p>
<ul>
<li>Min. 3+ év fejlesztési tapasztalat</li>
<li>Magas fokú PHP (5) ismeretek</li>
<li>Erős és alapos SQL ismeretek (MySQL 5.x)</li>
<li>Objektum Orientált programozási háttér (Java vagy C++) vagy OOP teljes körű ismerete</li>
<li>Javascript és Javascript könyvtárakban szerzett tapasztalat (jQuery, prototype, ExtJS)</li>
<li>SVN vagy CVS tapasztalat</li>
<li>Nyílt forráskódú technológiák az alapos ismerete (PHP, MySQL, memcache)</li>
<li>CSS és HTML részletes ismerete</li>
<li>Kiváló csapatjátékos, specifikáció alapján önálló, koncentrált munkavégzés</li>
<li>Junior fejlesztők munkájának koordinálása</li>
<li>Jó szóbeli és írásbeli kommunikációs készség</li>
<li>Megbízható, megfontolt személyiség</li>
<li>Szakmai angol szöveg megértése<br />
 </li>
</ul>
<p>Előnyt jelent:</p>
<ul>
<li>Szakirányú végzettség, szakmai képzések</li>
<li>PHP-s keretrendszer vagy keretrendszerek használatában szerzet tapasztalat</li>
<li>Szoftverfejlesztésben szerzett tapasztalat (UML nem követelmény, de előny)</li>
<li>Szakmai cikkek olvasása, szakmai tudás önállóan történő szinten tartása, fejlesztése<br />
 </li>
</ul>
<p>Amit kínálunk:</p>
<ul>
<li>A legmodernebb technológiák használata</li>
<li>Fiatal, dinamikus csapat</li>
<li>Szakmai támogatás és tudásbázis a munkavégzéshez</li>
<li>Folyamatos fejlődés, kihívások</li>
<li>Nemzetközi karrierlehetőség</li>
<li>Kiemelkedő bérezés: Tapasztalattól és szakmai tudástól függően.</li>
<li>Cafeteria rendszer, céges tréningek, szakmai utak<br />
 </li>
</ul>
<p>Munkaidő, helyszÍn:</p>
<ul>
<li>Modern, jól felszerelt iroda Budapest központjában</li>
<li>Napi fix, nyolc órás munkaidő</li>
</ul>
<p><a href="mailto:laszlo_spiller@kellyservices.hu">laszlo_spiller@kellyservices.hu</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Flash programozó]]></title>
<link>http://spillerlaszlo.wordpress.com/?p=227</link>
<pubDate>Thu, 17 Jul 2008 12:33:55 +0000</pubDate>
<dc:creator>Spiller László</dc:creator>
<guid>http://spillerlaszlo.wordpress.com/?p=227</guid>
<description><![CDATA[Média területen piacvezető multinacionális cégcsoporthoz keresünk munkatársakat Web 2.0 és k]]></description>
<content:encoded><![CDATA[<p>Média területen piacvezető multinacionális cégcsoporthoz keresünk munkatársakat Web 2.0 és közösségi portál témájú projektekhez. A cégcsoport több olyan oldalt is üzemeltet, melyek a világ leglátogatottabb 100 weboldala, illetve Magyarország leglátogatottabb 10 weboldala között szerepelnek. Az új fejlesztések mind a tartalom, mind pedig az alkalmazott technológiák alapján szintén a világ élvonalába tartoznak. Komoly, tőkeerős háttér biztosítja a nyugodt munkát, a kiemelt bérezést és a szakmai fejlődést.</p>
<p>Feladatok:</p>
<ul>
<li>Flash Media server, Flash appletek programozása<br />
 </li>
</ul>
<p>Szakmai elvárások:</p>
<ul>
<li>Flash action script (esetleg Java vagy C++) nyelv ismerete</li>
<li>Több éves programozási, szakmai tapasztalat</li>
<li>Objektum-orientált szemléletmód<br />
 </li>
</ul>
<p>Amit kínálunk:</p>
<ul>
<li>Kiemelkedő bérezés</li>
<li>Fiatal, dinamikus, ugyanakkor professzionális csapat</li>
<li>Szakmai támogatás és tudásbázis a munkavégzéshez</li>
<li>Folyamatos fejlődés, kihívások</li>
<li>Nemzetközi karrierlehetőség</li>
<li>Cafeteria rendszer<br />
 </li>
</ul>
<p>Munkaidő, helyszín:</p>
<ul>
<li>Modern, jól felszerelt iroda Budapest központjában</li>
<li>Napi fix, nyolc órás munkaidő</li>
</ul>
<p><a href="mailto:laszlo_spiller@kellyservices.hu">laszlo_spiller@kellyservices.hu</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[JUNIOR PHP FEJLESZTŐ]]></title>
<link>http://spillerlaszlo.wordpress.com/?p=218</link>
<pubDate>Thu, 17 Jul 2008 11:56:24 +0000</pubDate>
<dc:creator>Spiller László</dc:creator>
<guid>http://spillerlaszlo.wordpress.com/?p=218</guid>
<description><![CDATA[Média területen piacvezető multinacionális cégcsoporthoz keresünk munkatársakat Web 2.0 és k]]></description>
<content:encoded><![CDATA[<p>Média területen piacvezető multinacionális cégcsoporthoz keresünk munkatársakat Web 2.0 és közösségi portál témájú projektekhez. A cégcsoport több olyan oldalt is üzemeltet, melyek a világ leglátogatottabb 100 weboldala, illetve Magyarország leglátogatottabb 10 weboldala között szerepelnek. Az új fejlesztések mind a tartalom, mind pedig az alkalmazott technológiák alapján szintén a világ élvonalába tartoznak. Komoly, tőkeerős háttér biztosítja a nyugodt munkát, a kiemelt bérezést és a szakmai fejlődést.</p>
<p>Feladatok:</p>
<ul>
<li>Nagy látogatottságú, PHP alapú portálrendszerek, illetve közösségi oldalak fejlesztése egy professzionális csapat tagjaként</li>
</ul>
<p>Szakmai elvárások:</p>
<ul>
<li>Szakirányú felsőfokú végzettség</li>
<li>PHP tapasztalat</li>
<li>Objektum-orientált fejlesztésbeli jártasság</li>
<li>SQL ismeretek</li>
<li>Szakmai angol szöveg megértése</li>
<li>A feladattal, illetve a munkával kapcsolatban érzett szenvedély és igényesség</li>
<li>Új technológiák megtanulására való hajlandóság <br />
 </li>
</ul>
<p>Előnyt jelent:</p>
<ul>
<li>MySQL ismerete</li>
<li>CSS és HTML ismerete</li>
<li>JavaScript ismeretek, ezen belül kiemelten JQuery, illetve ExtJS használatában szerzett tapasztalat</li>
<li>Verziókezelő rendszer ismerete (CVS, SVN)<br />
 </li>
</ul>
<p>Amit kínálunk:</p>
<ul>
<li>Kiemelkedő bérezés</li>
<li>Fiatal, dinamikus, ugyanakkor professzionális csapat</li>
<li>Szakmai támogatás és tudásbázis a munkavégzéshez</li>
<li>Folyamatos fejlődés, kihívások</li>
<li>Nemzetközi karrierlehetőség</li>
<li>Cafeteria rendszer<br />
 </li>
</ul>
<p>Munkaidő, helyszín:</p>
<ul>
<li>Modern, jól felszerelt irodánk Budapest központjában található</li>
<li>Napi fix, nyolc órás munkaidő</li>
</ul>
<p><a href="mailto:laszlo_spiller@kellyservices.hu">laszlo_spiller@kellyservices.hu</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C++ és Python programozók]]></title>
<link>http://spillerlaszlo.wordpress.com/?p=210</link>
<pubDate>Thu, 17 Jul 2008 11:43:21 +0000</pubDate>
<dc:creator>Spiller László</dc:creator>
<guid>http://spillerlaszlo.wordpress.com/?p=210</guid>
<description><![CDATA[Média területen piacvezető multinacionális cégcsoporthoz keresünk munkatársakat Web 2.0 és k]]></description>
<content:encoded><![CDATA[<p>Média területen piacvezető multinacionális cégcsoporthoz keresünk munkatársakat Web 2.0 és közösségi portál témájú projektekhez. A cégcsoport több olyan oldalt is üzemeltet, melyek a világ leglátogatottabb 100 weboldala, illetve Magyarország leglátogatottabb 10 weboldala között szerepelnek. Az új fejlesztések mind a tartalom, mind pedig az alkalmazott technológiák alapján szintén a világ élvonalába tartoznak. Komoly, tőkeerős háttér biztosítja a nyugodt munkát, a kiemelt bérezést és a szakmai fejlődést.</p>
<p>A feladat:</p>
<ul>
<li>Nagy terhelésű, elosztott rendszerek kiszolgálását végző alkalmazások fejlesztése</li>
<li>Erőforrás-hatékony alkalmazások fejlesztése</li>
<li>Fejlesztett eszközök tesztelése</li>
<li>Fejlesztések folyamatos dokumentálása</li>
<li>Már meglévő alkalmazások refaktorizálása</li>
</ul>
<p>Szakmai elvárások:</p>
<ul>
<li>Komoly OOP és OOD ismeretek, algoritmikus szemléletmód</li>
<li>UML tervezési ismeretek</li>
<li>Hálózat-programozási ismeretek</li>
<li>Min. 2 éves szakmai tapasztalat</li>
<li>Szoftverfejlesztési módszertanok és kódolási standardok követése</li>
<li>Erős háttér Unix/Linux rendszerekre való fejlesztésben</li>
</ul>
<p>Amit kínálunk:</p>
<ul>
<li>A legmodernebb technológiák használata</li>
<li>Fiatal, dinamikus csapat</li>
<li>Szakmai támogatás és tudásbázis a munkavégzéshez</li>
<li>Folyamatos fejlődés, kihívások</li>
<li>Nemzetközi karrierlehetőség</li>
<li>Kiemelkedő bérezés: Tapasztalattól és szakmai tudástól függően.</li>
<li>Cafeteria rendszer, céges tréningek, szakmai utak</li>
</ul>
<p>Munkaidő, helyszín:</p>
<ul>
<li>Modern, jól felszerelt iroda Budapest központjában</li>
<li>Napi fix, nyolc órás munkaidő</li>
</ul>
<p><a href="mailto:laszlo_spiller@kellyservices.hu">laszlo_spiller@kellyservices.hu</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C++ growing pains]]></title>
<link>http://scaryreasoner.wordpress.com/?p=90</link>
<pubDate>Thu, 17 Jul 2008 02:08:14 +0000</pubDate>
<dc:creator>scaryreasoner</dc:creator>
<guid>http://scaryreasoner.wordpress.com/?p=90</guid>
<description><![CDATA[Still mucking about with C++ at work.  Here&#8217;s some of the stuff that bothers me lately.
Header]]></description>
<content:encoded><![CDATA[<p>Still mucking about with C++ at work.  Here's some of the stuff that bothers me lately.</p>
<p>Header file hell.  Much like DLL hell on windows, or RPM hell (before yum), header file hell is, I suspect, quite common in C++, and is one of the main reasons it's not my favorite language.</p>
<p>Typically, with C++, as you try to solve whatever problem you're trying to solve (means: get the computer to do some useful work) you are kind of forced to do a bunch of "extra" work, figuring out how to frame the problem in terms of objects and classes, not really that big a deal.  But, C++ being, (or trying to be) a strongly typed language, encourages the use of custom enumerated types (over #defines, say),  That means, if you want classes to communicate with each other without converting from, say, ints to these enums, both classes have to include the header file that defines these enumerated types.  Which means there's a good chance the typedef for the enumeration cannot reside in the header definition file for <em>either</em> class, at least not without putting some thought into it, and moving things around a bit.  Why?  Because, lets say <em>both</em> (of a mere two) classes define some custom enumeration types, and each class needs to communicate with the other in some way using those types.  In that case, if each class includes the header file of the other, and the header file contains guard #ifdefs to prevent being included twice.  Well, if there is a circular dependency, things get a bit sticky and non-obvious.  You've got to sort it out in one of a number of ways.  The easiest way is probably to take these types and separate them out into their own headers.  Fine.  But look at the time it takes to sort all this out.  In C, the params would have been ints, everybody automatically knows what an int is, and #defines would do the job pretty effortlessly, albeit with less compiler meddling to make sure you're doin' it right.</p>
<p>So, anyway, when I left work today, I was in that particular corner of header file hell, from which I will have to extricate myself tomorrow.</p>
<p>There are other corners of header file hell.  Suppose you want to try to reuse some C++ code. If you are very lucky, the code will have been designed to be reused, and designed to have been reused in just the manner you're wanting to reuse it.  More likely, the code isn't quite so well designed.  Instead, it is within a class which is designed such that it fits in well with whatever application it's embedded in.  This embedding entails references to all sorts of other classes in the application, types, etc.  As you try to extricate the code you're interested in for reuse, you find yourself dragging along more and more header files and classes in an ever expanding network, until, in an epiphany, you realize that this approach will lead you to suck in the entire application eventually.  At that point, you start cutting and pasting bits, and reworking the code to fit into your problem space.</p>
<p>Well, that's the bigger of the nuisances I've been facing.  There are some smalelr ones as well.<br />
whoDecidedThatIdentifiersLikeThisAreEasyToRead?  WasItSomeGermanGuy?  iHearGermansTendToBuildCompoundWordsInThisWay. ByWhichIMeanCapitializingWordsButOtherwiseJustCrammingThemTogether.  VeryReadableDon'tYouThink?  </p>
<p>Why do C++ people like identifiers like that?  Are they retarded? Brainwashed?  I mean, English sentences, in general, consist mostly of uncapitalized words separated by spaces.  That is the most readable way of writing text, and that's what you will find in <em>every</em> instance of fiction, newspaper journalism, magazines, etc., (except possibly some very esoteric and pathological exceptions which are deviating only to make some weird point. )  The closest approximation to this for C or C++ identifiers is lowercase words separated by underscores (as spaces are not an option.)<br />
I_mean_like_this.  This_is_far_more_readable_than_the_insane_cramming_method.</p>
<p>So, why, oh why, are C++ programmers so fond of this crazy way of naming variables and functions?  I have no idea.</p>
<p>Another nit.  I have become used to the linux kernel way of formatting code in the last 6 or 8 years or so.  This way of formatting code involves indenting code with tabs, not spaces.  And tabs indicate and indent of 8 spaces, not 4, not 3, not 2.  When I started on this project, I asked around, "hey, are there any coding conventions, style guidlines, etc., that I should be following?  By default, I'm apt to write code formatted like what you'd see in the linux kernel, is that ok?"  "Sure, we're not religious about that," I was told.  Hmm.  Well, today, I get a call.  "Hey, I noticed you're using tabs."  "yeah.... is that ok?"  "well, we'd prefer not."   Oooookay.  Could've told me that earlier.  The problem with this is, my editor of choice is vi.  Vi, by default, is very tab friendly, provided you agree that a tab means an 8 space indent.  It has various commands that know that (e.g. "&#60;&#60;" will move a line over by one tabstop, "10&#62;&#62;" will move ten lines right by one tab stop, etc.  These things are habits that are hardwired into my fingers by now.</p>
<p>Anyway, I converted all my C++ files to use 3 spaces in place of every tab.  And, I found (via <a href="http://www.outflux.net/blog/archives/2007/03/09/detecting-space-vs-tab-indentation-type-in-vim/">codeblog</a> that I can add some stuff to the end of the file like this:</p>
<pre>
// Local Variables:
// c-basic-offset: 3
// indent-tabs-mode: nil
// End:
//
// vim: et sts=3 sw=3
</pre>
<p>The above teaches vim that, around these parts, there is no such thing as a tab, when you think "tab", put 3 spaces.  It even makes "&#60;&#60;" and "&#62;&#62;" work as well.  So I'm glad to have found that.  I don't have to retrain my fingers.  (I couldn't retrain my fingers anyway, as there's plenty of code I still have to work on that adheres to the "no spaces, only tabs" doctrine, so I'm doubly happy that I found a solution that automatically (once implemented) limits its application to only those files which need it, and leaves default behavior alone.)</p>
<p>I had another idea today, while thinking about the C++ identifiers and using capital letters vs. lowercase, and underscores (or not.)  It occurred to me that both the underscores and the capital letters require one to use the shift key, which is, although easily learned, an inefficient and overly strenuous finger move, given how frequently it must be executed.  I started thinking about those keyboards with the split space bar they had for awhile, the ones where half the space bar was made into a backspace key.  Evidently that didn't go over too well, as I don't recall having seen those around lately, but they were around for about a year... maybe that was 2 years ago?  I can't remember.  Anyway, it occurs to me that if you could get one of those keyboards, and, for whichever thumb you don't normally use for space (I tend to use my right thumb exclusively for space, so for me, the left half of the space bar is unused), dedicate that to the underscore.  This way, C style identifiers could be typed in very nearly the normal fashion, just use the "wrong" thumb to hit the space bar...  Brilliant idea, no?</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[The Importance of Buiding Your Own PHP Framework!]]></title>
<link>http://clintonskakun.wordpress.com/?p=85</link>
<pubDate>Fri, 11 Jul 2008 15:00:14 +0000</pubDate>
<dc:creator>clintonskakun</dc:creator>
<guid>http://clintonskakun.wordpress.com/?p=85</guid>
<description><![CDATA[Theres a ton of PHP frameworks out there that will do what you want and will get the job done. But d]]></description>
<content:encoded><![CDATA[<p>Theres a ton of PHP frameworks out there that will do what you want and will get the job done. But do you really need all of these features? So is there a reason why you should build your own framework?</p>
<p><em>First of all</em>, how big is your project? How many projects do you work on? How much functionally are you looking for?</p>
<p><em>Second of all</em>, do you have enough time and knowledge to build your own framework?</p>
<p>The first step is listing a few features that you need:</p>
<ul>
<li>Basic XHTML document generation with the ability to add HTML titles, CSS, JavaScript, Icons etc.</li>
<li>A global template(or multiple templates) that can changed from page to page or stay static throughout the whole site.</li>
<li>Simple content placement, pages(determined by the URI)-would be loaded into the template.</li>
<li>Quick database access.</li>
<li>Data Sensitization.</li>
</ul>
<p>...and go from there.</p>
<p>I like using OOP(Object Orientated Programming) for my framework because it makes things so much easier.</p>
<p>It's only as complicated as you make it. Just integrate the features that you need, keep it secure and keep tweaking it until it meets up to your personal standards.</p>
<p>The things that you should look for in any framework before it's used in public:</p>
<ul>
<li>Freedom and flexibility</li>
<li>Quality and performance</li>
<li>Security</li>
</ul>
<p>The ultimate goal for your framework should be to save time as well as to give yourself a little extra freedom. All you need to do is write up a plan and start coding:)</p>
<p>Oh, and you might find this site helpful from time to time: <a href="http://php.net">PHP.NET</a></p>
<p>Have Fun!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Turning the page -- PHP, Symfony, ORM]]></title>
<link>http://justinleider.wordpress.com/?p=3</link>
<pubDate>Fri, 18 Jul 2008 18:23:42 +0000</pubDate>
<dc:creator>Justin Leider</dc:creator>
<guid>http://justinleider.wordpress.com/?p=3</guid>
<description><![CDATA[I have come to the conclusion that I should be cataloging my work, thoughts, theories and activities]]></description>
<content:encoded><![CDATA[<p>I have come to the conclusion that I should be cataloging my work, thoughts, theories and activities for others to read and learn from my experiences as a web engineer. Let me begin by mentioning I work at a company called <a title="CitySquares Online" href="http://citysquares.com" target="_blank">CitySquares</a> and for the last year I have been working diligently on the current CitySquares site.</p>
<p>This has been a great year for me as I was given the opportunity to learn the inner workings of the Drupal CMS. While <a title="Drupal CMS" href="http://drupal.org" target="_blank">Drupal</a> is a great CMS/Framework, it is inherently still a prepackaged CMS designed for things that 99% of the community needs. CitySquares unfortunately falls within that other 1%. I must say that we have accomplished quite a bit using Drupal's community modules in conjunction with our own custom written ones. However, there are plans in the works that we would like to implement but just cant within the Drupal framework.</p>
<p>Although all is not lost. With the current iteration running and stable and gaining traffic every week I have the opportunity to turn the page and begin work on the next phase of development. This is an exciting time and I will use this medium to convey the successes as well as the issues as development here continues.</p>
<p>That said, we have decided to scrap our Drupal based architecture in favor of a more extensible framework, <a title="Symfony Framework" href="http://www.symfony-project.org" target="_blank">Symfony</a>. Symfony is a PHP based OO architecture that resembles Ruby on Rails. Not only will we gain the benefit of switching to a OO style framework but we will be using Doctrine as our ORM and Smarty as our template engine.</p>
<p>The idea is that this combination of technologies will help us alleviate two of the major problems we have  with Drupal, essentially scalability and codability. Ive been toying with some ideas to help eliminate these two thorns in our side that I will discuss at a later time but look forward to hearing my ideas on a full stack horizontal architecture.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Kroger Purchase *07/17/2008*]]></title>
<link>http://gamethesystem.wordpress.com/?p=135</link>
<pubDate>Fri, 18 Jul 2008 04:17:23 +0000</pubDate>
<dc:creator>Game The System!</dc:creator>
<guid>http://gamethesystem.wordpress.com/?p=135</guid>
<description><![CDATA[Tonight was a great night at Kroger, I got a few things I needed and a lot of things I can put back ]]></description>
<content:encoded><![CDATA[<p>Tonight was a great night at Kroger, I got a few things I needed and a lot of things I can put back for when I need them. This is a perfect example of making the coupons work for you! I paid for my 1 year Sunday paper only subscription in just this one transaction.  Next week I'll pay for another subscription (that I do not have), and the next week the another one and on and on it goes. I've been able to maximize my savings by getting duplicate coupon inserts from the Sunday paper. <em>(Thanks to my mamaw and my mother in law)</em> .</p>
<p>I've started realizing I'm a coupon-a-holic, at night I dream about coupons and scenarios - I wake up exhausted because my mind has been crunching numbers all night long. However, when my plan follows through with an amazing savings I realize it's all worth it. I love the intoxicating feeling it gives! This week I had a savings of 82.36 %, now that's what I call success in Game The System!</p>
<p><a href="http://gamethesystem.files.wordpress.com/2008/07/071420081.jpg"><img class="aligncenter size-full wp-image-138" src="http://gamethesystem.wordpress.com/files/2008/07/071420081.jpg" alt="" width="400" height="238" /></a><a href="http://gamethesystem.files.wordpress.com/2008/07/071420082.jpg"></a></p>
<p><strong>Purchases:</strong></p>
<table border="0" cellspacing="0" cellpadding="1">
<tbody>
<tr>
<td width="400">
<ul>
<li>4 Bounty Basic Paper Towels @$1.00 ea.</li>
<li>2 Post Just Bunches Cearal@ @$2.00 ea.</li>
<li>2 Duncan Hines Brownie Mix @ $1.00 ea.</li>
<li>2 Carnation Instant Breakfast @$4.89 ea.</li>
<li>1 French's Mustard @ $1.00 ea.</li>
<li>3 Kroger Instant Chocolate Pudding @$0.50 ea.</li>
<li>1 Top Sirlion Steak @ $3.33</li>
<li>1 Chuck Loin Steak @ $2.51</li>
<li>3 Satin Care Shave Gel @ $2.39</li>
<li>2 Pantene ProV Conditioners @ $3.34</li>
<li>1 Pantene ProV Shampoo @ $3.34</li>
<li>3 Secret Deodorant @ $2.39</li>
<li>3 Herbal Essence Shampoo @ $2.50</li>
<li>3 Herbal Essence Conditioner @ $2.50</li>
</ul>
</td>
<td width="100" align="right">$4.00<br />
$5.00<br />
$2.00<br />
$9.78<br />
$1.00<br />
$1.50<br />
$3.33<br />
$2.51<br />
$7.17<br />
$6.68<br />
$3.34<br />
$7.17<br />
$7.50<br />
$7.50 </td>
</tr>
<tr>
<td>
<ul>
<li><strong>Pre-Savings Total:</strong></li>
</ul>
</td>
<td align="right" valign="top"><strong>$68.48</strong></td>
</tr>
</tbody>
</table>
<p><strong>Savings:</strong></p>
<table border="0" cellspacing="0" cellpadding="1">
<tbody>
<tr>
<td width="400">
<ul>
<li>4 MC's Bounty Paper Towels @$0.25 ea. (Tripled)</li>
<li>1 ECoupon Bounty Paper Towels @$0.50</li>
<li>2 <a href="http://www.kraftfoods.com/honeybunchesofoats" target="blank">IP Coupons Just Bunches Cearal</a> @$2.00</li>
<li>1 <a href="http://ivillage.coupons.smartsource.com/WEB/index.aspx?Link=RR2RBUAIFX62U" target="blank">IP Coupon Duncan Hines Brownie Mix</a> @$0.50/2 (Doubled)</li>
<li>1 <a href="http://homesolutionsnews.us/offers.shtml" target="blank">IP Coupon French's Mustard</a> @$0.50 ea. (Doubled)</li>
<li>1 <a href="http://homesolutionsnews.us/offers.shtml" target="blank">IP Coupon Carnation Instant Breakfast</a> @$2.00 ea,</li>
<li>1 SC Coupon Carnation Instant Breakfast @$1.25 ea.</li>
<li>3 MC's Pantene ProV Shampoo Or Conditioner @$2.00 ea.</li>
<li>1 MC Secret Deodorant @$1.00 ea.</li>
<li>2 MC Secret Deodorant @$0.50 ea. (Doubled)</li>
<li>3 MC's Satin Care Shavel Gel @$0.55</li>
<li>3 MC's Herbal Essencee Shampoo Or Conditioner @$3.00/2 ea.</li>
<li>1 Catalina from previous purchases @$4.00</li>
<li>1 Kroger Coupon @$3.00/$15.00 Beauty Product</li>
<li>1 Kroger Coupon @$2.00/$10.00 Beauty Product</li>
<li>5 P&#38;G Kroger Promotion @$3.00 ea.</li>
</ul>
</td>
<td width="100" align="right">
<ul>-$3.00<br />
-$0.50<br />
-$4.00<br />
-$1.00<br />
-$1.00<br />
-$2.00<br />
-$1.25<br />
-$6.00<br />
-$1.00<br />
-$2.00<br />
-$1.65<br />
-$9.00<br />
-$4.00<br />
-$3.00<br />
-$2.00<br />
-$15.00</ul>
</td>
</tr>
<tr>
<td width="400">
<ul>
<li><strong>Total Savings:<strong></strong></strong></li>
</ul>
</td>
<td width="100" align="right" valign="top">
<ul><strong>-$56.40</strong></ul>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><strong>Out-of-Pocket Expense (OOP) (tax included):</strong></td>
<td align="right" valign="top"><strong>$13.05</strong></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><strong>Catalina for future Use:</strong></td>
<td align="right" valign="top"><strong>$0.00</strong></td>
</tr>
</tbody>
</table>
<p> </p>
<p>Also, <a href="http://www.kroger.com/Pages/default.aspx" target="blank">Kroger</a> has ecoupons that you can load to your <a href="http://www.kroger.com/Pages/default.aspx" target="blank">Kroger</a> Plus Card, they allow you to use the ecoupons for your purchase along with MC's. Three different companies offer these coupons, go <a href="http://www.softcoin.com/Sites/Unilever_MakingLifeBetter/Page/HomePage/" target="blank">here</a>, <a href="http://www.softcoin.com/Sites/PG_eSAVER/Page/HomePage/" target="blank">here</a>, and <a href="http://www.shortcuts.com/" target="blank">here</a> to start loading your ecoupons today!</p>
<p><strong>-</strong>Game The System!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[What is OOP?]]></title>
<link>http://menardparas.wordpress.com/?p=5</link>
<pubDate>Fri, 18 Jul 2008 03:29:31 +0000</pubDate>
<dc:creator>menardparas</dc:creator>
<guid>http://menardparas.wordpress.com/?p=5</guid>
<description><![CDATA[Object-oriented programming (OOP) is a programming paradigm that uses &#8220;objects&#8221; and thei]]></description>
<content:encoded><![CDATA[<p>Object-oriented programming (OOP) is a <a title="Programming paradigm" href="http://en.wikipedia.org/wiki/Programming_paradigm">programming paradigm</a> that uses "<a title="Object (computer science)" href="http://en.wikipedia.org/wiki/Object_%28computer_science%29">objects</a>" and their interactions to design applications and computer programs. Programming techniques may include features such as <a title="Information hiding" href="http://en.wikipedia.org/wiki/Information_hiding">encapsulation</a>, <a class="mw-redirect" title="Module (programming)" href="http://en.wikipedia.org/wiki/Module_%28programming%29">modularity</a>, <a title="Polymorphism in object-oriented programming" href="http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming">polymorphism</a>, and <a title="Inheritance (computer science)" href="http://en.wikipedia.org/wiki/Inheritance_%28computer_science%29">inheritance</a>. It was not commonly used in mainstream software application development until the early 1990s. Many modern <a title="Programming language" href="http://en.wikipedia.org/wiki/Programming_language">programming languages</a> now support OOP.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C# .NET Generics: Method Overriding]]></title>
<link>http://shiman.wordpress.com/?p=101</link>
<pubDate>Thu, 17 Jul 2008 04:13:40 +0000</pubDate>
<dc:creator>shiman</dc:creator>
<guid>http://shiman.wordpress.com/?p=101</guid>
<description><![CDATA[Methods that have a type parameter can be overridden, regardless of where the type parameter is decl]]></description>
<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Methods that have a type parameter can be overridden, regardless of where the type parameter is declared. These methods can also override other methods. The Table lists the various combinations of overriding generic and nongeneric methods. If a base class is nongeneric or closed, overriding methods cannot have type parameters. Conversely, if the base class is open, overriding methods can employ type parameters.</span></p>
<table class="MsoNormalTable" border="1" cellpadding="0">
<thead>
<tr>
<td style="background-color:transparent;border:#f0f0f0;padding:0.75pt;" colspan="3">
<p class="MsoNormal" style="margin:0 0 10pt;"><a name="592"></a><a name="ch06table02"></a><span style="font-size:small;"><span style="font-family:Calibri;"><span class="table-titlelabel">Table : </span><span class="table-title">Combination of Overriding Generic Methods</span> <span style="font-size:12pt;line-height:115%;"></span></span></span></p>
</td>
</tr>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><strong><span style="font-size:small;"><span style="font-family:Calibri;">Base Method </span></span></strong></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><strong><span style="font-size:small;"><span style="font-family:Calibri;">Derived Method </span></span></strong></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><strong><span style="font-size:small;"><span style="font-family:Calibri;">Comments </span></span></strong></p>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Nongeneric</span></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (open)</span></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Permitted</span></p>
</td>
</tr>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Nongeneric</span></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (closed)</span></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Permitted</span></p>
</td>
</tr>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (open)</span></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Nongeneric</span></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Not permitted</span></p>
</td>
</tr>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (open)</span></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (open)</span></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Permitted; must use the same type parameters</span></p>
</td>
</tr>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (open)</span></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (closed)</span></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Not permitted</span></p>
</td>
</tr>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (closed)</span></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Nongeneric</span></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Permitted</span></p>
</td>
</tr>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (closed)</span></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (closed)</span></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Permitted</span></p>
</td>
</tr>
<tr>
<td style="width:1.5in;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="144" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (closed)</span></p>
</td>
<td style="width:102pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="136" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic (open)</span></p>
</td>
<td style="width:194.8pt;background-color:transparent;border:#f0f0f0;padding:0.75pt;" width="260" valign="top">
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Not permitted</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Here is some example code:</span></p>
<table class="MsoTableGrid" style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.65in;background-color:transparent;border:black 1pt solid;padding:0 5.4pt;" width="638" valign="top">
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:Consolas;">namespace</span><span style="font-size:10pt;font-family:Consolas;"> Examples.Generics</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Program</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> Main()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">ZClass</span>&#60;T&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:blue;">public</span> <span style="color:blue;">virtual</span> <span style="color:blue;">void</span> MethodA(T arg)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">YClass</span>&#60;T&#62; : <span style="color:#2b91af;">ZClass</span>&#60;T&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:blue;">public</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> MethodA(T arg)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:green;">//public override void MethodA(int arg)</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:green;">//{ [ illegal ]</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:green;">//}</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">XClass</span>&#60;X&#62; : <span style="color:#2b91af;">ZClass</span>&#60;<span style="color:blue;">int</span>&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>       </span><span> </span><span style="color:blue;">public</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> MethodA(<span style="color:blue;">int</span> arg)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:green;">//public override void MethodA(X arg) </span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:green;">//{ [ illegal ]</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:green;">//}</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">WClass</span> : <span style="color:#2b91af;">ZClass</span>&#60;<span style="color:blue;">int</span>&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:blue;">public</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> MethodA(<span style="color:blue;">int</span> arg)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>       </span><span> </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;"> </span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">When a generic method overrides another generic method, it inherits the constraints of that method. The overriding method cannot change the inherited constraints.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">The following code correctly overrides a generic method:</span></p>
<table class="MsoTableGrid" style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.65in;background-color:transparent;border:black 1pt solid;padding:0 5.4pt;" width="638" valign="top">
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:blue;">class</span> <span style="color:#2b91af;">ZClass</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">virtual</span> <span style="color:blue;">void</span> MethodA&#60;T&#62;(T arg)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:blue;">where</span> T : <span style="color:blue;">new</span>()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:blue;">class</span> <span style="color:#2b91af;">YClass</span> : <span style="color:#2b91af;">ZClass</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> MethodA&#60;T&#62;(T arg)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>T obj = <span style="color:blue;">new</span> T();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&#34;"><span style="font-size:small;"> </span></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Five Tips for Effective Object-oriented Programming in C++]]></title>
<link>http://farrahsottos.wordpress.com/?p=8</link>
<pubDate>Wed, 16 Jul 2008 06:35:10 +0000</pubDate>
<dc:creator>farrahsottos</dc:creator>
<guid>http://farrahsottos.wordpress.com/?p=8</guid>
<description><![CDATA[Spurgeon’s Law says that 90% of everything is crap.  This sure holds genuine in the concern of cip]]></description>
<content:encoded><![CDATA[<p>Spurgeon’s Law says that 90% of everything is crap.  This sure holds genuine in the concern of cipher development, and especially when it comes to object-orientation and C++ programming.  This is mostly cod to the pervasiveness and complexness of C++; it’s digit of the most commonly utilised object-oriented languages, and ease some grouping undergo how to ingest it effectively.  Couple this with the fact that some programmers genuinely apprehension the object-oriented planning belief and you hit an fast instruction for sloppy code. Volumes crapper be—and hit been—written on how to amend comely object-oriented cipher designs using C++.  Obviously, there won’t be expanse in this article for a genuinely complete discussion; however, I would same to inform a some quick, ultimate and trenchant tips for nonindustrial burly C++ software.</p>
<p>1. Work on the collection designs prototypal before determining on the fine ordering of operations.  Many programmers flamboyant themselves as doing object-oriented programming, but in reality, they ingest organic planning with some outside object-oriented trappings.  Ideally, digit should prototypal superior a ordered of cipher objects that wage a formal conception of the software, then impact on the ordering of operations.  (This is by no effectuation an unconditional conception though, as the impact of nonindustrial this ordering ofttimes reveals structure in which the goal organisation crapper be refined.)</p>
<p>2.  Think in cost of organisation patterns.  Design patterns earmark someone to entertainer on eld of problem-solving undergo within the machine power community.  Instead of reinventing the wheel, ground not meet garner digit soured the shelf?</p>
<p>3.  Use ‘const’ objects and ‘const’ functions whenever possible.  If you undergo that an object’s accumulation is never questionable to be modified, then tell the goal to be ‘const’.  This module preclude you—or worse, a na๏ve colleague--from unexpectedly modifying its land after on.  Of course, digit should also tell the pertinent member functions to be ‘const’ as well, to right oblige this rule.</p>
<p>4.  Avoid using open ‘get’ and ‘set’ member functions.  Getters and setters are not inherently bad; however, they are ofttimes a clew of slummy cipher abstraction.  ‘Get’ and ‘set’ functions implicitly obligate the individual to conceive in cost of the object’s interior accumulation (i.e. some these functions are effort or setting), and such info should ideally be unseeable from the object’s user.  Getters and setters hit their place, but gratify ingest them sparingly.</p>
<p>5.  Avoid threefold indirection.  C programmers are unnatural to impact with pointers, and so they are utilised to having pointers to pointers throughout their code.  This crapper ofttimes advance to unclear code, cod to the all-too-familiar problems of NULL references and indicator arithmetic.  In contrast, C++ programmers are low no such constraints, cod to the built-in hold for uncertain references in C++; that is, digit crapper ever ingest references to pointers instead, which makes the cipher such easier to understand.  (Hint:  If a C++ technologist uses threefold indirection, that’s a country clew that he’s ease intellection same an fledgling C hack!)</p>
</p>
<p>About the author:</p>
<p>V. B. Velasco Jr., Ph.D. has worked as an electrical and cipher organise for more than a decade.  He currently entireness for a biotech concern that provides cryopreserved PBMCs, ELISPOT analyzers and ELISPOT expertise.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C# .NET Generics: Casting]]></title>
<link>http://shiman.wordpress.com/?p=91</link>
<pubDate>Wed, 16 Jul 2008 04:44:37 +0000</pubDate>
<dc:creator>shiman</dc:creator>
<guid>http://shiman.wordpress.com/?p=91</guid>
<description><![CDATA[You may need to a cast a generic type. Since generic types are implicit System.Object types, they ca]]></description>
<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">You may need to a cast a generic type. Since generic types are implicit <em>System.Object</em> types, they can always be cast to that type. In addition, generic types can be cast to the derivation constraint, which is also a type. The derivation constraint assures that the generic type is a descendant of the constraint. This assures a safe cast. Finally, generics can be cast to any interface even if the interface is not included in an interface constraint. Since there is no restriction on casting to interfaces, it is not type-safe. For that reason, care should be taken to cast to an implemented interface.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">In the following code, <em>ZClass</em> is a generic type. It has a single type parameter (<em>T</em>) that has three constraints: <em>YClass</em> type derivation, <em>IA</em> interface derivation, and the constructor constraint. An instance of the <em>T</em> parameter is created in the method called <em>Cast</em>. The instance is then cast in succession to the <em>YClass</em>, <em>IA</em>, and <em>IB</em> interface. The first two casts work as expected. The third cast fails spectacularly. The type parameter is not related to <em>IB</em>. However, the compiler does not notice. Therefore, an exception is raised at run time, which is the worst possible time and underscores the type-unsafe nature of interface cast of generic types.</span><a name="587"></a><a name="IDX-257"></a></p>
<table class="MsoTableGrid" style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.65in;background-color:transparent;border:windowtext 1pt solid;padding:0 5.4pt;" width="638" valign="top">
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:blue;">class</span> <span style="color:#2b91af;">ZClass</span>&#60;T&#62; <span style="color:blue;">where</span> T : <span style="color:#2b91af;">YClass</span>, <span style="color:#2b91af;">IA</span>, <span style="color:blue;">new</span>()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">static</span> <span style="color:blue;">public</span> <span style="color:blue;">void</span> Cast()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>T obj = <span style="color:blue;">new</span> T();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>((<span style="color:#2b91af;">YClass</span>)obj).MethodA();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>((<span style="color:#2b91af;">IA</span>)obj).MethodA();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>((<span style="color:#2b91af;">IB</span>)obj).MethodB(); <span style="color:green;">// Error</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:blue;">class</span> <span style="color:#2b91af;">YClass</span> : <span style="color:#2b91af;">IA</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">void</span> MethodA()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>Console.WriteLine(<span style="color:#a31515;">"YClass.MethodA"</span>);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:Consolas;">interface</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#2b91af;">IA</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{ </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">void</span> MethodA();</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:blue;font-family:Consolas;">interface</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#2b91af;">IB</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:blue;">void</span> MethodB();</span></p>
<p class="para" style="margin:auto 0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Generic type parameters cannot be assigned a null or zero. There is no assurance that a type parameter is either a reference or value type, which prevents safely assigning a null or zero value to a type parameter. However, you can test a type parameter against null but not zero. If the comparison succeeds, the type parameter is a reference type. Otherwise, the type parameter is a value type.</span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C# .NET Generics: Inheritance]]></title>
<link>http://shiman.wordpress.com/?p=89</link>
<pubDate>Tue, 15 Jul 2008 11:27:26 +0000</pubDate>
<dc:creator>shiman</dc:creator>
<guid>http://shiman.wordpress.com/?p=89</guid>
<description><![CDATA[Generic and nongeneric classes can inherit a generic type. In addition, a generic type can be the ba]]></description>
<content:encoded><![CDATA[<p class="first-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic and nongeneric classes can inherit a generic type. In addition, a generic type can be the base class to a generic or nongeneric type. Some basic rules apply. For example, the derived class cannot be a closed constructed type. The Table<span>  </span>lists all the possible permutations.</span></p>
<table class="MsoNormalTable" style="border:windowtext 1pt solid;" border="1" cellpadding="0">
<thead>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" colspan="3">
<p class="MsoNormal" style="text-align:center;margin:0 0 10pt;" align="center"><a name="589"></a><a name="ch06table01"></a><span style="font-size:small;"><span style="font-family:Calibri;"><span class="table-titlelabel">Table: </span><span class="table-title">Inheritance Table for Generic Types</span> </span></span></p>
</td>
</tr>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><strong><span style="font-size:small;"><span style="font-family:Times New Roman;">Base Class </span></span></strong></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><strong><span style="font-size:small;"><span style="font-family:Times New Roman;">Derived Class </span></span></strong></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><strong><span style="font-size:small;"><span style="font-family:Times New Roman;">Comments </span></span></strong></p>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (open)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (open)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Permitted when the derived class consumes the type parameters of the base class</span></p>
</td>
</tr>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (open)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (closed)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Not permitted</span></p>
</td>
</tr>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (open)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Nongeneric</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Permitted</span></p>
</td>
</tr>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (closed)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (open)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Permitted</span></p>
</td>
</tr>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (closed)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (closed)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Not permitted</span></p>
</td>
</tr>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (closed)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Nongeneric</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Not permitted</span></p>
</td>
</tr>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Nongeneric</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (closed)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Permitted</span></p>
</td>
</tr>
<tr>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Nongeneric</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Generic (open)</span></p>
</td>
<td style="background-color:transparent;border:windowtext 1pt solid;padding:0.75pt;" valign="top">
<p class="table-para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Not permitted</span></p>
</td>
</tr>
</tbody>
</table>
<p class="para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">This sample code shows some of the permitted and not permitted combinations:</span></p>
<table class="MsoTableGrid" style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.65in;background-color:transparent;border:windowtext 1pt solid;padding:0 5.4pt;" width="638" valign="top">
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">ZClass</span>&#60;T&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">XClass</span>&#60;T&#62; : <span style="color:#2b91af;">ZClass</span>&#60;T&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">BClass</span>&#60;Y&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">AClass</span>&#60;Z&#62; : <span style="color:#2b91af;">BClass</span>&#60;<span style="color:#0000ff;">int</span>&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">YClass</span> : <span style="color:#2b91af;">ZClass</span>&#60;<span style="color:#0000ff;">int</span>&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;">/*</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;">public class AClass&#60;Z&#62; : BClass&#60;Y&#62; </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;">{<span>    </span>[ illegal ]</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;">public class YClass: ZClass&#60;T&#62;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;">{<span>        </span>[ illegal ]</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#008000;font-family:Consolas;">*/</span></p>
</td>
</tr>
</tbody>
</table>
<p class="para" style="margin:auto 0;"><span><span style="font-size:small;font-family:Times New Roman;"> </span></span><a name="590"></a><a name="IDX-258"></a><span style="font-size:small;font-family:Times New Roman;">When inheriting an open constructed type, the constraints of the base class must be repeated in the derived type. Furthermore, the derived type can provide additional constraints on type parameters declared at the base type. This is not applicable to closed constructed types because closed constructed types do not have type parameters or constraints.</span></p>
<p class="para" style="margin:auto 0;"><span style="font-size:small;font-family:Times New Roman;">Here is sample code combining inheritance of generic types and constraints:</span></p>
<table class="MsoTableGrid" style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.65in;background-color:transparent;border:windowtext 1pt solid;padding:0 5.4pt;" width="638" valign="top">
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">ZClass</span>&#60;T&#62; <span style="color:#0000ff;">where</span> T : IComparable</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">YClass</span>&#60;T&#62; : <span style="color:#2b91af;">ZClass</span>&#60;T&#62; <span style="color:#0000ff;">where</span> T : IComparable</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">XClass</span>&#60;T&#62; : <span style="color:#2b91af;">ZClass</span>&#60;T&#62; <span style="color:#0000ff;">where</span> T : IComparable, IDisposable</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">BClass</span>&#60;Y&#62; <span style="color:#0000ff;">where</span> Y : IEnumerable</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">public</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">AClass</span>&#60;Z&#62; : <span style="color:#2b91af;">BClass</span>&#60;<span style="color:#0000ff;">int</span>[]&#62; <span style="color:#0000ff;">where</span> Z : IDisposable</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-family:&#34;"><span style="font-size:small;"> </span></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Reducing server load - caching in PHP]]></title>
<link>http://iphptips.wordpress.com/?p=3</link>
<pubDate>Tue, 15 Jul 2008 08:56:53 +0000</pubDate>
<dc:creator>modotourneys</dc:creator>
<guid>http://iphptips.wordpress.com/?p=3</guid>
<description><![CDATA[As the web bacame more complex the need for dynamic web sites increased dramatically. Dynamic pages ]]></description>
<content:encoded><![CDATA[<p>As the web bacame more complex the need for dynamic web sites increased dramatically. Dynamic pages take generally more time to process than static ones. Imagine a page displaying some date stored in database. The server needs to load up the data, process them and then display the html output for every visitor.  Database is updated maybe every hour. In that case we do not need to generate the whole page again for every visitor. We just need to update it every hour because loading and processing can take significant amount of server time. This is where the caching magic comes to the rescue.</p>
<p>As we surely use the newer version of PHP and want to make our applications cool we'll make it the OOP way. Let's start with writing a simple class to handle our caching. Basically we just want to store information about the directory where to put cached files, amount of time to keep them cached and the actual content of the cache. Our class could look like this:</p>
<p>[sourcecode language="php"]</p>
<p><?php</p>
<p>require_once('ACacheException.php');<br />
require_once('AIOException.php');<br />
class ACache<br />
{</p>
<p>	private $strDirectory;</p>
<p>	private $intCacheTime;</p>
<p>	private $strContent = '';</p>
<p>	public function __construct( $strDirectory, $intCacheTime )<br />
	{</p>
<p>		$this->setDirectory( $strDirectory );<br />
		$this->setCacheTime( $intCacheTime );</p>
<p>	}</p>
<p>	public function setDirectory( $strValue )<br />
	{</p>
<p>		if( is_dir( $strValue ) )<br />
		{</p>
<p>			$this->strDirectory = $strValue;</p>
<p>		}<br />
		else<br />
		{</p>
<p>			throw new AIOException( 'Not a valid directory: '.$strDirectory );</p>
<p>		}</p>
<p>	}</p>
<p>	public function getDirectory()<br />
	{</p>
<p>		return $this->strDirectory;</p>
<p>	}</p>
<p>	public function setCacheTime( $intValue )<br />
	{</p>
<p>		$this->intCacheTime = intval( $intValue );</p>
<p>	}</p>
<p>	public function getCacheTime()<br />
	{</p>
<p>		return $this->intCacheTime;</p>
<p>	}</p>
<p>	public function startCaching()<br />
	{</p>
<p>		ob_start();</p>
<p>	}</p>
<p>	public function stopCaching()<br />
	{</p>
<p>		$this->strContent = ob_get_contents();</p>
<p>		ob_end_clean();</p>
<p>	}</p>
<p>	public function getCachedContent()<br />
	{</p>
<p>		return $this->strContent;</p>
<p>	}</p>
<p>	public function saveCache( $strFilename )<br />
	{</p>
<p>		$strFullFilePath = $this->getDirectory().$strFilename;</p>
<p>		$fp = fopen( $strFullFilePath, 'w+' );</p>
<p>		if( $fp )<br />
		{</p>
<p>			fwrite( $fp, $this->strContent );</p>
<p>			fclose( $fp );</p>
<p>		}<br />
		else<br />
		{</p>
<p>			throw new AIOException( 'Could not open file for writing: '.<br />
                            $strFullFilePath );</p>
<p>		}</p>
<p>	}</p>
<p>	public function getCache( $strFilename )<br />
	{</p>
<p>		$strFullFilePath = $this->getDirectory().$strFilename;</p>
<p>		if( file_exists( $strFullFilePath ) &&<br />
                    filemtime( $strFullFilePath ) > time() - $this->getCacheTime() )<br />
		{</p>
<p>			return file_get_contents( $strFullFilePath );</p>
<p>		}<br />
		else<br />
		{</p>
<p>			throw new ACacheException( 'File '.$strFullFilePath.<br />
                              ' does not exists or is older than '.<br />
                              $this->getCacheTime().' seconds' );</p>
<p>		}</p>
<p>	}</p>
<p>}</p>
<p>?></p>
<p>[/sourcecode]</p>
<p>That was the code, now I will try to explain it a bit. The two "Exception" files included just contain definitions of blank classes extending the Exception class. It's just for us to be able to catch those and know what has actually happened. Then there is a constructor and some setters and getters. Then there are the methods that actually "do something".</p>
<p><strong>startCaching()</strong> - starts to cache the output.  Using the <a title="ob_start()" href="http://us.php.net/ob_start" target="_blank">ob_start()</a> function we actually turn on the buffer output. This means that everything after it will not be displayed but will be just stored in the buffer.</p>
<p><strong>stopCaching()</strong> - yep, you guessed it. We store the contents of the buffer in local variable using <a title="ob_get_contents()" href="http://us.php.net/manual/en/function.ob-get-contents.php" target="_blank">ob_get_contents()</a> and then delete the buffer by calling <a title="ob_end_clean()" href="http://us.php.net/manual/en/function.ob-end-clean.php">ob_end_clean()</a>.</p>
<p><strong>saveCache( $strFilename )</strong> - we would like to save our cached output to a file so we can load it when the next request occurs. The method just tries to create the file and write the data into it.</p>
<p><strong>getCache( $strFilename )</strong> - the method looks for the cached file. When found and the file is not older than our caching time specifies the content is returned.</p>
<p>Simple, isn't it. The very simple example of using this class could look like this:</p>
<p>[sourcecode language="php"]</p>
<p><?php</p>
<p>require_once( 'classes/ACache.php' );</p>
<p>// set up the cache directory and keep files cached for 10 seconds<br />
$cache = new ACache( 'cache/', 10 );</p>
<p>try<br />
{</p>
<p>    $content = $cache->getCache( 'index.html' );</p>
<p>}<br />
catch ( ACacheException $e )<br />
{</p>
<p>    $cache->startCaching();</p>
<p>    echo 'Doing some costy operations in time'.time();</p>
<p>    $cache->stopCaching();</p>
<p>    $cache->saveCache( 'index.html' );</p>
<p>    $content = $cache->getCachedContent();</p>
<p>}</p>
<p>echo $content;</p>
<p>?></p>
<p>[/sourcecode]</p>
<p>And that's it. Of course you don't need to cache just html output, images or any other files can be cached the same way. That's all folks, until next time.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Generic Constraints in C# .NET: Default Constructor Constraint]]></title>
<link>http://shiman.wordpress.com/?p=88</link>
<pubDate>Sun, 13 Jul 2008 18:15:21 +0000</pubDate>
<dc:creator>shiman</dc:creator>
<guid>http://shiman.wordpress.com/?p=88</guid>
<description><![CDATA[Will this code compile? It looks fairly innocuous:




class ZClass&lt;T&gt;
{
    public void Me]]></description>
<content:encoded><![CDATA[<p>Will this code compile? It looks fairly innocuous:</p>
<table class="MsoTableGrid" style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.15in;background-color:transparent;border:windowtext 1pt solid;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">class</span><span style="font-size:10pt;font-family:Consolas;"> <span style="color:#2b91af;">ZClass</span>&#60;T&#62;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> MethodA()</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>T obj = <span style="color:#0000ff;">new</span> T();</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span>}</span></span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="para" style="margin:auto 0;">This code does not compile. The problem is the default constructor. Although prevalent, not every type has a default constructor. A default constructor, or a constructor with no arguments, assigns a default state to an object. The default constructor is called with a parameterless new operator. However, because a default constructor is not guaranteed, the new operator is not universally applicable. Therefore, the new operator is disallowed on type parameters.</p>
<p>The solution is the constructor constraint. The derivation constraint does not help with constructors because derived types do not inherit constructors for the base class. Constructor constraints mandate that a type parameter have a default constructor, which is confirmed at compile time. This allows the new operator to be used with the type parameter. The constructor constraint is added to the <em>where</em> clause and is a new operator. When combined with other constraints, the default constructor constraint must be the last item in the constraint list. The constructor constraint applies only to the default constructor. You are still prevented from using constructors with arguments.</p>
<p>Here is sample code of the constructor constraint. The constructor constraint is used on the <em>ZClass</em>.</p>
<table class="MsoTableGrid" style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.15in;background-color:transparent;border:windowtext 1pt solid;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">namespace</span><span style="font-size:10pt;font-family:Consolas;"> Examples.Generics</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">Program</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Main()</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#2b91af;">ZClass</span> obj = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">ZClass</span>();</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>obj.MethodA&#60;<span style="color:#2b91af;">XClass</span>&#62;();</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">ZClass</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> MethodA&#60;T&#62;()</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                     </span><span style="color:#0000ff;">where</span> T : <span style="color:#2b91af;">XClass</span>, <span style="color:#0000ff;">new</span>()</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"ZClass.MethodA"</span>);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>T obj = <span style="color:#0000ff;">new</span> T();</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>obj.MethodB();</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span> </span><span>   </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">XClass</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> MethodB()</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"XClass.MethodB"</span>);</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="para" style="margin:auto 0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Generic Constraints in C# .NET: Reference Type Constraint]]></title>
<link>http://shiman.wordpress.com/?p=87</link>
<pubDate>Sun, 13 Jul 2008 18:03:02 +0000</pubDate>
<dc:creator>shiman</dc:creator>
<guid>http://shiman.wordpress.com/?p=87</guid>
<description><![CDATA[A reference type constraint restricts a type parameter to a reference type. Reference types are gene]]></description>
<content:encoded><![CDATA[<p>A reference type constraint restricts a type parameter to a reference type. Reference types are generally user-defined types, including classes, interfaces, delegates, and array types. A reference type constraint uses the <em>class</em> keyword.</p>
<p>The following code has a reference type constraint. Although this code is similar to the code presented in the previous post, a reference type constraint is used instead of a value type constraint. For this reason, the illegal line has moved. You cannot use an integer type with a reference type parameter.</p>
<table class="MsoTableGrid" style="border-right:medium none;border-top:medium none;border-left:medium none;border-bottom:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.15in;background-color:transparent;border:windowtext 1pt solid;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System.Collections;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">namespace</span><span style="font-size:10pt;font-family:Consolas;"> Examples.Generics</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">Program</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Main()</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#008000;">// ZClass&#60;int&#62; obj1=new ZClass&#60;int&#62;(); [illegal]</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#2b91af;">ZClass</span>&#60;<span style="color:#2b91af;">XClass</span>&#62; obj2 = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">ZClass</span>&#60;<span style="color:#2b91af;">XClass</span>&#62;();</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">ZClass</span>&#60;T&#62; <span style="color:#0000ff;">where</span> T : <span style="color:#0000ff;">class</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Iterate(T data)</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">XClass</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin:0;"><span style="font-size:small;font-family:Times New Roman;"> </span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Generic Constraints in C# .NET: Value Type Constraint]]></title>
<link>http://shiman.wordpress.com/?p=85</link>
<pubDate>Sun, 13 Jul 2008 17:27:31 +0000</pubDate>
<dc:creator>shiman</dc:creator>
<guid>http://shiman.wordpress.com/?p=85</guid>
<description><![CDATA[A value type constraint restricts a type parameter to a value type. Value types are derived from the]]></description>
<content:encoded><![CDATA[<p style="margin:0;">A value type constraint restricts a type parameter to a value type. Value types are derived from the <em>System.ValueType</em> type. Primitives and structures are examples of value types. The exception is the <em>Nullable</em> type. The <em>Nullable</em> type is a value type, but it is not allowed with a value type constraint. A value type constraint is a constraint using the <em>struct</em> keyword.</p>
<p style="margin:0;">The following code demonstrates the value type constraint. The commented source line uses a reference type, which would cause compile errors because of the value type constraint.</p>
<table class="MsoTableGrid" style="border-right:medium none;border-top:medium none;border-left:medium none;border-bottom:medium none;border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.15in;background-color:transparent;border:windowtext 1pt solid;padding:0 5.4pt;" width="590" valign="top">
<p class="MsoNormal" style="margin:0;"><a name="582"></a><a name="ch06lev2sec8"></a><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System.Collections;</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">namespace</span><span style="font-size:10pt;font-family:Consolas;"> Examples.Generics</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">Program</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Main()</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#2b91af;">ZClass</span>&#60;<span style="color:#0000ff;">int</span>&#62; obj1 = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">ZClass</span>&#60;<span style="color:#0000ff;">int</span>&#62;();</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#008000;">// ZClass&#60;XClass&#62; obj2=new ZClass&#60;XClass&#62;(); [illegal]</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">ZClass</span>&#60;T&#62; <span style="color:#0000ff;">where</span> T : <span style="color:#0000ff;">struct</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Iterate(T data)</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">XClass</span></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Consolas;">}</span></p>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Design Pattern in PHP]]></title>
<link>http://aaronthegeek.wordpress.com/?p=7</link>
<pubDate>Sun, 13 Jul 2008 15:44:55 +0000</pubDate>
<dc:creator>aaronthegeek</dc:creator>
<guid>http://aaronthegeek.wordpress.com/?p=7</guid>
<description><![CDATA[今天接手同事 Paulo 的接子 BD，才發現原來 OOP 可以這樣子寫的。基本上整個 ]]></description>
<content:encoded><![CDATA[<p>今天接手同事 Paulo 的接子 BD，才發現原來 OOP 可以這樣子寫的。基本上整個 BD admin 就是物件的集合，從 user view 到 database ，可以分為表現層、邏輯層和資料層。</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[PHP5 和從前的 PHP 是不同的]]></title>
<link>http://aaronthegeek.wordpress.com/?p=5</link>
<pubDate>Sun, 13 Jul 2008 15:36:47 +0000</pubDate>
<dc:creator>aaronthegeek</dc:creator>
<guid>http://aaronthegeek.wordpress.com/?p=5</guid>
<description><![CDATA[不要以為 PHP 簡單易上手便不用學習。當 PHP 變得越來越相近 Java ，便知道其]]></description>
<content:encoded><![CDATA[<p>不要以為 PHP 簡單易上手便不用學習。當 PHP 變得越來越相近 Java ，便知道其實 PHP5 和 PHP4 是兩個很不同的東西——不是在語法上不同（PHP4 和 PHP5 的語法是相同的。），而是「心法上」的不同。</p>
<p>!! PHP5</p>
<ul>
<li>http://blog.roodo.com/jaceju/archives/3517185.html</li>
<li>http://blog.roodo.com/jaceju/archives/5781987.html</li>
<li>http://blog.roodo.com/jaceju/archives/3549457.html</li>
<li>http://www.php.net/manual/en/language.oop5.php</li>
</ul>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Generic Constraints in C# .NET: Interface Constraints]]></title>
<link>http://shiman.wordpress.com/?p=84</link>
<pubDate>Sun, 13 Jul 2008 09:57:48 +0000</pubDate>
<dc:creator>shiman</dc:creator>
<guid>http://shiman.wordpress.com/?p=84</guid>
<description><![CDATA[Interfaces can also be constraints, which require that the type argument implement the interface. Al]]></description>
<content:encoded><![CDATA[<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Interfaces can also be constraints, which require that the type argument implement the interface. Although a type parameter can have at most one derivation constraint, it can have multiple interface constraints. This is logical because a class can inherit a single base class but can implement many interfaces. The syntax for an interface constraint is identical to a derivation constraint. Class and interface constraints can be combined in a list of constraints. However, a class constraint should precede interface constraints in the list.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">Interface and derivation constraints share many of the same rules and restrictions, such as the visibility of the interface constraint exceeding that of the type parameter.</span></p>
<p class="MsoNormal" style="margin:0 0 10pt;"><span style="font-size:small;font-family:Calibri;">In the following code, the find capability has been added to the <em>Sheet</em> collection. The <em>Find</em> method returns an array of cells that contain a certain value. A comparison is made between the cell and value, where both are the type indicated in the type argument. Types that implement the <em>IComparable</em> interface support comparisons. If a comparison is equal, <em>IComparable</em> <em>.CompareTo</em> returns 0. To support this behavior, an interface constraint for <em>IComparable</em> is added to the type parameter. This is a partial implementation of the <em>Sheet</em> collection that shows <em>Find</em> and related methods. (Some of the code shown previously is omitted.)</span></p>
<table class="MsoTableGrid" style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:6.65in;background-color:transparent;border:black 1pt solid;padding:0 5.4pt;" width="638" valign="top">
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;color:#0000ff;font-family:Consolas;">namespace</span><span style="font-size:10pt;font-family:Consolas;"> Examples.Generics</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;">{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">Starter</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Main()</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#2b91af;">Sheet</span>&#60;<span style="color:#0000ff;">int</span>&#62; asheet = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Sheet</span>&#60;<span style="color:#0000ff;">int</span>&#62;(5);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">byte</span> row = 1; row &#60; 6; ++row)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span><span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">byte</span> col = 1; col &#60; 6; ++col)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                    </span>asheet[row, col] = row * col;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#2b91af;">Cell</span>[] found = asheet.Find(6);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#0000ff;">foreach</span> (<span style="color:#2b91af;">Cell</span> answer <span style="color:#0000ff;">in</span> found)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"> </span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span><span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"R{0} C{1}"</span>,</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                    </span>answer.row, answer.col);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">struct</span> <span style="color:#2b91af;">Cell</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">byte</span> row;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">byte</span> col;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> <span style="color:#2b91af;">Sheet</span>&#60;T&#62; <span style="color:#0000ff;">where</span> T : <span style="color:#2b91af;">IComparable</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#008000;">//…</span></span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#2b91af;">Cell</span>[] Find(T searchValue)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#0000ff;">int</span> total = Count(searchValue);</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#0000ff;">int</span> counter = 0;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#2b91af;">Cell</span>[] cells = <span style="color:#0000ff;">new</span> <span style="color:#2b91af;">Cell</span>[total];</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">byte</span> row = 1; row &#60;= m_Dimension; ++row)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span><span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">byte</span> col = 1; col &#60;= m_Dimension; ++col)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                    </span><span style="color:#0000ff;">if</span> (m_Sheet[row - 1, col - 1].CompareTo(searchValue) == 0)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                    </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                        </span>cells[counter].row = row;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                        </span>cells[counter].col = col;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                        </span>++counter;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                    </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#0000ff;">return</span> cells;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>}</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> Count(T searchValue)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>        </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#0000ff;">int</span> counter = 0;</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span><span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">byte</span> row = 1; row &#60;= m_Dimension; ++row)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>            </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span><span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">byte</span> col = 1; col &#60;= m_Dimension; ++col)</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                </span>{</span></p>
<p class="MsoNormal" style="line-height:normal;margin:0;"><span style="font-size:10pt;font-family:Consolas;"><span>                    </span><span style="color:#0000ff;">i