Code the Town! Investing in the next generation of programmers in Austin, TX

Code the TownAustin, TX is a hot-bed for technology.  You can find a user group for just about any technology and purpose meeting almost any day of the week.

And now, there is a group that intersects with giving back to the community and helping the next generation of programmers.  Code the Town is a group that does just that. Clear Measure, and other companies, are sponsors of the group.  The official description is:

“This is a group for anyone interested in volunteering to teach Hour of Code https://hourofcode.com/us in the Austin and surrounding area school districts. The goal is to get community volunteers to give the age appropriate Hour of Code to every student at every grade level. We want to have our own community prepare students for a technology-based workforce. We also want to build a community of professionals and students that have a passion for coding and teaching. We want to begin the Hour of Code in the high schools first. High school students would then be prepared to teach the younger students.  Once this group has momentum, it will be able to form motivated teams and use software projects done for local non-profit organizations to not only reinvest in our community but also to help our youth gain experience in software engineering.  Whether you are a student, parent, educator, or software professional, please join our Meet Up! This will be fun! And it will have a profound impact on the next generation.”

The long term vision is to create a sustainable community of professionals, educators, parents, and students that continually gives back to local community organizations through computers and technology while continually pulling the next generation of students into computer programming.
Simple codeIt all starts with some volunteers to teach students the basics of computer programming.  In the 1990s, the web changed the world.  Now, we have hand-held smartphones and other devices (TVs, bathroom scales, etc) that are connected to computer systems via the internet.  In the next decade, almost every machine will be connected to computer systems, and robotics will be a merging between mechanical engineering and computer science.  Those who know how to write computer code will have a big advantage in the workforce where the divide between those who build/create and those who service what is created might get bigger than it already has.
BlocklyCode the Town will focus on introducing students to computer programming and then pull them together with their parents, their teachers, and willing community professionals to work on real software projects for local non-profits.  In this fashion, everyone gets something.  Everyone gives something, and everyone benefits.  If you are interested in this vision, please come to the first meeting of Code the Town by signing up for the Meetup group.

What are the Alt.Net principles? – my answer

I’ll be attending the AltNetConf.  Convenient for me that it’s in Austin, TX.  It’s an open space conference, and I consider it the founding conference of a conversation that is “Alt.Net”.  I’ll be proposing the topic: What are the Alt.Net principles?.

The definition of Alt.Net isn’t defined yet.  It’s not even at a point where I can explain what it is and actually have other agree with me.  

Since I know the guy who originally coined the term, I have some insight into what David meant, but I’m going to propose some principles that, together, should be the definition of Alt.Net.

First, Alt.Net inherits Agile, and IS Agile.  Therefore:

  • Individuals and interactions over processes and tools
  • Working software over comprehensive documentation
  • Customer collaboration over contract negotiation
  • Responding to change over following a plan 

Extended principles:

  • Excellence and quality
    In a world of wizard-generated, disposable software (disposed 2 years later by necessity, not choice), Alt.Net focuses us on excellence in the software we create.  While the world may pay for and accept software that lives for 2 years before becoming utterly unmaintainable, we don’t accept shoddy work.  We know that we can deliver high quality software faster than others can deliver low quality software, so we accept no less than the highest in quality.  We strive for excellence through solid engineering practices and a high level of software education.  Coincidentally, Extreme Programming helps in this area, but Alt.Net does not specifically _mean_ XP.
  • Alternative Vendors
    A  common theme in many .Net shops is they are “Microsoft” shops.  In other words, if it doesn’t come from Microsoft, they won’t use it.  This makes no sense.  Microsoft is not a large enough company to be the vendor to the whole world.  .Net is a great platform, and we as a community have chosen the platform and choose to participate in this segment of the industry.  We strongly believe that 3rd party vendors complement the .Net platform in a way that can contribute to excellent working software.  In fact, some 3rd party offerings are superior to Microsoft’s offering.  For instance, in a strive for excellence in an e-commerce website, a team may choose a mature O/R Mapper like NHibernate to accelerate team speed and produce a flexible data layer; however, Alt.Net does not _mean_ ORM.  Open source software is a source of excellent 3rd party alternatives built on the .Net platform, and it should be used over Microsoft alternatives when they contribute to excellence; however, Alt.Net does not _mean_ open source.
  • Joy in our work
    We know that we will produce better software if a team is motivated and morale is high; therefore, we use libraries, tools, and practices that add joy to the working environment.  We abandon or correct libraries, tools, and practices that make it a drag to work on the software.  For instance, many find that Visual Studio is a bit slow to work with and that adding Resharper to the IDE adds a high level of joy while working with .Net code; however, Alt.Net does not _mean_ Resharper.
  • Knowledge
    We know that we will never know everything there is to know.  We strive for a greater understanding of software through studying successes and failures of the past as well as the present.  We educate ourselves through many sources in order to bring the most value to our clients.  We keep up with other platforms, such as Java and Ruby, so that we can apply their good ideas to .Net development and increase the quality of our .Net software.  The technology is always changing, but the knowledge accumulates.  We know that the knowledge applies no matter how the technology changes.  With knowledge comes humility because without humility, knowledge would pass us by.

The above are principles, so they are intentionally abstract.  Below, I’ll list some items that are concrete.  These items apply the principles but are more directly applicable:

  • Read more than just MSDN magazine and MS Press.  Authors like Feathers, Fowler, Martin, Evans, etc have a lot to give (Knowledge)
  • Use Resharper.  It makes working with Visual Studio a (Joy).  But if another vendor comes along that does even better than JetBrains, consider switching
  • Use NUnit  over MSTest,  Subversion over TFS SCC,  Infragistics/Telerik over in-the-box controls,  RedGate over in-the-box SQL tools.  Each of these is a better alternative to that which Microsoft provides (Alternative Vendors).  Use NHibernate over hand-rolled stored procedures and especially over DataAdapter/DataSet, but if EntityFramework proves to actually be superior to NHibernate in a meaningful way, consider using it.
  • Use a responsible application architecture.  Don’t put everything in Page_Load like you see demonstrated at MSDN Events.  Use knowledge to create an application that can stand the test of time and not be rewritten every 2 years.  Deliver (high quality and excellence). 
  • Automate every repetitive task; builds, tests, deployments, etc – excellence and joy

The concrete examples could go on and on, and I hope AltNetConf produces a long list.  I’ll be interested in having my proposed principles accepted by the community there or revised into something better.  Either way, I’d like to get to a point where there is an accepted definition of Alt.Net.

Arcast – The Agile Architect podcast now online

 http://channel9.msdn.com/ShowPost.aspx?PostID=322781

The above is a link to an Arcast episode where I had a conversation with Ron Jacobs about what an Agile Architect is.  Give it a listen and tell me what you thought.  My basic point (beyond introducing Agile for those not familiar) was that the architect on an agile team is the guys who looks ahead beyond the current iteration.  I mostly agree with Sam Gentile as he outlines his views here

Published! My current podcast list – level 200

 I’ve had numerous requests to publish my podcast list, so here it is.  Here is what I listen to on my commute to and from client sites or, in the case of this month, to and from a buddy’s wedding several states away.

 

http://polymorphicpodcast.com/podcast/feed/
http://channel9.msdn.com/rss.aspx?ForumID=34&Mode=0&sortby=0&sortorder=1&format=mp3
http://www.hanselminutes.com/hanselminutes_MP3Direct.xml
http://www.dotnetrocks.com/DotNetRocks_FullMP3.xml
http://www.slashdotreview.com/wp-rss2.php
http://www.se-radio.net/rss
http://feeds.feedburner.com/javaposse
http://feeds.feedburner.com/DrNeilsNotes
http://agiletoolkit.libsyn.com/rss
http://syndication.sdmediagroup.com/feeds/public/cmp_podcast_udi.xml
http://feeds.gigavox.com/gigavox/channel/itconversations
http://www.trinitydigitalmedia.com/tnb.xml
http://www.oneminutetip.com/feed.xml
http://www.runasradio.com/runasradio_FullMp3.xml
http://feeds.feedburner.com/NetObjectivesPodcast_LAST

 

In case you’d rather import the OPML, here it is in its entirety:

  <?xml
version=”1.0″ encoding=”utf-8″
?>
<opml version=”1.1>
<head>
  <title>iPodder Exported Subscriptions</title>
  <dateCreated>Tue, 08 May 2007 Central Daylight
Time
</dateCreated>
  </head>
<body>
<outline text=”iPodder Exported Subscriptions>
  <outline text=”Polymorphic Podcast
title
=”Polymorphic Podcast type=”rss xmlUrl=”http://polymorphicpodcast.com/podcast/feed/ />
  <outline text=”Channel 9: Podcasts
title
=”Channel 9: Podcasts type=”rss xmlUrl=”http://channel9.msdn.com/rss.aspx?ForumID=34&Mode=0&sortby=0&sortorder=1&format=mp3 />
  <outline text=”Hanselminutes
title
=”Hanselminutes type=”rss xmlUrl=”http://www.hanselminutes.com/hanselminutes_MP3Direct.xml />
  <outline text=”.NET Rocks!
title
=”.NET Rocks! type=”rss xmlUrl=”http://www.dotnetrocks.com/DotNetRocks_FullMP3.xml />
  <outline text=”Slashdot Review
title
=”Slashdot Review type=”rss xmlUrl=”http://www.slashdotreview.com/wp-rss2.php />
  <outline text=”Software Engineering Radio title=”Software Engineering
Radio
type=”rss
xmlUrl
=”http://www.se-radio.net/rss />
  <outline text=”Agile Toolkit Podcast title=”Agile Toolkit Podcast type=”rss xmlUrl=”http://agiletoolkit.libsyn.com/rss />
  <outline text=”The Java Posse
title
=”The Java Posse type=”rss xmlUrl=”http://feeds.feedburner.com/javaposse />
  <outline text=”Dr. Neil’s Notes
title
=”Dr. Neil’s Notes type=”rss xmlUrl=”http://feeds.feedburner.com/DrNeilsNotes />
  <outline text=”Dr. Dobb’s Ask Udi Podcast title=”Dr. Dobb’s Ask Udi
Podcast
type=”rss
xmlUrl
=”http://syndication.sdmediagroup.com/feeds/public/cmp_podcast_udi.xml />
  <outline text=”IT Conversations
title
=”IT Conversations type=”rss xmlUrl=”http://feeds.gigavox.com/gigavox/channel/itconversations />
  <outline text=”Tech, No Babel
title
=”Tech, No Babel type=”rss xmlUrl=”http://www.trinitydigitalmedia.com/tnb.xml />
  <outline text=”One Minute Tip
title
=”One Minute Tip type=”rss xmlUrl=”http://www.oneminutetip.com/feed.xml />
  <outline text=”RunAs Radio FullMP3
title
=”RunAs Radio FullMP3 type=”rss xmlUrl=”http://www.runasradio.com/runasradio_FullMp3.xml />
  <outline text=”Lean Agile Straight Talk podcast title=”Lean Agile
Straight Talk podcast
type=”rss
xmlUrl
=”http://feeds.feedburner.com/NetObjectivesPodcast_LAST />
  </outline>
  </body>
  </opml>

 

 

 

Results of a SOLID pair-programming day – level 200

There it is.  A pile of ripped up note cards denoting all the engineering tasks completed by my pair.  This was an unusual day because it started at 7:30am with some white board modeling and brain-crunching a very, very tough problem.  We wrote out some tasks to get us started, and we played the TDD game.   It was such a tough problem that neither my pair partner nor I could imagine the complete solution, but we could imagine a few things that would be included.  We wrote down the items to do on note cards and ordered them.  The navigator manned the note card deck.  In the course of completing some of the engineering tasks (all part of the same story), we uncovered new tasks that needed to be done.  We wrote those down and added them to the bottom of the pile.  We also ran into a brick wall and had to stop to do another task before we could continue.  We wrote that down and added it to the TOP of the stack.  We used these note cards as a true STACK.  FILO.  It helped us stay on track.  We finally got through the stack, and when we did, the story was implemented.  We didn't have the complete plan at the beginning, but we adapted and changed the plan along the way.

This pile of ripped up note cards is all that's left of that nasty story.  It did take us all day, though, and at 6PM, we both were wiped out!  It was the last day of the iteration, and we had committed to the story.  We ate a quick lunch at our desks and worked straight through.  It was great that we were able to meet our iteration through micro-adaptive planning.

I hope I don't have to do that again for a long time because that was the most difficult pair-programming I have ever done.  We were talking through the problems _all day_.  My brain was hurting on the way home.

My pair partner commented that it would have taken him 3 days if he had had to work through this nasty story by himself.  Pairing on the entire solution cut the delivery by 2/3. 

Having a baby and an integration testing tip – level 400

I found out today that my wife is with child, and we're having a baby!  Now, on with the post. . .

 

Integration testing isn't your basic 200-level topic at an MSDN event.  It can be very involved.  I believe that a good integration test has to depend on targeted unit tests being present.  Consider the scenario without unit tests:

Bob has a use case that spans 15 classes.  He sets up the environment to get this slice of the system under test.  He then proceeds to write the test with asserts.  He quickly becomes frustrated because for each of the 15 classes along the way, there are different scenarios that are possible.  If each class has just 2 possible uses, his number of scenarios to test are 2^15.  Each scenario requires many assert statements.  Faced with 32,768 test combinations, Bob is disgruntled and concludes that automated integration testing is too much overhead.

What did Bob do wrong?  First, Bob attempted to start his automated testing at the integration level.  Second, he assumed unit test responsibilities inside the integration test.  Third, he tried to test every possible combination of integration.  Fourth, he hadn't surrounded himself with a quality team that could help guide the testing strategy.

Here's the success scenario:
Bob has written unit tests for each of his 15 classes.  He marvels at how simple they looks since each unit test only has to cover 2 usage scenarios for each class.  With confidence that each individual class will do its job correctly, Bob writes an integration test for the use case choosing one of the many combinations that could occur.  Bob sets up the test, executes it, and then asserts on the resulting state of the system.  Bob finds an integration issues caused by how two of the classes interact with each other.  He fixes that bug, and the test passes.  Bob now has confidence that the 15 classes are interacting properly in his use case.

 

If you haven't already read the following from my friend, Jeremy Miller, take a minute to do so:

Qualities of a Good Unit Test: http://jeremydmiller.blogspot.com/2005/05/qualities-of-good-unit-test.html
Achieve Better Results by following Jeremy's Third Law of TDD: Test Small Before Testing Big: http://codebetter.com/blogs/jeremy.miller/archive/2006/05/30/145752.aspx

The first task of a new software project is to build trust – level 300

Please read this post by Brad Appleton (and some links off the post) about building trust in a software team.  The notion is very profound, and we don't talk about much in professional circles.  I, for one, can easily be drawn into only thinking about the technical aspects of software development.  It's easy because it's something at which I excel.  Years ago I went so far as to scoff at a previous employers attempted evaluation of "soft skills", but I know see the importance of it.  Technical skills are necessary, but the greatest techy on earth can be rendered ineffective if no one will trust him.

Sorting in .Net (don’t sort manually, let .Net do it for you) – level 100

I've labeled this as a level 100 topic because I feel that every .Net developer
should know the basics of sorting.  With the base class library that we have to
work with, we don't have to worry about sorting algorithms or speeding up our
sorts.  Folks smarter than I have implemented the fast sorting that we have in
.Net.

Here, I'll cover the basics of how
to sort your own domain object as well as how to sort any other object (even
ones you didn't create).

Let's consider
the following domain object, Person:

   11 public class Person

   12 {

   13     private string _firstName;

   14     private string
_lastName;

   15 

   16     public Person(string firstName,
string
lastName)

   17    
{

   18        
_firstName = firstName;

   19         _lastName =
lastName;

   20    
}

   21 

   22     public string
FirstName

   23    
{

   24        
get { return _firstName;
}

   25    
}

   26 

   27     public string
LastName

   28    
{

   29        
get { return _lastName;
}

   30    
}

   31 }

In our application, we may want to display
FirstName LastName or LastName, FirstName.  Also, we may want ascending or
descending sorts.  If you are using a database, you may be tempted to let the
database order the records for you, and that's fine if you never need to change
the sort inside the application.  In object-oriented systems, however, a lot of
code never talks to the database, so we need to be able to sort.  Now, suppose I
wanted the following code to work:

 

[Test]

public void ShouldSortPersonsAscending()

{

    Person[] persons =
new Person[]{new Person("Homer", "Simpson"), new Person("Bart", "Simpson"), new Person("Jerry", "Seinfeld")};

    Array.Sort(persons);

    foreach(Person person in persons)

    {

        Console.WriteLine(person.FullName);

    }

}


This code won't work right now because
Array.Sort( ) counts on the elements in the array implementing the IComparable
interface.  This is a key interface in .net for sorting.  By adding an
implementation of that method to my Person class, I get sorting for free.  What
I am going for here is a sort by last name and then first name:

public class Person : IComparable

{

    private string _firstName;

    private string
_lastName;

 

    public Person(string firstName,
string
lastName)

   
{

        _firstName
= firstName;

       
_lastName = lastName;

    }

 

    public string FirstName

    {

        get { return _firstName;
}

    }

 

    public string
LastName

    {

        get { return _lastName;
}

    }

 

    public string
FullName

    {

        get { return string.Format("{0} {1}",
FirstName, LastName); }

    }

 

    public int CompareTo(object obj)

    {

        Person person = (Person)obj;

        int compareResult =
LastName.CompareTo(person.LastName);

        if(compareResult == 0)

        {

            compareResult
= FirstName.CompareTo(person.FirstName);

        }

 

        return compareResult;

    }


Notice how
I just had to implement a single method comparing first on last name and then on
first name.  Here is my output:

------ Test started: Assembly: BlogScratchPad.dll ------

Jerry Seinfeld
Bart Simpson
Homer Simpson

1 passed, 0 failed, 0 skipped, took 0.41 seconds.

That's the bread and butter sorting case,
and that gives my Person object a default sort order.  Anyone working with
Person(s) can now sort by last name, first name in ascending order.  But what if
I wanted to sort in descending order?  There is another key interface in .Net
called IComparer.  This interface enables you to create a class that defines the
sort order for any class.  Consider the following tests.  I would like my
Person(s) to be listed in descending alphabetical order (reverse of above). 
Here, I choose to implement the generic form to avoid some casting:
IComparer<T>.

[Test]

public void
ShouldSortPersonsDescending()

{

    Person[] persons = new Person[] { new Person("Homer", "Simpson"), new Person("Bart", "Simpson"), new Person("Jerry", "Seinfeld")
};

    Array.Sort(persons,
new ByLastNameFirstNameDescendingComparer());

    foreach (Person person in persons)

    {

        Console.WriteLine(person.FullName);

    }

}


Notice how this test looks very similar to
the previous one; however, I've added my new comparer class to instruct
Array.Sort( ) how to sort the array.

public class ByLastNameFirstNameDescendingComparer :
IComparer<Person>

{

    public int Compare(Person x, Person y)

    {

        int compareResult =
y.LastName.CompareTo(x.LastName);

        if (compareResult == 0)

        {

            compareResult
= y.FirstName.CompareTo(x.FirstName);

        }

 

        return compareResult;

    }

}


Notice how I just compared y to x instead of
x to y.  This gets me the descending order that I want.  Here is the result of
running the test:

------ Test started: Assembly: BlogScratchPad.dll ------

Homer Simpson
Bart Simpson
Jerry Seinfeld

1 passed, 0 failed, 0 skipped, took 0.41 seconds.

Notice how it is exactly the
reverse of the previous result – just what I wanted. 

Array.Sort(Array, IComparer) works to sort an array of any object under the
sun.  My team's Visual Studio solution has accumulated  a healthy number of
IComparer classes.  This allows our application to sort objects however needed,
whenever needed. 

NHibernate: ICriteria may cause update – know about AutoFlush mode – level 300

This topic is for those already using NHibernate.  By looking at the forum, that is a whole load of people!

As always, my blog posts stem from experience, and this is no different.  It's been a year since I first tried out NHibernate, and since then I've used it on 4 large, unrelated applications.  This latest application of NHibernate is by far the most exciting, however, because we are able to take advantage of the full power of the library.  The others have always been tempered with the few things that couldn't be changed that hampered seamless data access.  My team no longer has to slow down to think about what SQL to write.  We stay in C#, and we're going faster and faster.  For the performance-minded, the NHibernate SQL is pretty darned fast (because there is nothing special about it – just CRUD).  We run about 120 database tests in 2.5 seconds – not bad.

Last week, I learned another thing new about NHibernate – AutoFlush mode.  This is important because NHibernate only keeps 1 instance of your domain object per ISession instance, so if you ask for the same object multiple times from the same ISession instance, you'll get the same domain object instance.  Imagine this scenario: 

  • You pull some objects into memory.
  • The user modifies one object.
  • You query for a list using ICriteria (the object the user modified is a match for this list)

What should the system do?  Should the fresh query refresh all the objects and throw away the user's changes?  NHibernate's default behavior is "no".  It is configured to "autoflush" by default.  When it detects that some changes might inadvertently be thrown away by a fresh query, it will auto update the modified object to the database.  If you open up SQL Profiler, look for UPDATE commands amidst SELECTs.  If you choose to set the autoflush mode to "NEVER", then you'll get a big fat exception, and you can write some code to handle the times when you need to do a fresh query after a persistent object has been modified.

Podcasts I listen to – level 100

I was listening to Internet radio before the term "podcast" was coined.  With the term, we have an explosion of Internet radio and listenership.  I've been asked several times what podcasts I follow.  I'll admit, there is limited time for listening, so over time, I have dropped some shows and picked up some others.  Here is my current list: