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.

July 2008 - Posts

  • 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.

More Posts

Our Sponsors

Proudly Partnered With