Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

ViNull, Off the Record

Distilled ramblings of Michael C. Neel delivered right to your browser.
  • ASP.NET SEO Interview on Polymorphic Podcast

    image Craig Shoemaker just posted the latest episode of the Polymorphic Podcast: ASP.NET SEO - Interview with Michael Neel.  Yes, I've now appeared in a podcast that I didn't have a hand in recording!

    Even if you don't listen to the show (and you should, Craig does an awesome job) check out the show notes.  SEO - or Search Engine Optimization - is one of those areas developers tend to overlook or outright ignore.  I think this is partly because it's not something we think about when knee deep in site code, but also because there is a stigma attached to SEO that it is dirty marketing stuff.  Truth is, a good design for SEO is also a good design for users and helps more people find what they need (I was glad to see StackOverflow realize the sitemap protocol is very helpful).

    One thing I mention at the end of the podcast (at least I think it's the end - I haven't listened to it yet!) was the new support from System.Web.Routing to handle some of the code I have written myself in mapping urls to content.  Wally McClure has just recently posted an ASP.NET Podcast on Routing with WebForms that explains the new API.

  • Finding the difference between two Arrays, or un-LINQ-ing your code

    imageLINQ is great, up to the point when it's not.  Then it's really not great at all.  When we trade simplicity of syntax for performance, we have to keep in mind there may come a point when we have to go back the code and factor out the shiny new toys.

    My system is complex, but this task is simple.  I have about 95,000 video files to keep track of in a database.  Try as we might, at some point someone is going to make changes, add or remove files, without going through our software, so a periodic file audit is required.

    I have two lists of file names, one is the list as it exists in the database, the other as it exists on disk.  This is greatly simplified, but the initial idea was something like this:

    List<String> toAdd = (from f in existingFiles
                          where !indexedFiles.Contains(f)
                          select f).ToList();
    
    List<String> toRemove = (from f in indexedFiles
                             where !existingFiles.Contains(f)
                             select f).ToList();

    The power of LINQ, short and sweet.  Sadly, it appears to act like this under the hood:

    List<String> toAdd = new List<String>();
    foreach (String f in existingFiles)
        if (!indexedFiles.Contains(f))
            toAdd.Add(f);
    
    List<String> toRemove = new List<String>();
    foreach (String f in indexedFiles)
        if (!existingFiles.Contains(f))
            toRemove.Add(f);

    These statements pegged the CPU for minutes at a time - can you see why?  How many times am I looping through each collection of strings?  Twice? Four times?  No, I'm afraid this is classic "Oh 2 Da N" performance here.  The problems lies in using the Contains() method - this method must search through the collection each time it's called, which is often.  To solve this, we'll have to kick it old school C-style:

    indexedFiles.Sort();
    existingFiles.Sort();
    
    for (int iE = 0, iI = 0; iE < existingFiles.Count || iI < indexedFiles.Count; ) {
        if (iE >= existingFiles.Count) {
            toRemove.Add(indexedFiles[iI]);
            iI++;
        }
        else if (iI >= indexedFiles.Count) {
            toAdd.Add(existingFiles[iE]);
            iE++;
        }
        else {
            Int32 diff = existingFiles[iE].CompareTo(indexedFiles[iI]);
            if (diff == 0) {
                iE++;
                iI++;
            }
            else if (diff > 0) {
                toRemove.Add(indexedFiles[iI]);
                iI++;
            }
            else if (diff < 0) {
                toAdd.Add(existingFiles[iE]);
                iE++;
            }
        }
    }

    A quick sort of the lists and we can make some time saving assumptions as well as walk through both lists at the same time (.Net had no trouble sorting lists of 95,000 strings in record breaking time).  We start off comparing the strings at index 0 of each list (the first if and else if will be false - I'll come back to those shortly).  If they match, then the file both exists and is indexed - go to the next file in both lists.  If the existing string is greater than the index string, then we know the file no longer exists (remember, lists are sorted).  In this case only advance the index list to see if it "catches up" with the existing list.  If the existing string is less than the index string, the reverse is done.  If we run out of existing list before we finish the index list, those files no longer exist - which is what the first if statement handles (the first else if handles the other case for running out of index list first).

    If you have to work through this for loop on scratch paper, don't feel bad - I did.  It's been a very long time since I've had to get this "raw" with my code.  It was worth it as the performance went from several minutes at 100% CPU to so fast I couldn't believe it had run.

    I googled a bit to see if there were other solutions out there, and more importantly some method in the .Net framework that would solve this issue and came up empty.  I'm not convinced there isn't something in the bazillion methods living in the framework, so if you know of something, please let me know!

  • ORM talk at CodeStock Open Spaces

    One thing I'm hearing from a lot of people who attended CodeStock last Saturday is how well the open spaces "track" was.  This is one area I can't take any credit for, my only role in planning open spaces was requesting a room from the college; all credit for success goes to Alan Stevens the facilitator.

    An Open Spaces conference is explained as the "un-conference" - a very hippy, free flowing conference where the sessions self organize and the topics are chosen by the attendees.  This in contrast to a traditional conference of set speakers and topics.  Each have an advantage; an open space isn't the best place to get a first look at a technology but once you've used a technology an open space is a great place to discuss with others how it should be used.

    Rather than choose one format, CodeStock featured both.  This worked out better than I could have imagined because it mixed two camps - the open space people hung out with the "straight laced" conference people.  This created a stage for some great conversations with all views represented and an exchange of ideas can commence.  Wally McClure was breaking in a new Flip, and managed to capture an ORM discussion for the latest ASP.NET Podcast - I would have loved to have been there, but I was fighting gnats at the time.

    More video formats available at ASP.NET Podcast

  • Using LINQ to generate HTML

    image I hate seeing code mixed with markup.

    Seeing a template page with <% if(show) { %> makes me want to claw my eyes out.  Seeing String htmlTitle = "<h1>" + title + "</h1>" causes me to vomit up a little something in my throat.

    Mixing code with markup is not a magic chocolate and peanut butter combination - it's a volatile cocktail of vinegar and baking soda waiting to explode your application to tiny Server 500 Error giblets.

    The time comes however when we find ourselves needing to generate some well formed HTML in code, and I found myself in just such a position last night adding the agenda to the CodeStock website. (Less than one week away now!)

    Background: On the CodeStock site, the speakers and sessions list lives in an XML file.  The agenda page has a grid of session times and my task was to fill in each session "cell" with the session planned for that room and time.  I wanted to link to the full session and also list the speaker's name in the cell.  In the XML I have created Key elements that are used as HTML anchors in a link to a session.  It's all very low tech, simplistic goodness.  An example of the XML for a speaker:

    <Speaker>
        <Key>Brownell</Key>
        <Name>Steve Brownell</Name>
        <Website>http://enthusiasticprogramming.blogspot.com</Website>
        <Photo>~/Speakers/SteveBrownell.png</Photo>
        <Bio>
            Steve is the manager for research and development at AllMeds in Oak Ridge, TN.  Steve
            has been programming one thing or another for over twenty years.  AllMeds makes and
            sells a commercial software product which is an electronic medical record system.  We've
            been .NET based since 2000.  AllMeds is a VB.NET shop at heart, but the AllMeds system spans
            many areas of Windows development.
        </Bio>
        <Session>
            <Key>Hobbled</Key>
            <Title>
                The Hobbled:  There And Back Again, or Code Automation:  how I made it from the
                presentation layer to the database and back.
            </Title>
            <Abstract>
                Stop writing code, and start writing code that writes code.  There's never been more
                choices to help you automate the creation of the data object layers immediately above
                the database.  Writing class factories and data access classes is boring, time consuming
                and wastes valuable time with expensive developer resources.  This course will examine
                two current approaches:  using a template engine and programming with the CODEDOM.  We'll
                also briefly discuss other ORM techniques like LINQ to SQL Classes.
            </Abstract>
            <Level>200</Level>
            <Technology>VB.NET, C#, LINQ, SQL</Technology>
        </Session>
    </Speaker>
    

    (Steve was our CodeStock Speaker Idol winner, and I enjoyed seeing System.Codedom in action; something I'll be playing with and posting on in the future thanks to Steve!)

    LINQ to XML, and the new "X" classes that come with it make working with XML as easy as it should have always been.  Armed with LINQ, I decided that putting <%= SessionInfo("Hobbled") %> was something I could live with (had this been a larger site that needed to live longer than August 9th, I would have opted for a user control <CodeStock:SessionInfo Key="Hobbled"/>).  My first LINQ expression looked something like the following:

    var info = (from s in speakers.Descendants("Session")
                where s.Element("Key").Value.Equals(SessionKey)
                select new {
                    key = s.Element("Key").Value,
                    title = s.Element("Title").Value.Trim(),
                    speaker = s.Parent.Element("Name").Value
                }).First();

    This yields a very useful info object with just the information I need.  *If* I was in a hurry, and didn't mind a little vomit, I would follow on with the following:

    String hmtl = String.Format("<a href='{0:s}' title='{1:s}'>{2:s}</a><br />{3:s}",
        new object[] { ExpandURL("~/Pages/Agenda.aspx", info.key),
                       info.title,
                       info.title.Length > 30 ? info.title.Substring(0, 27) + "..." : info.title,
                       info.speaker });

    Why do I despise this so much?  It's not easy to read, and it can become cumbersome to change.  ASP.NET has a collection of server controls just for generating HTML, intended for use in user controls but they are not limited to user controls alone.  To generate the html above would look something like this:

    HtmlAnchor aHref = new HtmlAnchor() {
        HRef = ExpandURL("~/Pages/Agenda.aspx", info.key),
        InnerText = info.title.Length > 30 ? info.title.Substring(0, 27) + "..." : info.title,
        Title = Title
    };
    HtmlGenericControl div = new HtmlGenericControl("div") {
        InnerText = info.speaker
    };
    
    StringBuilder html = new StringBuilder();
    using (StringWriter sw = new StringWriter(html)) {
        using (HtmlTextWriter hw = new HtmlTextWriter(sw)) {
            aHref.RenderControl(hw);
            div.RenderControl(hw);
            hw.Close();
        }
        sw.Close();
    }

    There are times when working with parts of the .Net framework I have wonder if some Java types didn't design the class.  The mess here to render the HTML is one of those times.  The lack of a RenderControl that returns a String is the problem - thankfully we now have extension methods to fix the framework, but that's another post.  No matter how much I hate markup in the code, I cannot endorse this version over the vomit inducing first solution.

    It occurs to me that HTML is (or was once) fundamentally XML, and I can return XML from my LINQ expression.  In fact, this is what LINQ is about - not just getting the data you want, but getting it in the format you need.  Here is the new LINQ query:

    XElement info = (from s in speakers.Descendants("Session")
                     where s.Element("Key").Value.Equals(SessionKey)
                     let key = s.Element("Key").Value
                     let title = s.Element("Title").Value.Trim()
                     let shortTitle = title.Length > 30 ? 
                        title.Substring(0, 27) + "..." : title
                     let session = new XElement("a",
                                  new XAttribute("href",
                                      ExpandURL("~/Pages/Agenda.aspx", key)),
                                  new XAttribute("title", title),
                                  shortTitle)
                     let speaker = new XElement("div", s.Parent.Element("Name").Value)
                     select new XElement("span", session, speaker)).First();

    This may not seem to some as better.  I myself have trouble looking at most LINQ expressions, but as I'm learning to Thinq Linq I'm seeing that writing the LINQ expression is where the power lies, not in the syntax.  The mental dialog goes something like this:

    "Okay, from my list of speakers I want a session where the session's key matches SessionKey.  Now, let me grab some fields I need, first the key, then the title which I need to trim off excess whitespace, then let's make a short version of that title since Steve's title is so long - love that title though.  I'll need an link tag for the session; set the href and title attributes, and then add the speaker's name in a div tag so I get a cheap line break.  I'm really in XML not HTML, so I'll need a root node and a span tag will work without affecting layout, and I'll add the link and div tags as children."

    Writing LINQ like this I feel much closer to the problem I'm trying to solve, and not bogged down by syntax.  There is still some moments I'm thrust back to code, such as the use of First() to select only one result.  I'd like to have a "select first" option in LINQ expressions instead of just the extension methods. 

    Is this something I'll be using now every time I have this problem?  Not sure yet, but it's another "tool in the box" I'll keep around and use when it feels right.

  • The ASP.NET MVC Definition

    image A few days ago I posted a question to the community, looking for a definition of the ASP.NET MVC framework that didn't depend upon faults in ASP.NET WebForms - after all, faults can be fixed.  I also do not like the implication that ASP.NET MVC is for those looking to use the MVC pattern, as I've been using that pattern for a decade and I use it in WebForms today.  Credit goes to Lucas Goodwin for helping me with the following definition:

    ASP.NET MVC is the evolution of Classic ASP.

    I've helped a number of developers move from Classic ASP to ASP.NET, and each one has said to me, "wow, this is nothing like ASP" once they groked it.  This is true, and mostly because WebForms introduced an event based paradigm to ASP.  Classic ASP had problems, but was the lack of events one of them?

    Classic ASP's number one problem was lack of separation of concerns.  This is the same reason I don't like PHP, my code is far to friendly with my HTML (gotta keep em' separated).  True you can discipline yourself to provide a separation, but it's not something the framework designers gave much thought to.

    WebForms fixed the separation issue, but at the same time brought in the event model.  I liked this "magic controller" approach, because it saves me the time I used to spend wiring up controllers that just ended up back at the same template I started with.  (For the record, I was mostly working with python before moving to WebForms, first with a framework called Albatross and later SnakeSkin)  An event model is not required to have separation of concerns, and this forced an event model on to many Classic ASP developers.  So I will add a bit to the definition:

    ASP.NET MVC is the evolution of Classic ASP, adding an easier separation of concerns while not using an event based model like WebForms.

    So do you agree or disagree?  I like this definition because it's not claiming either approach is better, and I can look to the pros and cons of an event based model to guide me in selecting MVC or WebForms for a project.  It also is less likely to cause rioting in the streets at your next user group meeting when the topic comes up!

  • The MVC Minefield

    There is a bit of turbulence in the ASP.NET airspace over MVC (yes, I'm making this post while on the fight back from the ASPInsiders Summit).  Even among the ASPInsiders, who are supposed to be at the cutting edge of ASP.NET, there is little agreement over what is MVC and what it's for.

    MVC, or Model View Controller, is an age old pattern found in many places.  ASP.NET providers follow the pattern, as does Service Oriented Architecture.  The general idea to have some code called a Model that works with your data storage, other code called a View that displays the data, and last plumbing code that ties these two together, called the Controller.  I call it a pattern because implementations differ in the details - the View may render a button, but when the user clicks that button should the click action be handled by the View or Controller?  The Model and View should know nothing of each other, but is the Controller allowed to be tightly coupled to them both?  (If your first thought above was the Controller should handle the button action, think now what this means about being loosely coupled between the View and Controller).

    ASP.NET MVC is a framework in development that is intended to closely match the MVC pattern.  The minefield lies in answering the pragmatic question of what does ASP.NET MVC offer over WebForms, and when would you use MVC?  In taking with those excited by MVC the reasons range from supporting TDD, clean URLs and avoiding postbacks by sending actions to a controller, better control over HTML output (including getting rid of ViewState), and being closer to the http protocol.

    TDD, or Test Driven Development, will always come up in any ASP.NET MVC conversation, but TDD itself isn't an explicit part of MVC.  The MVC pattern is very amendable to TDD however, and thus the association.  I generally support testable code even if there are no tests around the code.  Testable code is much easier to maintain, enhance, refractor, and replace.  I don't find the process of test-first development helpful, but I do write tests in the same session as the code when I know I'm writing some critical piece of functionality that needs to survive multiple versions of the software.  As Hanselman noted, I'm like the "person who goes to church on Easter and Christmas" and I'm sometimes looked down upon by the congregation who attend weekly.  I'm okay with this, but I have some reservations with MVC as a framework for TDD.

    To say you cannot test WebForms is a strawman argument; there is no trouble in separating the Model and testing it thoroughly.  Depending on how you go about it, you can also separate the Controllers and test them - I generally have very simple Controllers that pass user input into the Model as is, so testing the Controller is not that important to me.  Testing the View in WebForms is very difficult - and this isn't specific to WebForms.  My objection to claiming MVC has testable Views is the implied definition of testing.  Verifying the output HTML of a View is not helpful at all - it's just string comparison.   I want to write tests like Asset.JavascriptRunsOnSafariMac() and Assert.IE8RendersSameAsFireFox3().  If MVC could do that, then I would be switching to it today!

    WebForms provides a very robust SiteMapProvider interface that makes it easy to clean up urls of dynamic content.  Global.asax can be using to control routing of requests (in fact this is how MVC does it as well).  The biggest problem I've had here isn't WebForms fault, but IIS6's inability to allow ASP.NET to handle requests without an ASP.NET extension in them: this is solved in IIS7.

    You can get fine grain control of HTML in WebForms, ever with just the stock controls.  There is also an entire collection of HTML server controls to match HTML tags to make it easy to generate HTML from code (I hate seeing tags hardcoded in source file, feels dirty and hackish).  About the one thing that is hard to do in WebForms I deal with somewhat often is controlling the client side ID's, which can become quite long and fugly looking.  For CSS you can just assign a class name instead of using ID references (and there aren't many places I'm using CSS IDs except for layout divs that aren't coming from ASP.NET controls anyway).  Javascript is trickier; you need to inject a reference of Control.ClientID on the server in the client script, and the need is much more common than with CSS.  If you have an external JavaScript file this can get worse, but I believe that an external JS method should take the ID of the control they work with as a parameter making it easier to read the external file without the need to reference the aspx code.  At the end of the day however, I'm not willing to throw the "baby out with the bath water" and will lean more on Microsoft to fix this issue in WebForms rather than jump to MVC.

    The last reason for MVC I mentioned, being closer to the http protocol and its stateless nature, I simply don't grok.  Any application with a basic level of user interaction will need to mask the http protocol's implementation details to provide a positive user experience.  Web programmers of all frameworks and languages have realized there are only a few methods to solve this problem; cookies, url parameters, and hidden fields.  Any state solution will involve one or all of these - even if state is stored on the server's side.  WebForms supports all of these methods, and you can disable things like ViewState (hidden fields) if desired.  (I am aware there is also ControlState that will be still emitted if ViewState is disabled, but I'm willing to say that if these few bytes are an impact you are working on an edge case).

    I'm not here to bash ASP.NET MVC - to the contrary I'm here to help by outlining the faults in the current arguments for MVC.  If MVC is defined by the features in or not in WebForms, then it's going to be hard for those deep into WebForms to see value in MVC.  It becomes a song of "anything you can do, I can do better (no you can't, yes I can)" and will deadlock when neither side is listening to the other.  ASP.NET MVC need to be defined without claiming faults in WebForms, because that only says use MVC because WebForms is broken - leading one to say, "why not just fix WebForms?"

    I wish I could end here with a new explanation of ASP.MVC meeting the requirements I've just stated, but I'm afraid I can't.  This is a fault with me, and not the MVC framework - I'm too close and deep into WebForms to see a need for MVC I can't fill already.  It's my hope and request that instead of seeking to pick apart this post, the supporters of MVC come out to define MVC without attaching that definition to the perceived faults (for that's the minefield) of WebForms.

  • Review: The Annotated Turing by Charles Petzold

    image Let me start by saying while reading The Annotated Turing: A Guided Tour through Alan Turing's Historic Paper on Computability and the Turing Machine I encountered two other reviews worth note.  The first review by Jeff Atwood  focused on Alan Turing's personal life as a gay man in the first half of the 1900's and is light on reviewing the actual text of Turing.  The second review is by Deirdre Sinnott and does cover the text in depth, but one must carry a certain level skepticism (however undue) toward Deirdre given her relationship to Petzold.  I must also alert the reader to my own bias, as I have written well of Petzold in the past and was sent a (signed) copy of Turing.  I did however purchase the book before I knew a copy was being sent to me.

    For the impatient, busy, or otherwise opposed to reading what has become a lengthy review, I will save you the investment of time by saying now I highly enjoyed this book and would strongly recommend it to any programmer, mathematician, or person with an interest for numbers.  I will qualify this recommendation with the disclaimer that if you do not have the time to devote to reading the remainder of this review, you may not have the time needed to read and understand the book's content.  I found myself only able to read 10-20 pages a night of this scant 359 page book due to the amount of mental engagement demanded by the subject matter; which only worked to increase my enjoyment.  Before we get into the content of the book however, let us take a moment to understand the actors involved...

    Alan Turing is our hero in this tale, a brilliant young man who leads a troubled life and finds refuge in a love for numbers.   Our narrator, Charles Petzold, shares a great many things in common with Turing, including this love of numbers and the mind to process these numbers in complex ways.  I have read many of Petzold's books on Microsoft Windows programming and one constant is that his examples often use calculus or trigonometry equations in a way that the example itself teaches as much on mathematics as the API the text covers.  Mathematics and computers, I'm learning, are tied much closer together than most would assume.  The last character is myself, the reader, who poses only a basic understanding of college level mathematics (enough to meet CS requirements) and who once wrote a two page mathematical paper that was, in the words of the professor, "an amazing level of insight and effort, but 100% flawed and incorrect".  I mention this because while I was not able to understand every formula and proof covered in Turning, this did not detract from my understanding of its significance to the material.

    The events in Turing surround Turing's paper "On Computable Numbers, with an Application to the Entscheidungsproblem."  I will probably offend true mathematicians with the following explanation of the Entscheidungsproblem (and again later in this review), but simply put the Entscheidungsproblem asks for a set of steps one can use to determine if a given formula has a solution (but not what that solution might be).  Consider A² + B² = C², which we know is true because we can plug in 3, 4, and 5 and see that it works. What about A³ + B³ = C³?  Before we start trying some random numbers it would be nice to know if there even is a solution - and this is what the Entscheidungsproblem is all about.  (My method would be to try some random numbers, I'm sure a mathematician  would start with a much more reasonable and fruitful approach.)

    Turing proved that no, there is not a universal method for determining if a given formula has a solution.  Turing was not the first to prove this: 6 weeks before Turing's paper was published in 1936, Alonzo Church published a paper that also proved there was no method for the Entscheidungsproblem.  Turing's solution was so novel and unique in it's approach however, that it has the rare honor of also being published, and Turning added a proof to his paper that both methods are equivalent.

    Truth.  To normal folk truth has a somewhat soft definition, but to mathematicians truth has strong and rigid meaning.  You may know something to be true simply through common sense, but in the world of mathematics something must be proven in concrete formula before it can be accepted as true; until then it remains unproven and will not even be considered worthy of assumption of truth in all but the most extreme cases.

    To tackle the truth of the Entscheidungsproblem, Turning invented (on paper) a machine that could read a sequence of commands that expressed a method to calculate number and print it as the result.  This allowed Turing to work with numbers like π without needing to calculate the exact value (something no easier in 2008 than it was in 1936).  Further, Turing devised a method to give every possible sequence of commands a unique number, called a Description Number, or DN.  The DN for a machine that computed π might be DN 314,257.  Last, Turing invented a machine that could be given a DN and generate the sequence of commands that DN represented, then pass this sequence off to another machine to calculate the result.  Turing's machines worked in binary, i.e. 0's and 1's only, so Turning then proved it was not possible given a DN to determine if the calculation machine would ever print a 0 as a result of calculation, thus proving there was no universal method to determine if a given formula had a solution.

    Just reciting the list of actors and events doesn't convey the story, we must also discuss the meaning and impact.  Much of The Annotated Turing is true to the title; Petzold presents the unmodified original Turing paper and provides annotations to help understand the material, while also citing related material and events.  In this capacity, Petzold is unsurpassed - the bibliography for Turing cites over 90 books and papers (including a humble citation of Petzold's own Code) and one is given the impression Petzold read many more books not cited.  Petzold's greatest contributing to Turing's work comes at the end however, when he explores the impact Turing had on the fields of mathematics, computer science, and philosophy.

    Any developer reading above recognized that Turing machines are computers running programs.  What may not have been obvious is that Turing's proof also means that no program can be written that will determine the output of another program.  That we cannot break this limitation, and our new platforms, languages, and computers will "at best [...] only do jobs faster."

    The philosophic impact is far greater, for we humans qualify as Turing machines.  Other philosophers and mathematicians have come very close to a proof that the universe is fundamentally digital, can be expressed as 0's and 1's, and qualifies as a Turing machine.  If true, this abandons our romantic notions of free will, for as a Turing machine in a digital universe our actions are calculable.  Our perception of free will is merely the misunderstanding of the inability to predict the output of our own Turing machine, the mind.

    I do not assert I've laid out a solid argument in the above paragraph - for that you'll need to read Turing and possibly the references cited by Petzold.  Having just finished Turing hours before writing this review, and being a person who has rejected the idea of fate, I'm still a little uneasy myself.  It's as if Alan Turing sat next to me on the airplane and said, "Oh fate?  It exists, I have a mathematical proof here somewhere in my backpack I did last summer when I had some spare time."  At least I don't have to tell the major religions of the world I was wrong about them too...

    Last, I'd like to mention that in planning for CodeSock this summer, we were able to get Wiley Publishing (publisher of Turing) as a supporter.  I requested and was granted 5 copies of The Annotated Turing to give away at the end of the conference.

  • Knoxville takes part in the Ann Arbor Give Camp

    This past weekend Knoxville took part in the Ann Arbor Give Camp thanks to Nathan Blevins.  Nathan organized a team of developers (and one designer!) in Knoxville with Ben Farmer, Jenny Farmer, Dylan Wolf, and Joe Simpson.  The team assisted in two projects for the give camp: Wonder Puzzle and Ann Arbor Hands-On Museum.

    Josh Holmes will post more details on Wonder Puzzle, but the idea for the site is simple: make it easier for parents of children with undiagnosed medical problems.  If a child has a diagnosed illness, there are support groups for that illness a parent can turn to, but the parents of an undiagnosed child can find themselves isolated.  To help Wonder Puzzle the Knoxville team updated their site's design and moved the content management to Sitefinity.

    Knoxville (through Dylan) was able to assist in the Ann Arbor Hands-On Museum project by providing some PHP support.  The museum's goal is to inspire people to discover the wonders of science, math and technology.  I wish I had more info on what this project was, but I'm sure details will be posted on Michael Eaton's or Jennifer Marsman's blog shortly.

    I confess I really hated missing out on the give camp (I was on the road driving back from my speaking tour).  Not because I'm an awesome, caring guy who loves to give back to the community, but because I could have hung out with my peers and wrote code all weekend; charity is a bonus.  I'm glad to see the give camp team isn't stopping to rest and has formed a group to setup future give camps.  Nathan is part of this team, so I know I'll be a part of the many give camps to come!

  • How did I get started in Software Development?

    I'm such a slack, and just now getting to responding to this meme after being tagged by Derik.  Normally, I can't stand these things, but there are some I like - and this is one.

    How old were you when you started programming?

    I was about 10 years old when Dad came home with a Tandy 1000EX.  We played some games on it (Zork) and used it for homework (Mom loaded all our spelling words each week into a program that would flash the word and we would have to type it in).  One night, I watched Dad use BASIC to send escape codes to the printer, getting it to change settings and that was all it took - I was now curious about the secret language of computers.

    What was your first language?

    BASIC was where I started, and stay for most of my time in school.  I checked out books from the library and back then, Family Computing used to publish a BASIC program in each issue.  I tried to teach myself assembly, but only managed to reboot the computer every time I ran my programs.  I didn't know anyone else into programming, so it wasn't until college and the military that I learned about C.

    What was the first real program you wrote?

    The first program would be a BASIC program that played songs from Les Misérables while drawing images on the screen (the Tandy was known for it's 16-color display and 3-voice sound).  The first program I was paid to write was for the military, and it was a series of automation programs in C to move weather radar and satellite imagery from proprietary systems to an Internet website (note: I probably violated all kinds of military regulations and vendor contracts doing this!)

    If you knew then what you know now, would you have started programming?

    Without a doubt, and I would have looked into C much sooner!

    If there is one thing you learned along the way that you would tell new developers, what would it be?

    This is hard, but if I limit myself to one thing only, then I would stress to remember that technology, languages, platforms, etc are not that important.  Software is only a tool to accomplish another task, and the less of it involved the better off we all are.  As a developer, seek to understand the real problem you are solving for someone and then only apply your programming skills to solve that problem.

    What's the most fun you've ever had ... programming?

    Back in the military I was going to night school and met another programmer named David.  David and I both loved programming and games, and did many of our programming assignments together - often going way beyond what was required.  One night we had been passing our programs back and forth trying to crash each others program with bad input for a few hours, when finally we felt we had achieve indestructible code each.  When the proceeded to call our wives into the room, and show off how manly our programs were - programs that could never be hacked.  David's wife sat at the keyboard, and at the input prompt hit Crtl-K and caused his program to crash.  She then repeated the same on my program, and it cashed as well.  The wives shrugged and left - not understanding the look of horror and shock on our faces.   We then spent the night trying to figure out why that one combination caused a crash and all the others were fine.

    I don't think either of us have claimed to write indestructible code again.

    Who am I calling out?

    Knoxville, represent!

    Nathan Blevins

    Alan Stevens

    Dylan Wolf

    Wally McClure

    Walter Lounsbery

  • Where's Mike?

    I recently posted that everyone should read The Dip and I try to follow Seth's advice pretty closely.  The current "dip" I'm slugging through is organizing CodeStock - which means I have to "quit" or ignore many other things to focus on getting through this dip.  Less time spent playing with new .Net toys, which leads to less blogging and less speaking.

    One thing I'm slightly jealous about having to pass on is helping in the Ann Arbor Give CampTim Rayburn first told me about give camp's last year at the Memphis Day of .Net, and ever since then I've wanted to be part of one (or more).  I am however glad to see Nathan Blevins jump in and assemble a remote team so that Knoxville developer's can join in the Ann Arbor Give Camp, even if I can't.

    Fortunately however, a system has been created to allow one a temporary break from slugging through a dip - the vacation.  While most would imagine a vacation involves a beach and doing nothing, if we define vacation as "taking a break from daily routine to spend time doing an enjoyed activity" we see that a speaking tour is a vacation!

    Next week I'll be staying in the New Orleans' French Quarter and speaking at nearby .Net user groups.  Below is a list of dates and groups - if you're going to be in the area be sure to join in my vacation!

    • GNONUG in New Orleans, LA Mon 7/7 (topic TBD)
    • Perficient, Inc. in New Orleans, LA 7/8 @ 11:30 - Welcome to the Church of Agile
    • LANUG in Mobile, AL Tues 7/8 - From Zero to XAML
    • Acadiana .NET UG in Lafayette, LA on Wed 7/9 - SOA: Building the Arch
    • Hattiesburg, MS on Thurs 7/10 - "Geek Dinner" (this is still in the planning stages, but there will be something happening)
  • CodeStock After Party!

    image First, I want to give a shout out to Knoxville's "front man" Wally McCulre for including a spot on his latest ASP.NET Podcast for Codestock! (full disclosure - and apologies - it's me in the spot).  Big thanks to Wally!

    So what is the CodeStock After Party?  It's a time to hang out and socialize with your peers - speakers and attendees.  This is a major reason to attend a conference; meet your neighbors and realize you share the same goals and frustrations (no one ever told you being a developer was easy!).

    But wait, there's more!

    From 6pm till 8pm well have hot dogs, drinks and live music by Knoxville's own Hanover Fist - these guys know how to rock (and I have insider information that confirms some of them are also computer geeks)! The stage area is located right next to the conference, and there will be shade tents and tables setup for those not accustom to Southern Living.

    Space is limited so if you haven't, register today at CodeStock.org - get in your registration before July 15th to specify your t-shirt size and lunch preference in time for the conference.

  • You'll have my SQL when you pry my keyboard from my cold dead hands

    image Background - Some people don't like the Entity Framework, some do.  Many see the need to blog about it.  You can guess the rest, or JFGI if your need more info.

    The debate is nothing new; we have databases that are really good at storing data, searching that data, and spitting it back up.  Problem is the format spit up doesn't play well with how we use the data in code.  So we write some code to translate from one system to another.  If you want to be fancy, call it Object Relational Mapping.  JFGI as ORM if you want.

    Any skinned cat will tell you, there is more than one solution to a problem.  That's not a problem, that's called choice.  A problem is when one two sides argue over different solutions so loudly you cannot hear what they are saying.  It's often overlooked that there are more than the two options present.

    I write all my SQL.  I use a good deal of strongly typed DataSets.  I write my ORM code.  I have no problem with this, and have good reasons for doing such.

    First, I know SQL really well, and more importantly I understand how to manage a database.  I'm not a DBA - I've never setup a quad-node cluster with latency-free fail over across multiple data centers - but I know how to read a query plan and setup an index.  I have over a decade of experience with setting up a database behind and optimizing the system - I see no point in tossing that hard earned experience away.

    Second, and this is probably the most important factor, your ORM doesn't matter.  Your framework doesn't matter.  Your language, IDE, and ergonomic mouse you paid way too much for, don't matter.  When the servers start coming down, it's IO.  Disk or network bottlenecks are killing you.  We have the RAM folks, and the clock cycles are so plentiful we have to invent new ways of writing code just to use them all.  When all hell has broken loose, you need to know how your code works with the underlying IO; the fact you concatenated a few strings inline instead of using StringBuilder doesn't amount to a hill of beans.

    So what do you take from this?  ORMs are evil and true ninjas master SQL?  No.  You take from this that no matter what you use, it is 100% your responsibility to understand how your platform works at the IO level and how to adjust it when needed.  You take from this that you pick a tool based on you and your teams comfort level with that tool, and you don't bother to get caught up in pointless saber rattling posts like this one.

    If this has you all worked up, well... you can STFW for "kittens" or something.

  • Developer's Non-Development Book List

    I've been slack lately on posting, mostly because I'm still running around speaking and working on the details of CodeStock.  So I figure a "must read book list" is great filler until I finish up that SilverLight 2.0 series of posts.  Instead of the normal development and programming books though, I'm going to list the books outside of development I think developers should read.

    image

    Charles Petzold's Code is a book I've recommended before, but no less relevant today than it was when it was first published.  In these days of frameworks and garbage collectors it's easy to loose sight of how a computer really works.  Why is it binary based?  What does a logic gate really look like at the circuit level?  What are MSB and LSB and how did they cause the PC/MAC software divide for so long?  Petzold is a wonderful storyteller and he is at the height of his craft in these pages.

    image

    Waiting for You Cat to Bark? by the Eisenberg brothers is aimed at marketers struggling to adapt to the information age, but reading through this book you'll start to see how software UI - or the user experience - is fundamental to a successful application and required for a website.  Yes, you're the developer - but you're the one who knows the technology and should be in the marketing meeting designing the new site that will increase sales for the company (you and the marketing department are paid from the same source, after all).  Also, if you've been tasked with or looking to start writing user and use case stories, this is a far better place to start than most agile books - how better to get a non-IT perspective than from a non-IT book?

    image

    The A-Z of Creative Photography by Lee Frost is what we developers would call a "cookbook" - a list of common problems and their solutions.  Now why am I pushing a book on photography to developers?  Photography is a great way to learn design basics - and let's face it, you suck at PhotoShop.  Just because you own a digital camera doesn't mean you know how to take photos any more than downloading an IDE means you know how to write software.  After reading this book, I no longer take those boring family photos people avoid looking at - I'm no professional, but I no longer feel the need to fork over a few hundred bucks to some guy a Sears once a year for family portraits.  I also understand how to apply the "rule of thirds" in design.

    image

    Eric Raymond's classic The Cathedral & the Bazaar is a must read for every developer, manager, and person involved in software at any level.  The essays in this book are all available online, but they are worth having in printed form.  The title essay is a look at how linux bucked the system and released a better products with very little control and it's interesting to read this again now that we have something called agile that's getting popular.  Long before it was cool to speak of continuous integration, linux was doing it.  Also in the book is an essay on "How to be a Hacker" which, aside from answering the question, has help me in the bigger question - how do I identify and hire a hacker (aka passionate software developer).

    image
    image

    I'm listing Beyond the Bullet Points (Cliff Atkinson) and Presentation Zen (Garr Reyonlds) together because I really don't care which book you choose or if you read both - but you need to read at least one.  These books are very well known in the "speaker's circle," but even if you have no plans to become a conference junkie like myself these books are of interest to you.  At some point you will be tasked to give a presentation on your (or your team's) software - status, features, etc - and these are the moments that will lead to career boosts.  Effective presentations skills are not only about communicating the subject matter, they show how competent at understanding and communicating you are.  To be honest, we developers suck worse at communicating than we do at Photoshop - and there is no reason we have to.

    image

    The last book on the list is Seth Godin's The Dip.  We all know life is a series of ups and downs; consider this book a manual to handling the downs.  Only you truly care about your career and you need to be able to decide if the current "dip" (a temporary setback) you face is one to push through or is really a path to a dead end career and it's time to quit and move on.  You could read that other "win-win" book, but Seth is a master of communication and a much more enjoyable author, and I highly recommend subscribing to Seth's Blog.

    I'm always interested in non-development titles that help me as a developer; feel free to add recommendations in the comments.

  • Birmingham Slides and Code

    I had a great time last night in Birmingham hanging out with Robert Cain and speaking to the user group on DataSets.  it may not have been standing room only, but those in attendance had some good questions which is my favorite part of speaking - dealing in the area between ideal design and development reality.

    I've stolen this idea from Alan Stevens - all my code and slides can be found on google code.  Not only does this help me keep track of where the latest version of my slide and code are, but this help attendees who want to look closer at some code I used in a demo.  Google Code has a great source browser, so you don't need to download the entire solution to check out one class.

  • Announcing CodeStock 2008

    imageI'm pleased to announce that planning for Knoxville's first CodeStock is underway!  The website, http://www.codestock.org/ is up now and includes a pre-registration form.

    CodeStock's mission is to bring the best and brightest code experts to East Tennessee for a one day conference open to all developers. This is not a trade show with slick salesman giving prepared demos - this is a gathering of real programmers learning about the latest in technology from each other.

    The pre-registration information is being used to help us plan and secure sponsorship for the event.  You can help by forwarding this to every developer you know!  Signing up on the pre-registration form doesn't lock you into attending, so please sign up even if you're undecided so we can update you as we get closer to the conference.

    CodeStock is not limited to only .Net topics, so share this with your Java and Dynamic Language friends as well!

    (I've been tied up lately checking out venues and getting the website going, so I've been light on the code posts but never fear I have a SilverLight post I'm working on and will return this blog to code posts very soon!)

More Posts Next page »

Our Sponsors

Red-Gate!