<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5140708481885520713</id><updated>2012-01-30T05:54:44.783-05:00</updated><title type='text'>The Daily Module</title><subtitle type='html'>News, code, articles, rants; a daily dose of programming rigmarole.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-7058439375409217700</id><published>2008-10-07T21:14:00.005-05:00</published><updated>2008-10-10T16:00:42.474-05:00</updated><title type='text'>Typed DataSets versus Domain Model</title><content type='html'>Recently I worked on a project that used typed DataSets as a domain model. Because of my experiences on the project, I decided to post about the usage of typed DataSets for domain modeling. I personally didn't have much experience with typed DataSets since I always preferred classic domain modeling using good OO principles and user-defined types, so this was a nice new task.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Initial Thoughts&lt;/strong&gt;&lt;br /&gt;When I started on the project, my first task was to create a WCF persistence service. This persistence service would interact directly with two typed DataSets in the way of classic CRUD.&lt;br /&gt;&lt;br /&gt;My initial thoughts were the use of typed DataSets were pretty nice. It was quite easy to populate them from a resultset retrieved from a SQL Server database. The built-in support within the ADO.NET API was nice. Built-in support for simple data validation (not allow DBNull and such) was nice. Overall, my first impression was that typed DataSets are nice to work with, almost fun.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Reality Set In&lt;/strong&gt;&lt;br /&gt;Those thoughts quickly waned. What I started to find is that typed DataSets allowed inconsistent behavior when using them; for example, you can set a column's AllowDbNull property to false but then set its default value to DBNull.&lt;br /&gt;&lt;br /&gt;Continuing on, I discovered other problems that I consider serious. One is a very simple modeling issue: multiplicity. Simply stated, you cannot enforce a 1:1 relationship between two tables in a dataset. More accurately stated, you cannot control the multiplicity of relationships. That is, if you're modeling automobiles, and you have a Car table, you cannot enforce that the Engine table only has one record; by nature in relational models, a foreign key is 1:M, and with typed DataSets, this is no different. With classic domain modeling, this is of course trivial. There are also problems with aggregation, composition and generalization with typed DataSets as well; this will be discussed later.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Good Does Exist&lt;/strong&gt;&lt;br /&gt;There are some good things about typed DataSets that you get with using them. For one you get free ORM, which in my book is huge (restated, you don't have to do ORM since you can use built-in ADO.NET, and phrased yet another way which is that you only have two choices for ORM: manual property setting and DataAdapter.Fill). Another nicety is Visual Studio will automatically generate strongly-typed query methods on a DataTable for keyed columns when using the DataSet designer, such as GetCarByID().&lt;br /&gt;&lt;br /&gt;Another nicety is a DataSet's built-in support for databinding. One concern with using classic domain modeling is the fact that you have to build in data binding support. What I've done to overcome this is create reusable base classes that implement the required interfaces (such as INotifyPropertyChanged), support for undo/redo, and use BindingList for binding entities to a DataGridView, however data binding with domain models is largely a manual (and sometimes complex) effort. However my experience has been that the trade off is worth it from an architectural quality standpoint.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Typed DataSets vs Domain Modeling: Which to Use?&lt;/strong&gt;&lt;br /&gt;I could probably spend another 10-15 pages about why I always prefer domain modeling over typed DataSets, but it all boils down to what adds real business value.&lt;br /&gt;&lt;br /&gt;What I've found is that you will generally spend less time building your data layer when used typed DataSets. This is because of the fact that you can use the ADO.NET API for data access &lt;em&gt;and&lt;/em&gt; ORM. That is, you can depend on an IDataAdapter implementation to fill the DataSet. That means in the complete interest of RAD, typed DataSets increase time-to-market.&lt;br /&gt;&lt;br /&gt;That being said, for the reasons mentioned above, typed DataSets cannot produce accurate domain models, nor were they ever meant for such a thing. Typed DataSets work like relational databases, which do not support even basic OO principles. Of course typed DataSets are classes, so there is some support for OO (after all, typed DataSets &lt;em&gt;descend&lt;/em&gt; from DataSet), but typed DataSets in themselves are not the entity: the tables they contain are, which is why the application of OO fails when modeling a domain.&lt;br /&gt;&lt;br /&gt;Simply put: domain modeling with user types are the right approach to domain modeling. With user types, you can support generalization, (accurate) multiplicity, (better) code reuse and other OO principles that improve the overall architectural quality. Development teams can spend lots of time getting products to market, but the simple fact is architectural quality will have a postive or negative impact on long-term and repeatable success, and all too often, not enough time is spent on quality since its ROI is generally not measured. This is often followed by more bad code and bad architectural decisions, but that's a discussion for another day (blog?).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-7058439375409217700?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/7058439375409217700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=7058439375409217700' title='24 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/7058439375409217700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/7058439375409217700'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2008/10/typed-datasets-versus-domain-model.html' title='Typed DataSets versus Domain Model'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-1983007618521817827</id><published>2008-10-06T21:32:00.010-05:00</published><updated>2008-10-07T10:38:26.605-05:00</updated><title type='text'>Software Modeling: Why Bother?</title><content type='html'>If you've written software for any length of time professionally, or even if you're in school, you have likely come across at least one UML diagram.  If not, let's have a quick refresher (or introduction for those under the proverbial rock).&lt;br /&gt;&lt;br /&gt;UML is a formal language created to model different aspects of software construction, user interactions with software, activities that code and/or users carry out, and more.  The standard UML diagrams are Class, Sequence, Activity, and Use Case diagrams.  A quick description of each is below:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Class diagrams - these diagrams are used to present visual models of software classes, and are generally used for languages with some measure of classic OO like C++, C#, Java and others.&lt;/li&gt;&lt;li&gt;Sequence diagrams -  a sequence diagram is a high-level diagram used to visually depict the &lt;span style="font-style: italic;"&gt;sequence&lt;/span&gt; of events for a given software module, IPC/RPC call, a user-initiated event in a software system, and just about anything that contains a sequence of events that can be illustrated (even washing clothes, which I can graph easily but I try to avoid in real life).&lt;/li&gt;&lt;li&gt;Activity diagrams - activity diagrams are used to illustrate a specific activity.  This is another high-level diagram that depicts sequences of events, except that an activity diagram is more thorough in illustrating how those sequences are carried out.&lt;/li&gt;&lt;li&gt;Use Case diagrams - use case diagrams are used to visually illustrate what a given item will be used for.  This is usually used to depict use cases for a screen in an application, a software module, or anything that has uses and is useful (like a washing machine).&lt;/li&gt;&lt;/ul&gt;In case you haven't noticed, UML diagrams are used to &lt;span style="font-style: italic;"&gt;visually&lt;/span&gt; convey information.  That means the consumer of a UML diagram should be able to &lt;span style="font-style: italic;"&gt;visually&lt;/span&gt; grasp the information being conveyed.  If this is not possible, the diagram isn't useful, and in practice, this happens all too often (like when a class diagram has a few hundred classes).  What this means is there are some good guidelines on what should go into a UML diagram (Martin Fowler has a great &lt;a href="http://www.amazon.com/UML-Distilled-Standard-Addison-Wesley-Technology/dp/0321193687/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1223393762&amp;amp;sr=8-1"&gt;book&lt;/a&gt; on the subject).  For now I hope I've conveyed lexically the visual nature of UML diagrams.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Class Diagram Example&lt;br /&gt;&lt;/span&gt;Sometimes the best way to illustrate stuff is visually (are we getting somewhere yet?), so let's look (visually) at an example of how class diagrams provide the ability to convey information about an object model.&lt;br /&gt;&lt;br /&gt;Below are 3 classes and an enumeration in C#.  Firstly I show the code files for each class, then below that is a UML Class diagram.  Which would you say helps you get the full picture more rapidly and definitively?&lt;br /&gt;&lt;br /&gt;public abstract class PersonBase{&lt;br /&gt;public string Name{&lt;br /&gt;}&lt;br /&gt;public string Address{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Citizen : PersonBase{&lt;br /&gt;public CarTypes CarType{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Employee : PersonBase{&lt;br /&gt;public double PayRate{&lt;br /&gt;}&lt;br /&gt;public string Department{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public enum CarTypes{&lt;br /&gt;Car,&lt;br /&gt;Truck,&lt;br /&gt;Van&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_RgYK0DzjGs0/SOrZQQ-GKxI/AAAAAAAAAW4/_3b1z17hDow/s1600-h/2008-10-06_232810.jpg"&gt;&lt;img style="cursor: pointer; width: 402px; height: 185px;" src="http://4.bp.blogspot.com/_RgYK0DzjGs0/SOrZQQ-GKxI/AAAAAAAAAW4/_3b1z17hDow/s320/2008-10-06_232810.jpg" alt="" id="BLOGGER_PHOTO_ID_5254250788737657618" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can see how the object model is depicted much more succinctly and &lt;span style="font-style: italic;"&gt;rapidly&lt;/span&gt; with the UML class diagram.  You can view all classes at the same time, and how they relate to each other.  With code files, you only have the language syntax to help you understand the interactions between classes.  While developers can be expected to know the language well enough to understand the object model, when discussing architecture and design, thoughts are much more succinct using modelling then they are using code files.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Sequence Diagram Example&lt;/span&gt;&lt;br /&gt;Below is a sequence of events that will occur when washing clothes.  This sequence of events are listed out using bulleted points.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Wear clothes; dirty 'em up&lt;/li&gt;&lt;li&gt;Load washer with clothes&lt;/li&gt;&lt;li&gt;pour soap in&lt;/li&gt;&lt;li&gt;Set washer&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Start washer&lt;/li&gt;&lt;li&gt;Wait for washer to finish&lt;/li&gt;&lt;li&gt;Move to dryer&lt;/li&gt;&lt;li&gt;Set dryer&lt;/li&gt;&lt;li&gt;Start dryer&lt;/li&gt;&lt;li&gt;Wait for dryer to finish&lt;/li&gt;&lt;li&gt;Fold clothes&lt;/li&gt;&lt;li&gt;Put clothes away&lt;/li&gt;&lt;/ul&gt;Let's take a look at the sequence diagram for the above steps:&lt;br /&gt;&lt;br /&gt;Now lets take a look at the above steps in a sequence diagram:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_RgYK0DzjGs0/SOt7ud48MOI/AAAAAAAAAXA/HyRs3Wu6lDU/s1600-h/clothes_sequence.jpg"&gt;&lt;img style="cursor: pointer; width: 254px; height: 446px;" src="http://3.bp.blogspot.com/_RgYK0DzjGs0/SOt7ud48MOI/AAAAAAAAAXA/HyRs3Wu6lDU/s320/clothes_sequence.jpg" alt="" id="BLOGGER_PHOTO_ID_5254429428485468386" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Sequence diagrams are much better at conveying the actual order of steps and the interaction between systems.  Another thing sequence diagrams do much better than a bulleted list is looping, which I won't demonstrate here.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;UML as Blueprints&lt;/span&gt;&lt;br /&gt;When an architect is designing a building, the architect will use &lt;span style="font-style: italic;"&gt;blueprints&lt;/span&gt;, which is a visual drawing created using complex CAD software.  It visually depicts the size of rooms in height/width, the location of pillars in a building, the size and angle (property lines) of the lot the building will reside on, the location of walls, doors, and windows, and many more things that I won't mention.  When conveying the design of the building to &lt;span style="font-style: italic;"&gt;anyone&lt;/span&gt;, the architect will rely on these blueprints to convey every last detail of their building with complete accuracy.&lt;br /&gt;&lt;br /&gt;When a construction team is hired to create the building, the construction team will use these blueprints to ensure the architects design is implemented correctly.  Along the way, the construction team may point out flaws in the architecture that have to be corrected.  In this case, the use of blueprints makes perfect sense.  In fact, it could be stated that the use of blueprints is &lt;span style="font-style: italic;"&gt;required&lt;/span&gt; to construct the building with &lt;span style="font-style: italic;"&gt;any&lt;/span&gt; level of accuracy in regards to the architect's design.&lt;br /&gt;&lt;br /&gt;In the book &lt;a href="http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1223392989&amp;amp;sr=8-1"&gt;Code Complete Vol. 2&lt;/a&gt;, building software is likened to formal construction of buildings; in fact, the terminology "writing" software is eschewed for "building" software and UML diagrams are likened to software "blueprints".  In other words, it is stated that software construction parallels building construction: architects design the software, developers construct the architecture using the architect's output, QA staff perform "building" (quality) inspections, and UAT processes provide the "walk-through".&lt;br /&gt;&lt;br /&gt;When thinking about software as construction, it leads you to see the benefit of visual documentation.  UML serves this purpose very well, as it allows you to blueprint every aspect of your system, from business requirements down to implementation details such as abstract base classes and descendents, interfaces and realizations (implementors), and so on.  It helps you to see how applying development &lt;span style="font-style: italic;"&gt;process&lt;/span&gt; to building software aids in creating repeatable success; that is, building and shipping software is one thing, being able to do it &lt;span style="font-style: italic;"&gt;over and over&lt;/span&gt; in a systematic fashion is quite another, and the latter yields more long term success.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Closing&lt;/span&gt;&lt;br /&gt;I hope that I've demonstrated how things can be conveyed using visual diagrams much more succinctly and rapidly.  I hope that you can see the benefit of class diagrams and sequence diagrams, and I would encourage you to look into activity and use case diagrams.  In other words, I hope that you can see the real benefit of UML documentation.  It not only provides visual aids in understanding a software system, it can act as a true software blueprint when formal architecture preceeds writing code (and even when it doesn't).&lt;br /&gt;&lt;br /&gt;UML can be used to get new team members up to speed on the architecture.  UML can give help the business players on your team to really understand what developers are doing in that dark room, and can help everyone speak the same language.  Finally, UML introduces formal architecture, which gets developers/architects thinking about the &lt;span style="font-style: italic;"&gt;solution&lt;/span&gt; to the problem (the implementation) prior to writing any code, which lends itself to accurate and quality implementation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-1983007618521817827?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/1983007618521817827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=1983007618521817827' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/1983007618521817827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/1983007618521817827'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2008/10/software-modeling-why-bother.html' title='Software Modeling: Why Bother?'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_RgYK0DzjGs0/SOrZQQ-GKxI/AAAAAAAAAW4/_3b1z17hDow/s72-c/2008-10-06_232810.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-6389024730907294892</id><published>2008-08-08T21:37:00.002-05:00</published><updated>2008-08-08T21:39:55.591-05:00</updated><title type='text'>Wow It's Been A While!</title><content type='html'>So I can see that it's been quite some time since my last post - it was shortly before I started for TopCoder.&lt;br /&gt;&lt;br /&gt;Well here I am posting again.  I had actually moved my technical blog to my own &lt;a href="http://www.rockwithme.org"&gt;site&lt;/a&gt; but now I'm moving back.  I think it's much better for anybody needing to refer to my technical blog to not have to deal with the noise of my personal blogs :)&lt;br /&gt;&lt;br /&gt;So anyway, I'm still working for TopCoder which is awesome.  I'm having a blast!  Currently I'm implementing a workflow that processes a set of client data and runs some prioprietary calculations against some of the values in that data set.  It's a ton of fun.&lt;br /&gt;&lt;br /&gt;So this is my triumphant return; though it's highly likely I won't have much time to post.  We'll see how it goes?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-6389024730907294892?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/6389024730907294892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=6389024730907294892' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/6389024730907294892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/6389024730907294892'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2008/08/wow-its-been-while.html' title='Wow It&apos;s Been A While!'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-708597003816094809</id><published>2007-10-06T17:42:00.000-05:00</published><updated>2007-10-06T17:57:00.106-05:00</updated><title type='text'>Funny where life takes you</title><content type='html'>About 2 years ago, I was introduced to a website called '&lt;a href="http://www.topcoder.com/"&gt;Top Coder&lt;/a&gt;' by a guy I worked with.  His words to me were "If you ever want to find out who the better programmer is, we can go here and compete".  I was very intrigued, but we never did compete.  From that point on, I regularly logged in to &lt;a href="http://www.topcoder.com/"&gt;Top Coder&lt;/a&gt;'s site and reviewed the available competitions.  I thought to myself, "I wonder if I'm good enough to compete against people I don't know".  I never did compete, only watching these competitions from a distance.  One time I did download a distribution for a development competition that was in progress, but I just decided I hadn't the time to compete, so I didn't.  Well, one day I get a call from some one at &lt;a href="http://www.topcoder.com/"&gt;Top Coder&lt;/a&gt;, they were wondering what I was up to currently, as they liked my skillset and was wondering if I'd be interested in interviewing!  I had just started a new gig somewhere else, and thought it best to wait it out a bit and see where that gig went.&lt;br /&gt;&lt;br /&gt;For the unenlightened, &lt;a href="http://www.topcoder.com/"&gt;Top Coder&lt;/a&gt; hosts the worlds best &lt;a href="http://www.topcoder.com/tc"&gt;programming competitions&lt;/a&gt; in the world.  They use this process to &lt;a href="http://software.topcoder.com/tcs?module=Static&amp;amp;d1=tour&amp;amp;d2=page1"&gt;build great software&lt;/a&gt;.  If you think you've got what it takes to compete, you should do so asap, because not only can you prove it, but you can make money doing it.&lt;br /&gt;&lt;br /&gt;Anyway, I couldn't stop thinking about &lt;a href="http://www.topcoder.com/"&gt;Top Coder&lt;/a&gt;, and the allure for working at &lt;a href="http://www.topcoder.com/"&gt;Top Coder&lt;/a&gt; never waned.  I went through the interview process, and with great avidity, I accepted an offer to join.  My first day was officially October 1st, and I'm never looking back.  The feeling I get from everybody so far is this is the best team I've ever joined.  I've spent a few years contributing to open source software to build my skill set as a programmer, but after going through the interview process and competing for the first time recently, I now wish I had spent more time competing.  That aside, here's to my joining a company I think has the best process in the industry, and a company I am super proud of being associated with.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-708597003816094809?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/708597003816094809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=708597003816094809' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/708597003816094809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/708597003816094809'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/10/funny-where-life-takes-you.html' title='Funny where life takes you'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-8600407297451565422</id><published>2007-08-29T13:00:00.000-05:00</published><updated>2007-08-29T13:01:25.804-05:00</updated><title type='text'>Wow</title><content type='html'>It has been an extremely long time since I've posted on here, but I'm back in the saddle, and will be coming with some new posts very soon; keep checking back.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-8600407297451565422?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/8600407297451565422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=8600407297451565422' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/8600407297451565422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/8600407297451565422'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/08/wow.html' title='Wow'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-4239705901393846880</id><published>2007-02-22T10:51:00.000-05:00</published><updated>2007-02-22T10:52:37.834-05:00</updated><title type='text'>Answer to What's Wrong With This Code</title><content type='html'>I can't believe it's Thursday already!!  Yes, I forgot to post the answer to the previous problem yesterday, so here it is:&lt;br /&gt;&lt;br /&gt;Looks like 3_4 on 7 got it right:&lt;br /&gt;&lt;br /&gt;&lt;dl id="comments-block"&gt;&lt;dt id="c9119989650780580812"&gt;                     3_4 on 7    said...      &lt;/dt&gt;&lt;dd&gt; &lt;p&gt; I don't believe this would compile. I'm not sure what the output would be but, since C# does not support optional parameters, I believe you're required to supply a value for all of the parameters, including the optional parameters.&lt;br /&gt;&lt;br /&gt;However, the VB developer in this instance should make sure that their code is never going to be in a library that is being used by another language as including a universally unsupported concept like optional parameters would be poor development practice. &lt;/p&gt;&lt;/dd&gt;&lt;/dl&gt;C# does NOT (to my dismay and probably the dismay of many other developers) support optional parameters, therefore when referencing the code in C#, it would display the parameter list as having required parameters.  See you next time!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-4239705901393846880?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/4239705901393846880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=4239705901393846880' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/4239705901393846880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/4239705901393846880'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/02/answer-to-whats-wrong-with-this-code.html' title='Answer to What&apos;s Wrong With This Code'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-8072982631240078159</id><published>2007-02-19T23:09:00.000-05:00</published><updated>2007-02-19T23:25:42.461-05:00</updated><title type='text'>What's Wrong With This Code?</title><content type='html'>In this (hopefully) multi-part series, I will be presenting challenging (maybe to over-glorified web developers or egocentric re-implementers like previous developers I've worked with, you know who you are!  =^) programming problems that readers can solve via comments, and I will respond either with the winning comment or just the answer because nobody responded, in which case I will cry.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;What's Wrong With This Code?&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Say you have the following VB code:&lt;br /&gt;&lt;br /&gt;Public Class Adder&lt;br /&gt; Public Shared Function Add( ByVal a As Integer, ByVal b As Integer, Optional ByVal c As Integer = 0) As Integer&lt;br /&gt;     Return a + b + c&lt;br /&gt; End Function&lt;br /&gt;End Class&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;Then you have the following C# code referencing the previous VB code:&lt;br /&gt;&lt;br /&gt;public class AdderClient{&lt;br /&gt; public static void CallAdder(){&lt;br /&gt;    Console.WriteLine(Adder.Add( 1, 2 ));&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Will this compile?  Why/why not?  What would the output be? &lt;br /&gt;&lt;br /&gt;The answer will come Wednesday!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-8072982631240078159?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/8072982631240078159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=8072982631240078159' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/8072982631240078159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/8072982631240078159'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/02/whats-wrong-with-this-code.html' title='What&apos;s Wrong With This Code?'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-2174679449876295617</id><published>2007-02-16T11:51:00.000-05:00</published><updated>2007-02-16T12:01:13.341-05:00</updated><title type='text'>Favorite UML Tool</title><content type='html'>I didn't post yesterday in this (psuedo) daily blog; I'm a baaaaad man!!&lt;br /&gt;&lt;br /&gt;Anyway, I wanted to share what has become my official favorite UML/Design tool - Enterprise Architect.&lt;br /&gt;&lt;br /&gt;As you know, I'm leaving my current post and moving on to new ventures, and it's been quite some time since I updated my UML diagrams with the code I've been working with.  Well, I figured up Enterprise Architect, created a new project for each programming project I had been working on, and imported them into EA.  This is where EA is absolutely awesome: it reverse-engineered all of my code and generated class diagrams!  This feature alone must have saved me hours of work.&lt;br /&gt;&lt;br /&gt;Also, a few months ago when I had started one of the projects I was working on, I fired up EA, and did a lot of visual design using UML models.  EA also generated the code for me in my desired language (it currently supports enough language to be useable in almost any shop like Java, C#, Python, PHP, and more), and it allowed me to specify namespaces and other rules when code was generated (I used it for C#).&lt;br /&gt;&lt;br /&gt;Check out Enterprise Architect, along with its sweet Visual Studio integration at http://www.sparxsystems.com/ea.htm.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-2174679449876295617?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/2174679449876295617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=2174679449876295617' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/2174679449876295617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/2174679449876295617'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/02/favorite-uml-tool.html' title='Favorite UML Tool'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-3489919052992465765</id><published>2007-02-14T08:37:00.000-05:00</published><updated>2007-02-14T09:07:43.204-05:00</updated><title type='text'>Anonymous Methods - Perfect Stranger Or Close Relative?</title><content type='html'>Since most of the world (minus those currently under rocks or archaic cave dwellers) knows what anonymous methods are, I won't spend too much time analyzing them here.  I did however come across something interesting when analyzing the IL of an assembly with a class that uses an anonymous method for sorting a collection.  First we'll take a look at code and it's IL after compilation without an anonymous method, and then we'll try to put a face on the anonymity of anonymous methods.&lt;br /&gt;&lt;br /&gt;Here's the code without anonymous methods:&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;&lt;br /&gt;public class SortMan{&lt;br /&gt;public static void Main( string[] args ){&lt;br /&gt;  SortMan s = new SortMan();&lt;br /&gt;  s.Test_Sort();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void Test_Sort(){&lt;br /&gt;  List&lt;datetime&gt; dates = new List&lt;datetime&gt;();&lt;br /&gt;&lt;br /&gt;  dates.Add( DateTime.Now );&lt;br /&gt;  dates.Add( DateTime.Now.AddDays( -30 ) );&lt;br /&gt;  dates.Add( DateTime.Now.AddDays( -120 ) );&lt;br /&gt;  dates.Add( DateTime.Now.AddDays( -5 ) );&lt;/datetime&gt;&lt;/datetime&gt;&lt;br /&gt;&lt;datetime&gt;&lt;datetime&gt;&lt;br /&gt;  /*delegate( DateTime d1, DateTime d2 ){&lt;/datetime&gt;&lt;/datetime&gt;&lt;br /&gt;&lt;datetime&gt;&lt;datetime&gt;           return d1.CompareTo( d2 );&lt;br /&gt;  }*/&lt;br /&gt;  dates.Sort( this.Sort );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private int Sort( DateTime d1, DateTime d2 ){&lt;br /&gt;  return d1.CompareTo( d2 );&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/datetime&gt;&lt;/datetime&gt;&lt;br /&gt;&lt;datetime&gt;&lt;datetime&gt;And here's its IL (ildasm.exe):&lt;/datetime&gt;&lt;/datetime&gt;&lt;br /&gt;&lt;datetime&gt;&lt;datetime&gt;&lt;br /&gt;&lt;/datetime&gt;&lt;/datetime&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img245.imageshack.us/img245/4333/nonanonmethgv0.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px;" src="http://img245.imageshack.us/img245/4333/nonanonmethgv0.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Obviously our 'Sort' method is a member of our 'SortMan' class, just like any other method we would write in any other normal class.  What about using an anonymous method?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's the code for our 'SortMan' class with an anonymous method:&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;&lt;br /&gt;public class SortMan{&lt;br /&gt;public static void Main( string[] args ){&lt;br /&gt;    SortMan s = new SortMan();&lt;br /&gt;    s.Test_Sort();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void Test_Sort(){&lt;br /&gt;    List&lt;datetime&gt; dates = new List&lt;datetime&gt;();&lt;br /&gt;&lt;br /&gt;    dates.Add( DateTime.Now );&lt;br /&gt;    dates.Add( DateTime.Now.AddDays( -30 ) );&lt;br /&gt;    dates.Add( DateTime.Now.AddDays( -120 ) );&lt;br /&gt;    dates.Add( DateTime.Now.AddDays( -5 ) );&lt;/datetime&gt;&lt;/datetime&gt;&lt;br /&gt;&lt;datetime&gt;&lt;datetime&gt;   &lt;br /&gt;    &lt;span style="font-weight: bold;"&gt;dates.Sort( delegate( DateTime d1, DateTime d2 ){&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;            return d1.CompareTo( d2 );&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;        });&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And finally here's the IL for this compiled assembly:&lt;br /&gt;&lt;br /&gt;&lt;/datetime&gt;&lt;/datetime&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_RgYK0DzjGs0/RdMTIc7RzAI/AAAAAAAAAOM/bwj1_jm-gZE/s1600-h/anon-meth.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_RgYK0DzjGs0/RdMTIc7RzAI/AAAAAAAAAOM/bwj1_jm-gZE/s320/anon-meth.jpg" alt="" id="BLOGGER_PHOTO_ID_5031386244627680258" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It's quite interesting to note that our "anonymous" method actually compiles as a static field in our SortMan class, with a local static method as its target!  This "anonymity" appears to be nothing more than syntactical sugar to make it appear is if you don't really need a delegate instance, when in fact the compiler is creating a static delegate field variable for you, with a local static method as its target.&lt;br /&gt;&lt;br /&gt;Anonymous methods make for clean syntax, but they are far from anonymous, and actually become a relative of the class they live inside.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-3489919052992465765?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/3489919052992465765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=3489919052992465765' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/3489919052992465765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/3489919052992465765'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/02/anonymous-methods-perfect-stranger-or.html' title='Anonymous Methods - Perfect Stranger Or Close Relative?'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_RgYK0DzjGs0/RdMTIc7RzAI/AAAAAAAAAOM/bwj1_jm-gZE/s72-c/anon-meth.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-8363398244152819637</id><published>2007-02-13T13:56:00.000-05:00</published><updated>2007-02-12T23:07:51.848-05:00</updated><title type='text'>Great Book</title><content type='html'>In this series of Great Book posts, I'll try to provide enough information that will hopefully deem a book worthy of reading or worthy of your campfire, including three rating systems: General Rating (*-***** - 1-5 stars), Preponderance (*-***** - 1-5 stars relative to other books that should be in your collection), and Skill Level (or target for what type of skill level you should have when reading this book; this rating will be taken directly from the book if it has one).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A great book I recently picked up was Applied Micorosft .NET Framework Programming,  by Jeffrey Richter.  This book dives deep into the .NET Framework (v. 1.0) and succinctly covers topics such as header information written into .NET Assemblies (which really drives a point made in Effective C# about small assemblies), type fundamentals like the difference between a primitive, value and reference type and the differences between an instance and type constructor, and many more low-level .NET Framework topics.  Even though this book is based on a more archaic version of the .NET Framework, much of the information is applicable to .NET Framework programming today.  It's definitely a must read for novice and expert alike.&lt;br /&gt;&lt;br /&gt;General Rating: ****&lt;br /&gt;Preponderance: ****&lt;br /&gt;Skill Level: Novice-&gt;Expert&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-8363398244152819637?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/8363398244152819637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=8363398244152819637' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/8363398244152819637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/8363398244152819637'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/02/great-book.html' title='Great Book'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-7278682618768601914</id><published>2007-02-12T16:04:00.000-05:00</published><updated>2007-02-12T16:56:08.638-05:00</updated><title type='text'>Demistifying Recursion</title><content type='html'>One of those "how deep does the rabbit hole go" issues you encounter along your programming journey can be recursion.  At first it makes sense, then it's confusing, then it makes sense, then it ....&lt;br /&gt;&lt;br /&gt;Moving on!  I'll try to provide some of the basic things you'll need to be aware of when you think recursion is the way to go, as well as some pointers and caveats implementing recursion within the .NET Framework.  We'll use C# as the language for this article.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Recursion Defined&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;Let's describe function recursion as simple as possible: say you have an arbitrary function (SimpleMindedAndDumbNonCoolNonRecursiveFunction(), or FunctionA()), and it has some complex calculation that it hands off to another arbitrary (this time recursive) function that performs this calculation recursively (WayCoolAndRockinRecursiveFunction(), or FunctionB()).  FunctionB() performs this calculation by "recursing", or calling itself multiple times.  Let's analyze a better example.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Recursion Analyzed&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;Say FunctionA() contains a &lt;a href="http://en.wikipedia.org/wiki/Binary_tree"&gt;binary tree&lt;/a&gt; that you would like to traverse in &lt;a href="http://en.wikipedia.org/wiki/Tree_traversal"&gt;pre-order&lt;/a&gt; fashion.  The only way to achieve pre-order tree traversal is to do so recursively.  Let's look at the definition of our binary tree:&lt;br /&gt;&lt;br /&gt;public class Node{&lt;br /&gt;    private Node left;&lt;br /&gt;    private Node right;&lt;br /&gt;    private int val;&lt;br /&gt;   &lt;br /&gt;    public Node(){}&lt;br /&gt;   &lt;br /&gt;    public Node( Node Left, Node Right, int Val ){&lt;br /&gt;        this.left = Left;&lt;br /&gt;        this.right = Right;&lt;br /&gt;        this.val = Val;&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    public Node Left{&lt;br /&gt;        get{&lt;br /&gt;            return this.left;&lt;br /&gt;        }&lt;br /&gt;        set{&lt;br /&gt;            this.left = value;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    public Node Right{&lt;br /&gt;        get{&lt;br /&gt;            return this.right;&lt;br /&gt;        }&lt;br /&gt;        set{&lt;br /&gt;            this.right = value;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;   &lt;br /&gt;    public int Value{&lt;br /&gt;        get{&lt;br /&gt;            return this.val;&lt;br /&gt;        }&lt;br /&gt;        set{&lt;br /&gt;            this.val = value;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And here's the code for FunctionA():&lt;br /&gt;&lt;br /&gt;public void FunctionA(){&lt;br /&gt;        Node parentNode = new Node();&lt;br /&gt;        parentNode.Value = 1;&lt;br /&gt;       &lt;br /&gt;        parentNode.Left = new Node();&lt;br /&gt;        parentNode.Left.Value = 2;&lt;br /&gt;       &lt;br /&gt;        parentNode.Left.Left = new Node();&lt;br /&gt;        parentNode.Left.Left.Value = 3;&lt;br /&gt;       &lt;br /&gt;        parentNode.Right = new Node();&lt;br /&gt;        parentNode.Right.Value = 4;&lt;br /&gt;        parentNode.Right.Right = new Node();&lt;br /&gt;        parentNode.Right.Right.Value = 5;&lt;br /&gt;        //you get the point ...&lt;br /&gt;       &lt;br /&gt;        FunctionB( parentNode, 1 );&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;We can simply write code to traverse this binary tree that spans all levels of nodes without recursion.  But that can only be done reliably (and IMHO very ugly) if all the levels of the tree are known.  But what if we add more nodes?  Or remove nodes?  Writing code based on this assumption would be a great failure on our part.  There is a better way.   Enter Recursion:&lt;br /&gt;&lt;br /&gt;private void FunctionB( Node parentNode, int counter ){&lt;br /&gt;        //This function walks a binary tree in pre-order fashion&lt;br /&gt;   &lt;br /&gt;        Console.WriteLine( parentNode.Value );&lt;br /&gt;        Console.WriteLine( string.Concat( "Recursive calls so far: ", counter++ ) );&lt;br /&gt;       &lt;br /&gt;        if ( parentNode.Left != null )&lt;br /&gt;            FunctionB( parentNode.Left, counter );&lt;br /&gt;        if ( parentNode.Right != null )&lt;br /&gt;            FunctionB( parentNode.Right, counter );&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;10 lines of elegant simplicity.  Here's how this function works:&lt;br /&gt;&lt;br /&gt;It gets called (originally by FunctionA, with a value of 0 for 'counter'), and the value of parentNode is written to the Console.  Then FunctionB determines if the left and right nodes are null.  If Left is not null, FunctionB calls FunctionB (itself), passing parentNode.Left as the argument.  If Right is not null, FunctionB then calls FunctionB (itself) with parentNode.Right as the argument.  The entire process starts all over, and the same code is excuted, as if parentNode were the first node in the tree, even though FunctionB at this point is processing parentNode.Left and parentNode.Right.  &lt;br /&gt;&lt;br /&gt;FunctionB basically does not "care" what node it is currently working on; only that it is a Node, and that the Node contains a Value, and optionally Left and Right nodes.  This is happening 'recursively', because FunctionB is calling FunctionB is calling FunctionB (...) until the bottom-most node in the tree is reached, at which point the "bottom-most" call to FunctionB returns control to the previous FunctionB, all the way back up to the top.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Note:&lt;/span&gt; If too many recursive calls occur, an ugly 'System.StackOverflowException' will be thrown, because there will be too many function calls on the stack, so use recursion wisely.&lt;br /&gt;&lt;br /&gt;Let's look at the output from the recursive call, perhaps this will shed some more light on what exactly is happening when the function calls are made.&lt;br /&gt;&lt;br /&gt;1&lt;br /&gt;Recursive calls so far: 1&lt;br /&gt;2&lt;br /&gt;Recursive calls so far: 2&lt;br /&gt;3&lt;br /&gt;Recursive calls so far: 3&lt;br /&gt;4&lt;br /&gt;Recursive calls so far: 2&lt;br /&gt;5&lt;br /&gt;Recursive calls so far: 3&lt;br /&gt;Finished!&lt;br /&gt;&lt;br /&gt;FunctionA calls FunctionB, with parentNode, and a value of 1 for counter (which gets printed first as the value for parentNode), then the current counter value is printed, to keep track of how many recursive calls we've made.  You may notice that the amount of recursive calls follows the pattern 1-&gt;2-&gt;3-&gt;2-&gt;3.  This is because 'counter', being incremented, is passed to the next call FunctionB along with parentNode.Left, then 'counter' is incremented again, and FunctionB is called with parentNode.Right.  Since 'Right' is the last node on this path, control is returned, and 'counter's previous value (2) is back in place. &lt;br /&gt;&lt;br /&gt;This is where recursion can be difficult to understand.  Remember this rule of thumb: variables that have one value within a method body may have a different value at the same point in the same method body, when that variable's scope is within a recursive method.  This is because when FunctionB is called again, this is a NEW method call, and when that method call is complete, the previous method call picks back up where it left off.  FunctionB may as well have called FunctionC or even FunctionD.&lt;br /&gt;&lt;br /&gt;As you can see though, the output of the current nodes value follows the pattern we set when we originally set up our tree, in FunctionA (parent=1, parentNode.Left=2, parentNode.Left.Left=3 etc.).&lt;br /&gt;&lt;br /&gt;Another benefit of the recursive FunctionB is we can add or remove nodes on a whim, and FunctionB can handle this automatically without any code change whatsoever.&lt;br /&gt;&lt;br /&gt;I hope this post has helped you obtain a better understanding of function recursion.  Recursion is simple to implement, and can empower a developer to perform complex calculations with great ease, while maintaining a clean codebase, and minimalist class sizes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-7278682618768601914?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/7278682618768601914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=7278682618768601914' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/7278682618768601914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/7278682618768601914'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/02/demistifying-recursion.html' title='Demistifying Recursion'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5140708481885520713.post-6977885882915123697</id><published>2007-02-09T10:18:00.000-05:00</published><updated>2007-02-09T14:29:19.933-05:00</updated><title type='text'>How To Be A Great Programmer</title><content type='html'>When first starting out as a programmer, it can be quite difficult to discern what steps to take to grow your skills and flourish.  This difficutly is compounded when working around others who have radical, pernicious ideas of how to write software.  How does one overcome this?  How can you continue to grow as a developer, even while working around others who can perpetuate bad habits?  How can one identify when the ideas of those around them are actually "bad"?&lt;br /&gt;&lt;br /&gt;Well, as it turns out, there's a method to the madness. In this multipart series, I plan on covering many steps to unravel the mystery behind becoming great, especially since it's really always a work in progress, and never a desitination (did I just say that greatness can never be achieved?).  But in this particular post, we'll start with some of the more basic steps I took to help my skills flourish.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;How To Choose A Language&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;   The language you finally settle on dictates what path you should follow, but your choice of languages should start with a solid, low level language.  I started with C (via K&amp;R/CC classes).  Learning C first laid an excellent foundation for what has so far become a great journey in the world of writing software.  There is lot's of great &lt;a href="http://cr.yp.to/qmail.html"&gt;software&lt;/a&gt; originally written (and still maintained) in C.  If you're gonna learn C, make sure to have the &lt;a href="http://en.wikipedia.org/wiki/The_C_Programming_Language_%28book%29"&gt;K&amp;amp;R&lt;/a&gt; book handy (it was co-authored by the creator of the C language, &lt;a href="http://en.wikipedia.org/wiki/Dennis_Ritchie"&gt;Dennis Ritche&lt;/a&gt;, who is one of the greatest contributors to computing in general).  Even if you've been a programmer for a number of years, and even if you have no use for C, learn it anyway.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Note: &lt;/span&gt;Whatever you do in software, it all comes down to one thing: hard work.  If you're unwilling to put in the hard work necessary to be good at writing software, then you will waste the time and money of many people (including yourself).   The hard work never really ends, and you must be able to persevere.&lt;br /&gt;&lt;br /&gt;This is the path I chose when I decided I wanted to write software:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Learned C: I attended a class at my local CC, read K&amp;R, and wrote as much code as I could.&lt;/li&gt;&lt;li&gt;Learned C++: I mostly read C++ Primer Plus (great book on C++), and wrote more code.&lt;/li&gt;&lt;li&gt;Learned VB6: I again attended a class at my local CC, and wrote more code still.&lt;/li&gt;&lt;li&gt;Learned C#: I started learning C# around the time I was attending classes for VB6, shortly before the .NETFX 1.0 was released (pre-beta+).&lt;/li&gt;&lt;li&gt;Learned Java: Because of my familiarity with C based languages, I figured I would have an easy time with this, and I did.  Syntactically, Java is very similar to C# (some would say C# was derived from Java), and so for me Java was like learning European English while already knowing American (U.S.) English (in other words, a rather easy transition).&lt;/li&gt;&lt;li&gt;Learning(ed) Python: This is a work in progress, though I have written a calculator with some minor scientific calculations.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Currently, I work mostly in C# and .NET 2.0 professionally, with most free time spent in Python.  A great book, Pragmatic Programmer, says you should learn one language every year; I tend to think this is great advice.&lt;br /&gt;&lt;br /&gt;My next step was to join and actively participate in the Open Source community.  I feel this was one of the best steps I ever made.  My skills grew tremendously, as I was reading code written by others (two of the best I found in C# were the Jabber library for C# - jabber-net, and the MySQL .NET Connector), and I was writing code to be viewed by others (now the world is really watching!).  I also participated in as many C# and Java forums as I could register for and still get work done throughout the day.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In my next post, I plan on discussing more about learning programming languages, as well as beginning discussion on more advanced topics, like design patterns, methodologies, and so on.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5140708481885520713-6977885882915123697?l=smartkoder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://smartkoder.blogspot.com/feeds/6977885882915123697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5140708481885520713&amp;postID=6977885882915123697' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/6977885882915123697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5140708481885520713/posts/default/6977885882915123697'/><link rel='alternate' type='text/html' href='http://smartkoder.blogspot.com/2007/02/how-to-be-great-programmer.html' title='How To Be A Great Programmer'/><author><name>Carlos J. Muentes</name><uri>http://www.blogger.com/profile/09303457798306507668</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='33' height='26' src='http://1.bp.blogspot.com/-LkW_Pp4julM/ToSrZZEVuSI/AAAAAAAAAeQ/D1HyjvVPB8s/s220/rsz_p14.jpg'/></author><thr:total>1</thr:total></entry></feed>
