I recently implemented a recursive function in my code and wanted to write about my experience. First, let me say this is not the first time I've written a recursive function and hopefully won't be the last. However, as a developer I jump at the opportunity to write one. As someone who loves to avoid the conventional for each within another for each statement the idea of a recursive function just gets me all excited inside.
Definition:
- A function that calls itself repeatedly, satisfying some condition is called a Recursive Function.
Why would a developer use recursion?
A better question to ask would be why a developer would not use recursion? The classic for loop within a for loop to update the same property for each item in a multi-dimensioned list is just not practical. The code itself is just not clean.
Example of recursion:
I had a scenario where I needed to gather a list of parameters for rows linked via a parent-child relationship. In a nutshell I had a case where a parent row could be linked to several children rows, which also could be linked to several of their own children rows. This could go on and on. I also had to identify the selected row in my list as well for future analysis. Below is a simple code example of recursion.
private void UpdateGridRowInformation(UltraGridRow row, List<GridRowInformation> list)
{
bool isActiveRow = ((Summary)row.ListObject).Key == _activeRowKey;
int parentListIndex = -1;
if (row.HasParent())
parentListIndex = row.ParentRow.ListIndex;
if (row.HasChild(true))
{
//if item has a child then store its Row Information and call recursion //on Child
UpdateGridRowInformation(row.ChildBands[j].Rows
, list);
UpdateGridRowInformationList(parentListIndex, row.ListIndex, row.Band.Key, row.Expanded, isActiveRow, list);
}
else if (isActiveRow)
UpdateGridRowInformationList(parentListIndex, row.ListIndex, row.Band.Key, row.Expanded, true, list);
}
private void UpdateGridRowInformationList(int parentRowIndex, int listIndex, string bandKey, bool expanded, bool active, List<GridRowInformation> list)
{
GridRowInformation gridRowInformation = new GridRowInformation();
gridRowInformation.ParentRowIndex = parentRowIndex;
gridRowInformation.ListIndex = listIndex;
gridRowInformation.BandKey = bandKey;
gridRowInformation.Expanded = expanded;
gridRowInformation.Active = active;
list.Add(gridRowInformation);
}
This code runs through all parent child relationships and adds particular row elements to a list if that row has its own children. This also adds the selected row’s elements.
Conclusion:
Recursion is clean, easy, and extremely beneficial in programming. There are dangers to watch out for though. Just like for loops there must be a way to exit the function cleanly. Keep in mind that because the function calls itself again and again a spiral effect is created. The first time the function is called will not finish until the instance it calls is finished. That instance does not finish until the instance it calls is finished. And this cycle continues. Therefore, if the function continuously calls itself with no calls ever finishing, the application will be stuck running in that part of the code most likely causing the CPU utilization to increase and the application to halt.
In my case, I will eventually get to the last row of the last child, then the function will unwrap and my code will continue. This is a pretty simple example of recursion however it is a very powerful method used for development.
Conclusion Part II:
To conclude from a personal standpoint, I am a happy coder as I have written a recursive function in my application <g>!
The Chicago competition of Microsoft's PhizzPop Design Challenge took place last night at a club called The Underground. As taken from their website, the PhizzPop Design Challenge pits top interactive, Web, and design agencies against one another to push the limits of technology and creativity in a battle royale. Six teams compete in six cities with the winners of each city then competing at the South by Southwest Interactive Conference in Austin, TX. The Chicago competition had Ratchet, Effective UI, Webitects, Clarity Consulting, Tribal DDB, and Magenic as the companies presenting in the design challenge.
The Challenge
Airplanes! To most, riding an airplane is a miserable experience. Most hate long terminal lines, taking off and landing of a plane, and of course sitting for X number of hours staring at a PG movie or trying to sleep in those uncomfortable chairs. Flying, in general, just sucks. What can be done about this? Well, Microsoft proposed an in-flight concept based on new technology that could improve a passengers enjoyment. The technology used to create this concept is Windows Presentation Foundation or WPF. Each company had three representatives spend two and a half days developing an application using WPF that would somehow make a person's experience on a flight more enjoyable. The airline the teams are creating this for? None other then Howard Hughes nemesis Pan Am Airlines. So this is the challenge! Last night I was able to see all six companies entries and here are the results.
The Teams
Ratchet
Ratchet was the first company to present. They actually teamed up with a design company, sorry I can't remember the name. Its always hard to be the first presenter in a competition as judges tend to remember you the least at the end. You really have to stand out. I don't think it helped that it was obvious these developers and designers were Apple 'fan boys' and were not too fond of Microsoft. I took this by how excited one of them was when he won a Zune in one of the raffles.
Regardless of their opinions of Microsoft, they used the tools designated for this contest and created a pretty nice application. The application was easy on the eye, creative, and I believe a really good effort for first time users of these development tools. They had a simple Kiosk touch screen application on the back of an airplane seat. A user was able to watch movies (though we didn't actually see a video), chat with other users, and contact people not on the flight using Twitter. The provided a business case scenario for this, for example if their flight is running late, they can update work. They also provided an in-flight live map of where the plane's current position is. In all, it was a good opening presentation and set the bar for what to expect from the other teams.
Effective UI
Effective UI was the second company. After researching all the teams going into this competition I thought this was the team that had the best chance. Their company website is very cool, very user interactive, and really demonstrates what I believe is the bar for rich user experiences.
Compared to Ratchet's presentation, Effective UI's blew it away. It was a very nice presentation with some interesting additions. After seeing it I believed it would get some consideration for winning this contest. The application itself had all the same amenities as Ratchet's with the ability to view movies, chat, plane location, etc. But besides having some animation, which made the application just more user appealing, they came up with a fantastic idea to have a touch screen at each user's armrest that interacted with their application. Kind of like a mouse for the user. I do want to add that there were some really nice zoom features in their app as well. All in all, very good application that enhanced the user experience immensely.
Webitects
Webitects was the next company. I didn't really know what to expect from this company. After looking at some of their work I thought this was a really good company for this task, but maybe not in the league of Effective UI. And after their presentation, I still had the same opinion. They had a web page where users could update their flight information at that particular time. For example, lets say their flight is being delayed. A user could go to this website and reschedule a connecting flight for a later time. However, though this is a nice idea, its something that is pretty normal in today's user experience in flying. You can get internet access on a plane and do this. After seeing Effective UI's application, I became all excited with new creative features in a user experience, so though this application was really good, it left an element to be desired.
Clarity Consulting
Clarity Consulting was the fourth company and host for all the developers to work at. I have to be honest, my review here is going to to be extremely biased because I work for Clarity Consulting. They are one of the two development companies in this competition out to show that developers can also be good designers.
To say I was impressed by the presentation wouldn't give enough credit to those guys. They started with a video of an IPhone application. They can use this application to book, review the itinerary of their flight, and even view their boarding pass. They were the first team to present a concept not just for the present user experience but for the future too. They then demonstrated their Kiosk, which was extremely user friendly, extremely animated, and contained a lot of content. The one thing, from a user interface perspective, that stood out from the other applications was the look and feel of their buttons. By having different button sizes, they gave a three dimensional look and feel. Plus their user interface flow was really impressive. Moving from screen to screen seemed to be a smooth transition instead of a jump cut (not to steal a movie term). Definitely was wowed!
Tribal DDB
Tribal DDB, the next company, I thought would be the other big name player based on their website. Their website was very user rich experienced and its clear this companies is really strong in the design environment.
I really liked their presentation. It was very clean, had a lot of animation, and there is a lot to be said about colors. They were the first team to really use colors well. From a visual friendly point of view, this was the best so far. That being said the content was similar to all four previous presentations. They had an obscure movie selection, a very nice seating arrangements viewing GUI, and chat capabilities. These guys are really good at what they do and this application definitely proved that.
Magenic
Magenic was the final company to present and the other development company in this contest. I have met and worked with a few of their past and present employees and think very highly of them as developers. So I was really interested to see what their design team could come up with.
Their presentation was really nice. It wasn't wowing. It wasn't animated. It didn't have features that stood out. But still, it was really nice. It was a very clean application that was easy to move around and had similar features to the previous presentation. One thing I did notice was their team's use of colors, pictures and GUI layout was very good. I find it strange that the two development companies were just fabulous with the rich user experience part of the presentation. This was the one area I thought they would be lacking in.
The Judges
Jeremy Alexis an Assistant Professor at IIT's Institute of Design has a tremendous amount of experience in defining next generation products, services, and business models.
Scott Kinkaid, Vice President of Usability Practices is an expert in defining solutions and integrating the knowledge of traditional lab-based research with online user experiences.
Carlos Segura, one of the most innovative, creative, and talented graphic designers of our time. His artistry is known throughout the world and most of the presenters were extremely honored to just meet him, let alone have him judge their contest.
The Winners
Carlos was the last to talk about the presenters. It was interesting that he said one of the most important criteria the judges were looking for was, in a nutshell, innovation. It was fascinating to know what we could do now with this technology, but where was it headed? What new creative ideas can arise from the use of this technology. He followed by saying therefore hands down the winner is Clarity Consulting! Based on that I think the addition of the IPhone and its usability in the entire flight experience was exactly what the judges were looking for. Using this technology to be innovative is what design is all about. All these teams were very technology savvy, artistic, and did a fabulous job on their presentations. But besides all the cool animation, video, and data in Clarity's presentation they stood out because they were innovative. They saw what could become rather then what currently is. On that note, they deserved to win.
Conclusion
I wanted to attend this contest to not only root my co-workers on, but to continue to see what people are doing with this new technology. I even brought my fiance to give her a visual perspective of the possibilities she always hears me talk about but never sees. I am lucky as I can feed off of these guys and their expertise. Not just as developers, but designers and innovators. So Marlon, Erik, and Kevin congrats to you guys. You truly deserve it for a job well done.