02 January 2011

Hello World! in 2011

Knowing I needed less than 40 ASCII characters to pronounce Hello World in FORTRAN, I set about to determine what it would take to do the same in Silverlight using Prism and the Model View ViewModel or MVVM pattern.

Back in the summer of '82, huddled in front of a venerable VAX terminal, I tapped out my first computer program.

Hello World! gave me a chill -- particularly remarkable since this happened in a sweltering computer lab at the University of Minnesota. Our pampered VAX was housed in a chilly meat locker of a room - a room much more accommodating than the undergraduate computer lab with its solitary oscillating fan.

Three glorious lines of FORTRAN. And yes, less than 40 characters of code.

PROGRAM HELLO
PRINT *, 'Hello World!'
END

Hello Silverlight, Buh-Bye Simplicity

Fast forward to 2011. This New Year weekend, I have been struggling with adapting a navigation framework for Microsoft Silverlight using MVVM. The stated intent of MVVM, and similar patterns like MVC, is separation of concerns; namely,
separating the presentation layer from the logic layer 
to make code easier to test and to have a pattern that's easy to build upon and to maintain.

Most of my agile colleagues, and mentors like Chris Bartling, are passionate about test driven development. I use TDD, and I think I understand where TDD shines. But I admit I am slightly more motivated by something as mundane as separation of purpose (i.e., old-school layers), because I like an approach to programming that makes stuff easy to create, re-produce cookie-cutter style, and, down the road, will make it a cinch to maintain or extend. Clean. Easy. Life's good.
Forget the complaints against complexity; instead, complain about confusion.
~ Don Norman
I cling to clean simplicity like so many Buckyballs. I despise sloppy confusion. I despise deciphering widely varied code formatting. I loath wringing drops of value from the software anti-patterns I encounter as a contract programmer. And I frequently go ape-shit unraveling spaghetti code.
If I put the hyphen in anal-retentive when it comes to consistent formatting of code, why do I need a machete to cut a path to my desk?
Yet I have struggled with adapting a canned MVVM navigation framework for Silverlight. Ostensibly, all that's needed is simple navigation. We need to register and load views on demand from a navigation framework. Sounds straight-forward. It ain't.

I started with the Prism Navigation Framework developed by Slobodan "Roboblob" Pavkov. Without Roboblob, I'm not sure where I would have started. Microsoft tends to release software tools that are half-baked and then backfill the shoddy effort with spotty documentation - Don't get me started on Entity Framework!

After 3 days of incisor gnashing, I have been able to adapt Slobodan's laudable work to something that just might suit our needs. I don't belittle Slobodan's framework as it must have taken a yeoman's effort.

Perhaps by necessity the solution to what should be a straight-forward problem, seems painful. By painful I mean fragile, almost inscrutable, difficult to debug, and downright confusing for slightly above-average programmers like me - particularly considering we only need to provide hyper-links that load different views on demand.

Why does something that ain't rocket science have to seem so much like...rocket science?

Hello World 2011 in Silverlight

Writing Hello World in Silverlight, I needed 2 projects:
  • a Silverlight project for the application that includes both the View and the ViewModel, and
  • a web project to render the Silverlight. This project has an HTML file with a tag that references the Silverlight object created above.


It seems that Hello World in 2011 via Silverlight requires,
  • a 74 line HTML file that has the tag containing the Silverlight object;
  • a 55 line XAML file that contains navigation and a container for the View; and
  • some 23 lines of XAML in the View to say Hello World!
Yikes!

Perhaps I've exaggerated the effort since Microsoft makes Hello World so easy that even an aging bonobo with cataracts could code it with 3 clicks and a cut 'n paste. What happens when I need more than Hello World?

I am beginning to wonder about confusing & seemingly gratuitous complexity; albeit confusing complexity added in the good name of testability, flexibility, and modularity. My questions are two-fold:
What is the cost of confusing complexity (necessitated by an ostensibly clean pattern)?
and
How much are we blinded by the laudable lights of testability, flexibility, and modularity?

4 comments:

  1. I am not your average Microsoft basher but I am beginning to think confusing complexity could have been purposely built to create and retain certain 'expert' based communities.

    Big guys like MS make tools so complex or weird that you would have to invest hell of a time and need to become an 'expert' just to be able to use those tools. It is as if only after this torturous loyalty proof her majesty MS might accept you to 'Silverlight' community. Since it is not easy to give up on your heavy investment you would become dependent or addicted to that certain cult-like technology thereafter.

    I have a very talented friend of mine who nowadays litters Buzz and Twitter with nothing but Silverlight news, tricks, tips. I just want to shake him, look deep into his Zombie eyes and say "Wake up man! You are a developer. A DEVELOPER! You are supposed to enjoy writing your algorithms, not trembling with anxiety to learn this tool or that gadget!"

    Apple does the same. I gave up learning how to write iPhone apps as I found out that XCode meant to be a cult. You need to withstand weeks of torture in order to write 'Hello World' with XCode and Interface Builder crap.

    So. I am beginning to think there is a pattern here. Big guys perhaps would like to create and retain their developer cult.

    Open source on the other hand is quite the opposite. Sure there are 'language cults' Perl, Python etc. but at least there is tradition. Things are not thrown out into a garbage bin overnight. Languages and tools are treated like languages and tools. It feels like you have higher return on your investment.

    I understand and share your pain Bob. Good luck anyway.

    ReplyDelete
  2. Ergun,

    I hadn't quite thought of it as a conspiracy perpetrated by would-be experts. But the thought resonates because I never seem to be privy to the "secret handshake" once I obtain competency.

    I need my day job as a Microsoft shill, but I resolve to explore other communities in the coming year.

    Thanks.

    ReplyDelete
  3. If your are going to follow the conspiracy theory then you may enjoy David Ing's Time to Diversify

    http://david.ing.name/2010/12/01/time-to-diversify/

    to quote him: "While I’m sure I’ll be desperate someday with a ‘Will VB.NET For Food’ cardboard sign sat slumped outside an insurance company, today is not that day – this is my Adios .NET post."

    ReplyDelete
  4. David (Koontz),

    I enjoyed David Ing's adios to .NET. In particular, that "The Bazaar is more powerful than the Cathedral."

    Thanks.

    ReplyDelete