<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Sergio Pereira : featured</title><link>http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx</link><description>Tags: featured</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Tim Barcz in the house, brought his keyboard</title><link>http://devlicio.us/blogs/sergio_pereira/archive/2008/08/08/tim-barcz-in-the-house.aspx</link><pubDate>Fri, 08 Aug 2008 14:14:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:41752</guid><dc:creator>sergiopereira</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;
We are adding a new contributor to &lt;a href="http://devlicio.us/"&gt;Devlicio.us&lt;/a&gt;. Join me and welcome &lt;a href="http://devlicio.us/blogs/tim_barcz/"&gt;Tim Barcz&lt;/a&gt; and his blog posts to our site.
&lt;/p&gt;
&lt;p&gt;
Tim will be another Midwest blogger, reporting from Cedar Rapids, Iowa. He is the president of the &lt;a href="http://www.crineta.org/"&gt;CRIneta&lt;/a&gt; and always involved with the local and global .NET community.
&lt;/p&gt;
&lt;p&gt;
I&amp;#39;ve met Tim at the ALT.NET Conference in Seattle earlier this year, where we had a chance to chat quite a bit. I&amp;#39;ve always liked the positive attitude of his blog and we share the same goal of finding and provoking &lt;a href="http://www.timbarcz.com/blog/2007/07/22/PassionInProgrammers.aspx"&gt;passion for software development&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Tim is moving his &lt;a href="http://www.timbarcz.com/blog/"&gt;previous blog&lt;/a&gt; over here and not a minute too soon. Welcome aboard, Tim.
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=41752" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx">featured</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Announcement/default.aspx">Announcement</category></item><item><title>Beginning Continuous Improvement, A Case Study</title><link>http://devlicio.us/blogs/sergio_pereira/archive/2008/06/27/beginning-continuous-improvement-a-case-study.aspx</link><pubDate>Fri, 27 Jun 2008 05:11:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:41098</guid><dc:creator>sergiopereira</dc:creator><slash:comments>7</slash:comments><description>&lt;p&gt;
&lt;em&gt;by: &lt;a href="http://ruprict.wordpress.com/"&gt;Glenn Goodrich&lt;/a&gt;&lt;/em&gt;
&lt;/p&gt;


This post is the winner of &lt;a href="http://devlicio.us/blogs/sergio_pereira/archive/2008/06/05/the-great-devlicio-us-giveaway.aspx"&gt;The Great Devlicio.us Giveaway&lt;/a&gt;.


&lt;p&gt;
	The story you are about to read is true. The names and identities of the innocent have been changed to protect them and my job. No animals were harmed in the writing of this story.
&lt;/p&gt;
&lt;p&gt;
	Roughly three to five years ago I was an intermediate ASP.NET Webforms developer. I had produced several applications for various clients that were in different stages of test/production/maintenance /graveyard. Some of these applications were loved by my clients, others were tolerated, and still others were abhorred. The aspects all of these applications did have in common were a high level of difficulty to maintain and an almost violent resistance to change. Most of my clients tend to generate requirements in a management bubble so during the first round of testing, (if it existed) or the first weeks stumbling through production deployment, the user feedback was very large. Of course, the client always desired make changes accommodating this feedback, which is often where my real troubles began.
&lt;/p&gt;
&lt;p&gt;
	There had to be a better way. So, I started combing the web, hoping to find people that solved issues like mine. Googling phrases like &amp;ldquo;extensibility&amp;rdquo;, &amp;ldquo;webforms pain&amp;rdquo;, and &amp;ldquo;easy asp.net deployment&amp;rdquo;. If memory serves, the first fish on the line was &lt;a href="http://www.rubyonrails.org"&gt;Rails&lt;/a&gt;. I did the Rails &amp;ldquo;Hello World&amp;rdquo; and was amazed at how fast you could get going, how easy you could add views, and how much of my nerd life I had wasted. Realizing that my clients were not quite ready for Rails (&amp;ldquo;Ruby on what??? Where&amp;rsquo;s the msi?&amp;rdquo;) I started looking for &lt;a href="http://en.wikipedia.org/wiki/Model-view-controller"&gt;MVC&lt;/a&gt; in .NET. This, as you&amp;rsquo;ve probably guessed, landed me at the &lt;a href="http://www.castleproject.org"&gt;Castle Project&lt;/a&gt;. &lt;a href="http://www.castleproject.org/MonoRail/"&gt;Monorail&lt;/a&gt; was just what I needed. I could shoehorn it past my clients&amp;rsquo; open source/never-heard-of-that worries, because it was .NET. But this was just the beginning.
&lt;/p&gt;
&lt;p&gt;
	The Castle Project also had the &lt;a href="http://www.castleproject.org/container/index.html"&gt;Windsor&lt;/a&gt; Inversion of Control (IoC) container, which led me to things like &amp;ldquo;separation of concerns&amp;rdquo;, &amp;ldquo;single responsibility&amp;rdquo;, and the &amp;ldquo;open-closed principle&amp;rdquo;. It really started me down the path of Test Driven Development (TDD) which was probably the single biggest positive change to my coding practices. It was a little bumpy at first, but once I saw that I could get all my code working before I even had a web site application AND I could really test it, I was hooked.
&lt;/p&gt;
&lt;p&gt;
	I started reading the &lt;a href="http://www.castleproject.org/community/forum.html"&gt;Castle Forums&lt;/a&gt; as well as &lt;a href="http://hammett.castleproject.org/"&gt;Hammet&amp;rsquo;s blog&lt;/a&gt; and &lt;a href="http://www.ayende.com"&gt;Ayende&amp;rsquo;s blog&lt;/a&gt;. Figuring they weren&amp;rsquo;t the only really smart people out there, I started reading tons of blogs (&lt;a href="http://www.codebetter.com"&gt;CodeBetter&lt;/a&gt;, &lt;a href="http://www.martinfowler.com/bliki/"&gt;Martin Fowler&amp;rsquo;s Bliki&lt;/a&gt;, etc.) which showed me the endless world of better design practices. I started reading books that weren&amp;rsquo;t from Microsoft Press (nothing against them, but there are a lot of good books out there) including &lt;a href="http://books.google.com/books?id=LjJcCnNf92kC"&gt;Head First Design Patterns&lt;/a&gt;, which was another huge A-HA! moment for my development career. I now read blogs everyday and have at least two books going at any moment in time. I read about &lt;a href="http://martinfowler.com/articles/continuousIntegration.html"&gt;Continuous Integration&lt;/a&gt; and &lt;a href="http://www.cifactory.org"&gt;CI Factory&lt;/a&gt;, as well as &lt;a href="http://www.hibernate.org/343.html"&gt;NHibernate&lt;/a&gt; and other OR/M frameworks. This was my first steps into Continuous Improvement.
&lt;/p&gt;
&lt;p&gt;
	So, where is this going? Is there a success story in our future? Before you object to the relevance of my opening statement, we have finally arrived at my success. We were handed a very large client from a business partner, partially because that partner could not satisfy the needs of the client. The client (who I will call BigCo) wanted a web-based application to put in front of their customer-facing employees to, basically, figure out if BigCo could provide any services to new clients. There were various factors that affected BigCo&amp;rsquo;s ability to provide services to a given customer, and the application would have to perform the logic that determined each of these factors. For this article, we will call the application ProviderApp. ProviderApp had to do the following:
&lt;/p&gt;
&lt;p&gt;
	Collect information about the customer. Find out where the customer lived. See if BigCo had the ability to provide services to that location. If the location was good, show the employee which of BigCo&amp;rsquo;s services were available. Persist the results of this interaction.
&lt;/p&gt;
&lt;p&gt;
	So, BigCo wanted a prototype. Tapping into my new approach and knowledge, I started writing tests for my (persistent ignorant!) domain model. Customer, Address, ProviderResult, and other classes were the result. All clean and responsible only for themselves and fully tested. I used separation of concerns to partition out the factors into services, being sure to use interfaces. These services were also open for extension, but closed for modification. In fact, for testing, I actually wrote test-only providers, removing the need to invoke some needed external services that would be used in production. I had all the logic for the factors written and tested, all the domain model designed and tested before I had even created a web application. Also, thanks to CI, I knew when the build was broken immediately, so bugs didn&amp;rsquo;t have a chance to get stale, causing me to have to hunt for hours or days because I didn&amp;rsquo;t know when the bug was introduced. By the time I got around to the user interface (the web application) it was simply a matter of writing my views and consuming my services. Oh, and the act of writing pure HTML views was a breath of fresh air.
&lt;/p&gt;
&lt;p&gt;
	I finished the prototype a couple of days early, so we had to time to actually perform real user tests, which I don&amp;rsquo;t think I had ever seen before. The bugs found here were relatively small but made a big difference in our demonstration of the prototype. On demo day, BigCo was very happy with the prototype. They were not wowed, they were not dazzled. Their reaction is not the success story. The success story comes from the fact that I was relaxed on demo day, confident the software was solid. I had no anxiety about getting off the beaten path, which was new for me. In fact, I let the BigCo folks drive the application at the end of the meeting and told them to show it to whomever they liked later. There is no way I would have been confident enough in my previous life to let a client demo my &amp;ldquo;prototype&amp;rdquo; code.
&lt;/p&gt;
&lt;p&gt;
	At the end of the meeting, the BigCo people asked me how long it would take to &amp;ldquo;make this real&amp;rdquo;, which is when my success story really sunk in. I realized, right there in front of them, that the application was done. My answer was a matter of days, as I did have to write new providers for a couple of the services, since they were using different back-ends then the prototype, but that was it. They also asked about some changes, a question that would have usually caused my ulcer to start. Each of their requests was a trivial change, taking me a few minutes to incorporate.
&lt;/p&gt;
&lt;p&gt;
	I remember walking out of that meeting realizing I had taken a huge step in my career. We are still doing a lot of work with BigCo, and they are a happy client. I no longer fear change, and am still continuously improving.
&lt;/p&gt;
&lt;p&gt;
	Well, I didn&amp;rsquo;t mention &lt;a href="http://www.domaindrivendesign.org/"&gt;DDD&lt;/a&gt;, because I haven&amp;rsquo;t gotten to it yet (it&amp;rsquo;s on the list, which seems to get longer all the time) but I hope you&amp;rsquo;ll consider my contribution. Either way, I had a lot of fun writing this.
&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=41098" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/.NET/default.aspx">.NET</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx">featured</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/alt.net/default.aspx">alt.net</category></item><item><title>Giveaway result</title><link>http://devlicio.us/blogs/sergio_pereira/archive/2008/06/26/giveaway-result.aspx</link><pubDate>Thu, 26 Jun 2008 17:29:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:41096</guid><dc:creator>sergiopereira</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;
We&amp;#39;ve just finished tallying up our votes for the &lt;a href="http://devlicio.us/blogs/sergio_pereira/archive/2008/06/05/the-great-devlicio-us-giveaway.aspx"&gt;Great Devlicio.us Giveaway&lt;/a&gt; 
and we are pleased to announce that the winner is &lt;a href="http://ruprict.wordpress.com/"&gt;Glenn Goodrich&lt;/a&gt;. We had enough entries to make the contest worthwhile and we decided to give prizes for every story. Everyone got one of the books in the original list and the 2nd place also got Visual Studio Team System. You see? I told you that you should tell us your story.
&lt;/p&gt;
&lt;p&gt;
Some people asked if there will be a contest where they could submit horror stories instead of success stories. Well, I&amp;#39;m considering running a contest for that, but I&amp;#39;m afraid the prize will be limited to a bag of Doritos.
&lt;/p&gt;
&lt;p&gt;
Glenn runs a very nice &lt;a href="http://ruprict.wordpress.com/"&gt;blog&lt;/a&gt; and his story, 
which will be posted here tomorrow, shows that the quest for a better way to develop
applications or, in broader terms, the constant pursuit of improvement should be in our DNA.
&lt;/p&gt;

&lt;p&gt;
I&amp;#39;ll quote from his story:
&lt;/p&gt;

&lt;blockquote&gt;
... Head First Design Patterns, which was another huge A-HA! moment 
for my development career.  I now read blogs everyday and have at least two books going at 
any moment in time. I read about Continuous Integration and CI Factory, as well as NHibernate 
and other OR/M frameworks.  This was my first steps into Continuous Improvement.
&lt;/blockquote&gt;

&lt;blockquote&gt;
...I was relaxed on demo day, confident the software was solid.  I had no anxiety about 
getting off the beaten path, which was new for me.
&lt;/blockquote&gt;

&lt;p&gt;
Congratulations to Glenn, we are very happy that the prizes are being given to 
such deserving hands. You make us proud, Glenn.
&lt;/p&gt;
&lt;p&gt;
Be sure to check back tomorrow with the full story.
&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=41096" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/.NET/default.aspx">.NET</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx">featured</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/alt.net/default.aspx">alt.net</category></item><item><title>The Great Devlicio.us Giveaway</title><link>http://devlicio.us/blogs/sergio_pereira/archive/2008/06/05/the-great-devlicio-us-giveaway.aspx</link><pubDate>Thu, 05 Jun 2008 23:02:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:40889</guid><dc:creator>sergiopereira</dc:creator><slash:comments>10</slash:comments><description>&lt;h3&gt;Because there&amp;#39;s more than one kind of hero&lt;/h3&gt;
&lt;b&gt;Update: &lt;/b&gt; The contest is now closed. We cannot accept any more entries. Wait for the winner announcement is a few days. Thanks for all the great submissions.
&lt;p&gt;
 Here&amp;#39;s your chance to win a well-deserved prize for being a good developer — and not just any prize.
Devlicio.us, with the generous support from Microsoft (via &lt;a href="http://blogs.msdn.com/somasegar/"&gt;Somasegar&lt;/a&gt;) and &lt;a href="http://www.informit.com/imprint/index.aspx?st=61085"&gt;Addison-Wesley&lt;/a&gt;, is proud to present you with a contest that will dump a truckload of goodness at your doorstep. This ultimate prize package contains the following items.
&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;&lt;b&gt;&lt;a href="http://www.informit.com/store/product.aspx?isbn=0131857258"&gt;Agile Principles, Patterns, and Practices in C#&lt;/a&gt;&lt;/b&gt;: Uncle Bob&amp;#39;s must-have work. This book needs to be part of your Agile and OOD bookshelf.&lt;/li&gt;
	&lt;li&gt;&lt;b&gt;&lt;a href="http://www.informit.com/store/product.aspx?isbn=0321125215"&gt;Domain-Driven Design: Tackling Complexity in the Heart of Software&lt;/a&gt;&lt;/b&gt;: Eric Evans describes DDD and how your software design can benefit from it.&lt;/li&gt;
	&lt;li&gt;&lt;b&gt;&lt;a href="http://www.informit.com/store/product.aspx?isbn=0321268202"&gt;Applying Domain-Driven Design and Patterns&lt;/a&gt;&lt;/b&gt;: Armed with the DDD knowlegde, now it&amp;#39;s time to let Jimmy Nilsson show us how to implement solid .NET code.&lt;/li&gt;
	&lt;li&gt;&lt;b&gt;&lt;a href="http://www.informit.com/store/product.aspx?isbn=0321127420"&gt;Patterns of Enterprise Application Architecture&lt;/a&gt;&lt;/b&gt;: In this classic, Martin Fowler lays down the law on how an enterprise application needs to be designed.&lt;/li&gt;
	&lt;li&gt;&lt;b&gt;&lt;a href="http://www.informit.com/store/product.aspx?isbn=0131177052"&gt;Working Effectively with Legacy Code&lt;/a&gt;&lt;/b&gt;: We&amp;#39;ve all been there. It&amp;#39;s hard and Michael Feathers does a great job in guiding us through the challenges and techniques to get you out of the quicksand.&lt;/li&gt;
	&lt;li&gt;&lt;b&gt;&lt;a href="http://www.informit.com/store/product.aspx?isbn=0321437381"&gt;Implementing Lean Software Development&lt;/a&gt;&lt;/b&gt;: This book by Tom and Mary Poppendieck distills practices to optimize the development process.&lt;/li&gt;
	&lt;li&gt;&lt;b&gt;&lt;a href="http://www.informit.com/store/product.aspx?isbn=020161622X"&gt;The Pragmatic Programmer: From Journeyman to Master&lt;/a&gt;&lt;/b&gt;: No list of this caliber would be complete without Andy Hunt and Dave Thomas&amp;#39; ultimate guide to developer proficiency.&lt;/li&gt;
	&lt;li&gt;&lt;b&gt;&lt;a href="http://www.buy.com/prod/microsoft-visual-studio-team-system-2008-team-suite-with-msdn-premium/q/loc/105/205852888.html" style="color:#a00;"&gt;Visual Studio 2008 Team Suite + MSDN Premium&lt;/a&gt;&lt;/b&gt;: No need for explanations here. A &lt;b&gt;$10K+&lt;/b&gt; retail value item with all you&amp;#39;ll ever need in terms of Microsoft technology.&lt;/li&gt;
&lt;/ol&gt;

&lt;p style="text-align:center;"&gt;
&lt;a href="http://www.informit.com/store/product.aspx?isbn=0131857258"&gt;&lt;img src="http://devlicious.com/blogs/sergio_pereira/2008/06/0131857258.jpg" border="0" alt="" /&gt;&lt;/a&gt;
&lt;a href="http://www.informit.com/store/product.aspx?isbn=0321125215"&gt;&lt;img src="http://devlicious.com/blogs/sergio_pereira/2008/06/0321125215.jpg" border="0" alt="" /&gt;&lt;/a&gt;
&lt;a href="http://www.informit.com/store/product.aspx?isbn=0321268202"&gt;&lt;img src="http://devlicious.com/blogs/sergio_pereira/2008/06/0321268202.jpg" border="0" alt="" /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;a href="http://www.informit.com/store/product.aspx?isbn=0321127420"&gt;&lt;img src="http://devlicious.com/blogs/sergio_pereira/2008/06/0321127420.jpg" border="0" alt="" /&gt;&lt;/a&gt;
&lt;a href="http://www.informit.com/store/product.aspx?isbn=0131177052"&gt;&lt;img src="http://devlicious.com/blogs/sergio_pereira/2008/06/0131177052.jpg" border="0" alt="" /&gt;&lt;/a&gt;
&lt;a href="http://www.informit.com/store/product.aspx?isbn=0321437381"&gt;&lt;img src="http://devlicious.com/blogs/sergio_pereira/2008/06/0321437381.jpg" border="0" alt="" /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;a href="http://www.informit.com/store/product.aspx?isbn=020161622X"&gt;&lt;img src="http://devlicious.com/blogs/sergio_pereira/2008/06/020161622X.jpg" border="0" alt="" /&gt;&lt;/a&gt;
&lt;a href="http://www.buy.com/prod/microsoft-visual-studio-team-system-2008-team-suite-with-msdn-premium/q/loc/105/205852888.html"&gt;&lt;img src="http://devlicious.com/blogs/sergio_pereira/2008/06/205852888.jpg" border="0" alt="" /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;h3&gt;The Contest&lt;/h3&gt;
&lt;p&gt;
I hope the prizes got you excited. I actually envy you because I cannot participate. The contest is pretty simple.
&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;
		We are looking for success stories. Submit a true story that happened to you or your team where adopting good software development practices rescued a project or even the entire organization. The stories we want to award are
		the ones that demonstrate a direct relation between good practices or good design (or both) and successful solutions. Examples:
		&lt;ul&gt;
			&lt;li&gt;Continuous Integration saved my job.&lt;/li&gt;
			&lt;li&gt;DDD made my application survive the test of time.&lt;/li&gt;
			&lt;li&gt;My team went from grumpy to engaged after we introduced collective design ownership.&lt;/li&gt;
			&lt;li&gt;etc...&lt;/li&gt;
		&lt;/ul&gt;

	&lt;/li&gt;
	&lt;li&gt;
		Submit your stories by email or using the &lt;i&gt;Contact&lt;/i&gt; link to any of the Devlicio.us bloggers 
		between today (&lt;i&gt;June 5th 2008&lt;/i&gt;) and ~2 weeks from today (&lt;i&gt;June 20th 2008&lt;/i&gt; by 5 PM ET GMT-4:00).
	&lt;/li&gt;
	&lt;li&gt;
		The winner will be chosen by voting among the Devlicio.us bloggers. This might take up to 1 week.
	&lt;/li&gt;
	&lt;li&gt;
		The winner story will be announced on Devlicio.us on or before &lt;b&gt;June 20th&lt;/b&gt; and &lt;i&gt;it will become a guest blog post&lt;/i&gt; on the blog to which it was submitted (so remember to protect the innocent in your story.)
	&lt;/li&gt;
	&lt;li&gt;
		Shortly after that, the winner will be contacted for mailing address information and the prize will be shipped.
	&lt;/li&gt;
	&lt;li&gt;
		Other stories might be selected to feature as blog posts as well - with or without any prizes.
	&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Restrictions&lt;/h3&gt;
&lt;p&gt;
The stories need to be of your own personal experience, within your team or your organization. Since the story has a chance of being posted in Devlicio.us, make sure the people and organizations mentioned in the story are OK with that or replace their names.
&lt;/p&gt;
&lt;p&gt;
We think we can ship the prize anywhere but if you&amp;#39;re not in the U.S. and there&amp;#39;s some form of export or import regulation that prohibits the shipment of software or even the books, then we may not be able to send it to you.
&lt;/p&gt;

&lt;h3&gt;Get to the writing already&lt;/h3&gt;
&lt;p&gt;
We are anxious to hear your stories. Prizes like these don&amp;#39;t come by often and we really want to reward someone for doing the right thing.
&lt;/p&gt;


&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=40889" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/.NET/default.aspx">.NET</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx">featured</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/book/default.aspx">book</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Announcement/default.aspx">Announcement</category></item><item><title>Designing With Lambdas - Part III</title><link>http://devlicio.us/blogs/sergio_pereira/archive/2008/04/29/designing-with-lambdas-part-iii.aspx</link><pubDate>Tue, 29 Apr 2008 19:30:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:40267</guid><dc:creator>sergiopereira</dc:creator><slash:comments>5</slash:comments><description>&lt;p&gt;
In the previous two installments of the series we discussed how we can use lambdas to &lt;a href="http://devlicio.us/blogs/sergio_pereira/archive/2008/04/12/designing-with-lambdas-part-i.aspx"&gt;encapsulate more processing logic&lt;/a&gt; and to &lt;a href="http://devlicio.us/blogs/sergio_pereira/archive/2008/04/14/designing-with-lambdas-part-ii.aspx"&gt;create contextual APIs&lt;/a&gt;. In this post I will show another example of the latter.
&lt;/p&gt;

&lt;h3&gt;Navigating directory structures&lt;/h3&gt;

&lt;p&gt;
This time around we will try to create a safe way to browse and create directories without losing track of the current location. When we write code to read files or directory information from a directory structure, and we need to look into more than one directory, we have to be careful to always be sure of what the current working directory is or use only absolute paths. Neither approach is without its inconveniences. 
&lt;/p&gt;

&lt;p&gt;
What I&amp;#39;ll try to show here is a way to enforce the working directory as a lambda context. That can be a mouthful so let me try to put it in simpler terms. I&amp;#39;d like to have a way to assert that when a particular code runs, the working directory will be changed to a specified location, and after that code finishes the working directory is restored automatically.
&lt;/p&gt;

&lt;p&gt;
Without lambdas, the context setting could resemble the following:
&lt;/p&gt;

&lt;pre name="code" class="c-sharp"&gt;string previousDir = Environment.CurrentDirectory;
try
{
	Environment.CurrentDirectory = @&amp;quot;c:\myapp&amp;quot;;
	DoStuff();

	try
	{
		Environment.CurrentDirectory = 
				@&amp;quot;c:\myapp\subdirs\resources\images\toolbar&amp;quot;;
		DoOtherStuff();
	}
	finally
	{
		Environment.CurrentDirectory = @&amp;quot;c:\myapp&amp;quot;;
	}

	DoMoreStuff();
}
finally
{
	Environment.CurrentDirectory = previousDir;
}&lt;/pre&gt;
	
&lt;p&gt;
All those &lt;code&gt;try&lt;/code&gt; and &lt;code&gt;finally&lt;/code&gt; are there to make sure we restore the appropriate working directory after we are done with each one. I don&amp;#39;t know about you, but having a lot of those in my code would add a lot of noise, obscuring the real intent of the code. 
&lt;/p&gt;

&lt;p&gt;
What if we could, once again, encapsulate this pattern in a function that accepts a delegate? Here&amp;#39;s what a way more revealing code would look like.
&lt;/p&gt;

&lt;pre name="code" class="c-sharp"&gt;Dir.Change(@&amp;quot;c:\myapp&amp;quot;, path =&amp;gt;
{
	//we&amp;#39;re in c:\myapp
	Dir.Change(subdir =&amp;gt;
	{
		//we&amp;#39;re in c:\myapp\subdir
		string dirName = DateTime.Now.ToString(&amp;quot;yyyy-MM-dd&amp;quot;);
		//we can ask it to create the directory if 
		//  not found (the &amp;quot;true&amp;quot; parameter)
		Dir.Change(dirName, true, dailyLogDir =&amp;gt;
		{
			//we&amp;#39;re in c:\myapp\subdir\2008-04-29 (for example)
			using(StreamWriter wr = File.CreateText(&amp;quot;logfile.txt&amp;quot;))
			{
				wr.WriteLine(&amp;quot;Hello file.&amp;quot;);
			}
		});

		//we&amp;#39;re back in c:\myapp\subdir

		//we can pass in a deeper path
		Dir.Change(@&amp;quot;resources\images\toolbar&amp;quot;, imagesDir =&amp;gt;
		{
			//we&amp;#39;re in c:\myapp\subdir\resources\images\toolbar
			//listing all files here
			foreach(string file in imagesDir.GetFiles(&amp;quot;*.png&amp;quot;))
				Console.WriteLine(&amp;quot;Toolbar icon: &amp;quot; + file);

		});
	});
});&lt;/pre&gt;

&lt;p&gt;
Within each &lt;code&gt;Dir.Change&lt;/code&gt; &lt;em&gt;block&lt;/em&gt; we can be certain that the current working directory will be the one we specified (unless your own code intentionally changes it.) When the code block finishes, we will be back to whatever directory we were before the block, guaranteed.
&lt;/p&gt;

&lt;p&gt;
Note in line 4 that the name of the directory can be gathered from the parameter&amp;#39;s name &lt;code&gt;subdir&lt;/code&gt;. This is not always possible because we could be dealing with multi-level directory changes (line 22) or dynamically generated directory names (line 10). Additionally, the rules for naming directories are not the same as for naming C# identifiers. For these reasons, it&amp;#39;s also possible to pass a string containing the name of the desired directory.
&lt;/p&gt;

&lt;p&gt;
Here&amp;#39;s the code that makes this possible.
&lt;/p&gt;

&lt;pre name="code" class="c-sharp"&gt;public static class Dir
{
	public static void Change(Action&amp;lt;DirectoryInfo&amp;gt; execute)
	{
		Change(false, execute);
	}

	public static void Change(string path, Action&amp;lt;DirectoryInfo&amp;gt; execute)
	{
		Change(path, false, execute);
	}

	public static void Change(bool createIfNeeded, Action&amp;lt;DirectoryInfo&amp;gt; execute)
	{
		string path = execute.Method.GetParameters()[0].Name;
		Change(path, createIfNeeded, execute);
	}

	public static void Change(string path, bool createIfNeeded, 
							Action&amp;lt;DirectoryInfo&amp;gt; execute)
	{
		string previousDir = Environment.CurrentDirectory;

		try
		{
			if(createIfNeeded &amp;amp;&amp;amp; !Directory.Exists(path))
				Directory.CreateDirectory(path);

			var di = new DirectoryInfo(path);
			Environment.CurrentDirectory = path;
			execute(di);
		}
		finally
		{
			Environment.CurrentDirectory = previousDir;
		}
	}

	public static bool TryChange(string path, Action&amp;lt;DirectoryInfo&amp;gt; execute)
	{
		if(Directory.Exists(path))
		{
			Change(path, false, execute);
			return true;
		}
		else
		{
			return false;
		}
	}
}&lt;/pre&gt;

&lt;p&gt;
So there you have it. Another example of incorporating lambdas to design APIs that attempt to reduce code noise and eventually read more naturally. Hopefully you&amp;#39;re starting to see a pattern here in terms of what a context can be and how lambda-aware APIs can help formalizing that context.
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=40267" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/.NET/default.aspx">.NET</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx">featured</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Series/default.aspx">Series</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Designing-With-Lambdas/default.aspx">Designing-With-Lambdas</category></item><item><title>Redmond, the center of the ALT.NET universe</title><link>http://devlicio.us/blogs/sergio_pereira/archive/2008/04/17/redmond-the-center-of-the-alt-net-universe.aspx</link><pubDate>Thu, 17 Apr 2008 14:12:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:40118</guid><dc:creator>sergiopereira</dc:creator><slash:comments>0</slash:comments><description>&lt;h2&gt;...at least for the next three days&lt;/h2&gt;

&lt;p&gt;
Tomorrow I&amp;#39;m hopping on a plane to Seattle/Redmond, WA to take part in &lt;a href="http://altdotnet.org/events/seattle"&gt;the second ALT.NET Open Spaces Conference&lt;/a&gt;. I had the chance to be at the first one last October in Austin, TX and what a great experience that was.
&lt;/p&gt;

&lt;p&gt;
My main motivation to attend the event in Austin was to learn from the more experienced folks how they adopted these practices and culture in their organizations. I wanted to participate in discussion about creating interest in self-improvement in my organization, my local .Net community, and eventually in the global .Net ecosystem.
&lt;/p&gt;

&lt;p&gt;
The sessions I took part in included mostly these topics, like how can we help MSDN and MSDN Magazine become a great vehicle for spreading into the .Net community, among other things, practices that go beyond what Visual Studio shows in its &lt;em&gt;Add &amp;raquo; New Item&lt;/em&gt;, and the lessons that we can learn from the non-.Net space. The &lt;a href="http://msdn2.microsoft.com/en-us/magazine/cc301916.aspx"&gt;March 2008&lt;/a&gt; issue of the magazine was a glimpse at what types of techniques and tools we could be seeing applied by more .Net developers, helping create more maintainable applications and more scalable development and support processes.
&lt;/p&gt;

&lt;p&gt;
This time around I&amp;#39;m hoping to be in discussions that are more specific of Agile processes. I want to understand how to get started and how demonstrable Agile value really is. I&amp;#39;m tired of reading from people that quickly attached themselves to the Agile label just because it looks like the thing to do at the moment. I, for one have never experienced Agile in any organization I worked at. This event will give us a great opportunity to hear and question some of the people that are really employing Agile and experiencing some form of benefit from it. I want to make sure Agile isn&amp;#39;t just another bandwagon.
&lt;/p&gt;

&lt;p&gt;
There&amp;#39;s always the risk that events like this become the proverbial echo chamber, where folks that think alike tap each other&amp;#39;s back, celebrate their common thinking, and waste time discussion irrelevant technicalities. I&amp;#39;m happy to see a lot of blue badges and even people that I&amp;#39;m sure will be there to challenge ALT.NET to put up or shut up. One such individual is &lt;a href="http://www.blogcoward.com/archive/2008/04/15/ALT.NET-Open-Spaces-Seattle-Conference.aspx"&gt;JDN&lt;/a&gt; &amp;mdash; if you read the &lt;a&gt;altdotnet mailing list&lt;/a&gt; you&amp;#39;re familiar with his point of view. I think that is a good thing.
&lt;/p&gt;

&lt;p&gt;
So, if you happen to be there too and see me, come and talk. That&amp;#39;s why we are there for, right. And I&amp;#39;m not one of these guys that can only talk about software. I could spend hours chatting about other things like soccer and .... and ... darn it! Nevermind :)
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=40118" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/.NET/default.aspx">.NET</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx">featured</category></item><item><title>Designing With Lambdas - Part I</title><link>http://devlicio.us/blogs/sergio_pereira/archive/2008/04/12/designing-with-lambdas-part-i.aspx</link><pubDate>Sat, 12 Apr 2008 21:25:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:40047</guid><dc:creator>sergiopereira</dc:creator><slash:comments>12</slash:comments><description>&lt;p&gt;
When our programming language of choice gets a new feature, it&amp;#39;s usually not that hard to start using that feature right away from a consumer&amp;#39;s point of view.
&lt;/p&gt;
&lt;p&gt;
I could use the introduction of generics in .Net 2.0 as an example. When I wrote my first C# 2.0 piece of code, it already made use of the existing generic classes and methods, especially the ones in the &lt;code&gt;System.Collections.Generic&lt;/code&gt; namespace such as &lt;code&gt;List&amp;lt;T&amp;gt;&lt;/code&gt; and &lt;code&gt;Dictionary&amp;lt;TKey,TValue&amp;gt;&lt;/code&gt;. 
&lt;/p&gt;
&lt;p&gt;
But it took a little more time until I learned how to design my own classes offering generic functionality. Reaching the balance of when to create generic classes, when to create generic methods, or when not to use generics only comes with some exercise.
&lt;/p&gt;
&lt;p&gt;
I think this will be the case with &lt;em&gt;lambdas&lt;/em&gt; for many people, including myself. Detecting opportunities to apply lambdas can make all the difference between a class that is a joy to use and one that is just the same old thing.
&lt;/p&gt;

&lt;h3&gt;Processing lines in a file&lt;/h3&gt;

&lt;p&gt;
My first example will be a more concise and less error-prone way of processing lines in a text file. Consider this hopefully familiar piece of code.
&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;using(StreamReader rd = File.OpenText(&amp;quot;Data.txt&amp;quot;))
{
	string line = rd.ReadLine();
	while(line != null)
	{
		DoSomething(line);
		// do more stuff with the line text

		//move on
		line = rd.ReadLine();
	}
}&lt;/pre&gt;

&lt;p&gt;
How many times have you written something like this over and over? I know I did. If I were to compare the various times I implemented this, I would probably notice that &lt;strong&gt;the only thing that is different is the logic&lt;/strong&gt; inside the &lt;code&gt;while&lt;/code&gt; block. This should be a clue that a delegate or lambda could help make this pattern reusable.
&lt;/p&gt;
&lt;p&gt;
But how do we create a reusable method that performs this common task without providing the logic inside the &lt;code&gt;while&lt;/code&gt;? The last paragraph gave away the answer: &lt;strong&gt;delegates&lt;/strong&gt;.
&lt;/p&gt;
&lt;p&gt;
Let&amp;#39;s create a helper class with a method to encapsulate the pattern at hand.
&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public static class FileUtil
{
	public static void EachLine(string fileName, Action&amp;lt;string&amp;gt; process)
	{
		using(StreamReader rd = File.OpenText(fileName))
		{
			string line = rd.ReadLine();
			while(line != null)
			{
				process(line);
				line = rd.ReadLine();
			}
		}
	}
}&lt;/pre&gt;

&lt;p&gt;
The body of the &lt;code&gt;EachLine&lt;/code&gt; method is almost the same as the original implementation we started with. The difference, as expected, is that we replaced the &lt;code&gt;DoSomething(line)&lt;/code&gt; with a call to &lt;code&gt;process&lt;/code&gt;, which is a delegate of type &lt;code&gt;Action&amp;lt;string&amp;gt;&lt;/code&gt;, meaning that it expects a function that accepts a single parameter of type &lt;code&gt;string&lt;/code&gt; and does not have a return value.
&lt;/p&gt;
&lt;p&gt;
Using our new method, we can rewrite the original example like this.
&lt;/p&gt;

&lt;pre class="c-sharp:nogutter:nocontrols" name="code"&gt;FileUtil.EachLine(&amp;quot;Data.txt&amp;quot;, line =&amp;gt; DoSomething(line));&lt;/pre&gt;

&lt;p&gt;
Not bad. In this particular case, because we are just forwarding the &lt;code&gt;line&lt;/code&gt; parameter to &lt;code&gt;DoSomething&lt;/code&gt;, the call can be further simplified taking advantage of C#&amp;#39;s new shortened delegate creation syntax.
&lt;/p&gt;

&lt;pre class="c-sharp:nogutter:nocontrols" name="code"&gt;FileUtil.EachLine(&amp;quot;Data.txt&amp;quot;, DoSomething );&lt;/pre&gt;

&lt;p&gt;
There you have it. Hopefully this assists someone in their journey in this new lambda thing.
&lt;/p&gt;
 &lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=40047" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/.NET/default.aspx">.NET</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx">featured</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Series/default.aspx">Series</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Designing-With-Lambdas/default.aspx">Designing-With-Lambdas</category></item><item><title>Automation FTW</title><link>http://devlicio.us/blogs/sergio_pereira/archive/2008/03/27/automation-ftw.aspx</link><pubDate>Fri, 28 Mar 2008 01:12:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:39836</guid><dc:creator>sergiopereira</dc:creator><slash:comments>4</slash:comments><description>&lt;p&gt;
One of the things I often discuss with other developers is how little (on average) we automate our work-related tasks.
&lt;/p&gt;
&lt;p&gt;
Think about this. We make our living automating our users&amp;#39; activities:
&lt;/p&gt;

&lt;ul&gt;
	
&lt;li&gt;We write applications to replace manual processes.&lt;/li&gt;
 
	
&lt;li&gt;Our programs send notifications so that they users don&amp;#39;t need to waste time checking for process status.&lt;/li&gt;
	
&lt;li&gt;We make our programs talk to each other and to third party systems so that the slow and expensive human interaction is avoided,&lt;/li&gt;
	
&lt;li&gt;In more general terms, we go through great lengths to ensure our users are adequately empowered and hopefully more productive.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Contrast that to the way we historically see developers conducting their daily chores.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We often work with incredibly powerful IDEs or text editors with macro support or even an extensibility model. When was the last time you employed a macro?&lt;/li&gt;
	
&lt;li&gt;How many times will that manager will have to send you that updated Excel spreadsheet or CSV file until you write a script to verify each line instead of the tiresome and error-prone manual check you have been doing?&lt;/li&gt;
	
&lt;li&gt;Aren&amp;#39;t you tired of keeping track of which files changed since last time you updated the application? Have you ever thought your Source Control Management tool could make this much simpler?&lt;/li&gt;
	
&lt;li&gt;Are you kidding me? You&amp;#39;re writing that same SQL query for the Nth time? How hard is to save this query for a change?&lt;/li&gt;
	
&lt;li&gt;If your work cycle looks like this: &lt;i&gt;Save, Build (wait), Debug (wait), Click, Click, Click, Type, Type, Click, Verify result, OK&lt;/i&gt;;&amp;nbsp; someone needs to introduce you to a unit testing tool immediately.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
I&amp;#39;m as guilty as the next guy of falling in one of the the above anti-patterns. The way I found to make these traps the exception, not the norm, was to make them less comfortable than the automated alternative. The key in the entire process is lowering the automation entry barrier by learning. It also helps if you cultivate a positive attitude toward learning. 
&lt;/p&gt;
&lt;p&gt;
Here&amp;#39;s my laundry list of steps to make those CPU cores earn their salt and leave my own processing power for more challenging things. I have some of these items pegged but I&amp;#39;m not done with all of them yet.
&lt;/p&gt;

&lt;ul&gt;
	
&lt;li&gt;Take the time to explore and learn the capabilities of your IDE/text editor. Find a cheat sheet and  print it. Learn one or two interesting keyboard shortcuts every day. Learn how to write/record a macro, it&amp;#39;s usually so easy that you&amp;#39;ll be ashamed you hadn&amp;#39;t done that before. Some tools even have strong user communities sharing macros. See how your IDE can be extended, if it&amp;#39;s beyond your reach, maybe there are third party productivity add-ons that will boost your productivity and pay for themselves quickly (if not already free.)&lt;/li&gt;
	
&lt;li&gt;Other applications, like MS Office apps, also have a rich extensibility and automation model behind them. If that application insists in being part of your workflow, investigate how you can show it who the boss is.&lt;/li&gt;
	
&lt;li&gt;One of the best things I&amp;#39;ve done in the recent years was to add a scripting language to my toolbox. I highly recommend that. If possible pick a scripting language that is reasonably different from your primary development language, it will make the learning phase more interesting. I&amp;#39;m currently working with C#, so I thought &lt;a href="http://www.ruby-lang.org/"&gt;Ruby&lt;/a&gt; would be an interesting language for scripting tasks, and that&amp;#39;s what I use most of the time.&lt;/li&gt;
	
&lt;li&gt;Be adamant about using your SCM as part of your deployment process. Learn how to do labeling/tagging, diffs, updates, etc not only using the GUI but also through an API or the command line. You&amp;#39;ll be writing scripts against your SCM in no time and the weight of tracking changed files will be lifted.&lt;/li&gt;
	
&lt;li&gt;I tend to include a &lt;i&gt;tools&lt;/i&gt; directory within each project directory structure where I keep (among other things) all the scripts I create to assist development and maintenance of the application. These files can be SQL scripts, Ruby scripts, .bat files, and anything that can be repeatedly executed. Some scripts turn out to be generic enough that I keep them in a common location, such as &lt;i&gt;c:\projetcs\tools.&lt;/i&gt;&lt;/li&gt;
 
	
&lt;li&gt;I won&amp;#39;t attempt to get yo hooked on TDD or Continuous Integration here, that&amp;#39;s something for another day. I will say, though, that if you don&amp;#39;t already use an automated unit testing framework, you owe yourself a closer look into that. Why write several test applications or run the entire application all the time to manually verify that everything still works when there are tools to automate this? Take a look at &lt;a href="http://www.junit.org/"&gt;JUnit&lt;/a&gt;/&lt;a href="http://www.nunit.org/"&gt;NUnit&lt;/a&gt; (the xUnit family), &lt;a href="http://rspec.info/"&gt;RSpec&lt;/a&gt; or whatever there is in your language of choice.&lt;/li&gt;
 
	
&lt;li&gt;No text about software development automation would be complete without at least mentioning build automation tools. Tools like &lt;a href="http://ant.apache.org/"&gt;Ant&lt;/a&gt; (&lt;a href="http://nant.sourceforge.net/"&gt;NAnt&lt;/a&gt;), &lt;a href="http://msdn2.microsoft.com/en-us/library/0k6kkbsd.aspx"&gt;MSBuild&lt;/a&gt;, &lt;a href="http://www.gnu.org/software/make/"&gt;Make&lt;/a&gt;, &lt;a href="http://rake.rubyforge.org/"&gt;Rake&lt;/a&gt; go a long way toward providing complete solutions for automating the build, testing, packaging/deploying of an application. Very few things are more satisfying than executing go.bat and seeing your application being compiled, configured, and tested in a fraction of the time that it used to take when you did all this manually.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
As many things in life, the hardest part is getting started. Once you have your first one or two tasks automated, you will be more aware of tasks that can be automated and you will be more confident that you can indeed automate this task that you were just about to start for the second time.
&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=39836" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Tools/default.aspx">Tools</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/sergio_pereira/archive/tags/featured/default.aspx">featured</category></item></channel></rss>