When I was in Redmond a few weeks ago I begged ScottGu for a copy of the MVC bits so I could "muse" over how SubSonic would fit in. Scott's a big supporter of what we've been doing with SubSonic, and he gave me his "demo proto bits", which, as Hanselman put it, are but shades of the real thing. Scott was good enough to share with me (I'm under NDA as an MVP so please don't ask - I simply can't share) and yesterday/last night I geeked out a bit.
I'll have more on SubSonic/MVC things in a future post, but I did want to share with you a disturbing experience I had yesterday when I was working up a goofy little demo site: I realized I forgot a lot of HTML and javascript.
I can't tell you how demoralizing this was.
MVC and Server Controls
You can still use server controls with MVC, but you don't have the "WebFormy Postback" sugar that you do with WebForms. To be sure, this is a great way of doing things, but it abstracts away the whole programming thing in general. In other words - there's very little HTML or javascript needed since they do it all for you.
So as I'm working up my demo page, I come across a problem that hits me sideways and really made me feel dumb. Not one to pass up an opportunity to let my readers share in my ignorance - here it is for you. My moment of pain..
The Problem
OK so it wasn't that dramatic. I just had to relearn some HTML and javascript that I forgot. Oh sure, I know how to do tables and divs and all the layout stuff - that's not what I'm talking about. I'm talking about hand-coding radio button lists, checkbox lists, and dropdowns (what we used to call select boxes) that do auto-postback.
Specifically my problem was setting an auto-postback that would refresh a radio button list based on the selected value. Yes, this is embarrassing to be sure! I can't even believe I'm blogging this. I'm sure you know how to do it off the top of your head. So did I! Just a few years back too!
It took all of five minutes to "remember" it (and I decided to use jQuery instead of the "old ASP way" - a lot more fun this way), and I had a good chuckle thinking back on how I "used to do it" with ASP Classic. And that sort of scared me. But then...
Sobering Thoughts
I've lost a whole lot of "Programming English" (insert your native language there) over the last 7 years working in .NET. I have to say it's embarrassing. Yes I can work up most anything in javascript, but it doesn't come to me as quickly as it should and I have to resort to Google far more often than I'd like to. I don't do ANY form-based HTML, however.
Many of you will take this as a justification to keep using WebForms (why should we code all this stuff by hand, etc) - and I think that's just fine. I think you lose a little in the end, but WebForms aren't going anywhere!
Personally, as a "web programmer" I feel pretty disconnected, I must say, from my brethren "across town" who sometimes cross the tracks and make fun of us MS/ASP.NET guys. Throwing stones at our IDE and it's designer surface - calling our "one form per page" a big sissy.
Sometimes I think they have a point. I just wish they could express it without the tired FUD rhetoric. We really ought to be listening to each other - isn't this what MIX is all about (aside from showing that "look it works on a Mac!")?
If I may - I think their point is that VS and ASP.NET are pretty cushy (aka Big Massive Abstraction) and do all the work for us, and we've become "platform engineers" that have strayed pretty far from the core of web programming, which is HTML, CSS, and javascript.
Sure we may know about it at a high level - but can you call it up when needed? Like in an interview? OK then! You're on!
Thank you for coming today to interview for the position of Web Alpha Geek. I've worked up a little technical question for you here... let's see... oh yes, here it is:
"Create an HTML page, without server controls, that posts data back to a server when the selection in a select box has changed. The page needs to work in all browsers, and the selection needs to remain "in state" in the select list. No javascript libraries please - this must be done by hand.
You have 5 minutes and no Google..."
As silly as the context of Neelin here, truer words were never spoke. It's come full circle. I don't think things get lost, just fuzzy. Then we hop on the bike again...
Concerning the boys on the other side of town, sure I can get "sissy", but eliminating those mundane repetative tasks has allowed us to concentrate on more important things I suppose.
Keep it up!
RA
Often I'll have the probem in reverse, I'll remember how to easily do something in PHP/classic ASP/erb/HTML but I'll look blankly at a fresh WebForm and have no idea how to do it via postback. The light bulb does go on finally but it's after having to unscrew my head a little. WebForms and server controls have always bothered me because they always felt like they were designed by an application developer trying to hammer the Internet into the VB programming model.
Of course Rails can make you stupid as well with all their nifty helper functions for outputting radio and select lists.
One last little gripe about ASP.NET server controls, I *hate* the fact that the id attribute becomes worthless if you want to use it with a JavaScript framework or CSS. While I love a lot about ASP.NET that one little thing makes me hate it so much at times that I have to count to ten. Nothing like getting a super clean CSS XHTML from a designer and realize any form element they've styled via id is going to have to be replaced with hackery.
Care to answer how you'd do the question Mr. Smarty Man?
Here is one way to do it, but I am not a geek:
-- edited -- thanks J i had to take out the code. WordPress is being whacky...
Personally, I cannot wait until the day where I can abandon antiquaited, idiosynchratic technologies like HTML, CSS et. al. That's partially why Silverlight excites me. I'd much rather work with XAML/WPF than having to contend with browser hacks and CSS tricks. Now if only Microsoft would port the entire WPF framework and clean it up a bit...
I'm not going to post some HTML and/or JavaScript here to prove I know it. I know I do, and I think my Web.Maps.VE ASP.NET Ajax Virtual Earth Mapping Server Control (http://simplovation.com/Page/WebMapsVE.aspx) pretty much demonstrates it.
I really like the HML controls in the framework and wonder why us Microsoft guys don't make use of them.
I think that both CSS and JavaScript are still things that a web developer needs to know. I just think it's a shame that most on the dotnet framework have forgotten all we learned in the run-up to 2001.
I have built up my own little ideas on how I like to use asp.net. They revolve around heavy use of repeaters and form views. I use anchors "A" set to runat equals server and a full set of html tags out of the generic html library. But controls like the dropdownlist and checkbox list are great, because they are so enumerable aware.
I think in terms of master pages and controls now, and that helps my ability to use a full implementation of CSS in my sites.
In JavaScript, I have had to change my methods, and use relative calls instead of calling into an id that I might switch to server side and get bollixed up in the asp.net id scoping. Which really meant all I had to learn was how to write recursion into my JavaScript functions.
I have gotten out of the DAL "data access layer" business, and instead use the SQLDataObject as an inheritable base class in custom objects.
All of this makes for a quick, tidy implementation that is very CSS capable and doesn't mess too much with the ability to continue to code things in JavaScript.
-- I had to edit this - it broke the page. Damn wordpress...
I can forgive people not knowing their JavaScript, because cross-browser JavaScript is akin to cross-platform C programming. It's a bloody mess I wouldn't wish on my worst enemy. Thankfully, several good JavaScript libraries like jQuery, Prototype, mootools, etc. have emerged to abstract this mess, but they're just one more thing a programmer has to learn to be productive, which sucks.
Plus there's this whole "Javascript has functional programming language constructs so let's use them!" movement sponsored by smart guys like Douglas Crockford which just make learning JavaScript DOM programming even more formidable than it already is for your average Joe programmer.
There are just way too many things a programmer needs to learn to be productive as a .NET Web application developer. Here's a list:
Two, sometimes three, different JavaScript, CSS, HTML dialects (IE6, Firefox, IE7, Safari)
Two, sometimes three, different versions of C# or VB.NET (1.1, 2.0, 3.5)
Two, sometimes three, different Web Services platforms (ASMX, ASMX WSE, WCF)
Two, sometimes three, different versions of SQL Server or ORACLE (2000/9i, 2005/10g, 2008/11g)
Two, sometimes three, different dialects of SQL (T-SQL, PL/SQL, generic SQL)
Two, sometimes three, different unit testing platforms (VSTS, NUnit, MbUnit)
Visual Studio (MSBUILD, Web Deployment Projects, VSTS, SourceSafe)
On a unrelated note, I hate "whiteboard coding" questions in job interviews, because it's an unrealistic environment to write code in. Yes, I'm looking at you, Microsoft. If everybody loves whiteboard coding so much, then why haven't we made this possible in our actual development IDE's? Please don't take that as a suggestion to do so.
Anyway enough with the rants, I'm starting to feel like the Lewis Black of .NET here...
Wouldn't it be better for MS to just write tools/VS add-ins to work better with MonoRail? Instead we have a new platform that MS has devoted to and then it will move developers to another project and its initial release will be missing some features and we will have to wait for to implement (i.e. WCF, WPF, WPF UI, Silverlight etc.)
So...this sounds great and I definitely want to play with it, but once again I hope MS doesn't make this a 1.0 release we have to wait up to 2 years to implement in real-life scenarios.
http://www.odetocode.com/Articles/473.aspx article. "What ASP.NET
Developers Should Know About JavaScript" I thought it was pretty
good and thought of this conversation. And I agree with the
article, that this should be the ASP.net developer's level of
competence with our default client scripting language. Well I have
always had a problem with the default stance that everything
Microsoft did was bad, I have worked with their products my whole
career. But equally I have a problem with the dotnet crowd thinking
that they can ignore JavaScript and CSS. ps. Sorry I broke your
page.
wasting my time here. My previous comment was like 1,000 characters
and look at what it did with it. Ridiclulous... Here goes the
second attempt... --- Hehe I had a couple free moments so I decided
to whip it up in JSP. Boy, this sure made me appreciate ASP.NET. If
us "geeks" really have lost something, I think it was worth letting
go! Here is what I came up with... <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<title>JSP Test for Josh</title> </head>
<body> <form action="test.jsp" method="post"> <% int
numIndex = 1; String strSelection =
request.getParameter("ddlOptions"); if (strSelection != null) {
%> <h1>Selection has been made!</h1> <% } %>
<select id="ddlOptions"
onchange="document.forms[0].submit()"> <% while (numIndex
< 6) { if(strSelection == numIndex.toString()) { %>
<option value="<%= numIndex %>"
selected="selected"><%= numIndex %></option> <% }
else { %> <option value="<%= numIndex %>"><%=
numIndex %></option> <% } } %> </select>
<input type="submit" value="Go For It!" /> </form>
</body> </html> Thanks for the challenge!
I just ran into the situation myself a few weeks back where I was
stumped on something that should have been easy to me. @Joe - As
always you bring class and provoke good conversations in any post
you comment on. I am proud to work with you.
http://channel8.msdn.com/Posts/Codeplex-an-Open-Source-project-from-Microsoft/
Look... they mention SubSonic :)