Scott Hanselman

INETA - Check us out at TechEd, and congrats to all the new addtions

May 29, '03 Comments [2] Posted in Web Services | ASP.NET | TechEd | Speaking
Sponsored By

This is an exciting thing! INETA (the International .NET Association) is announcing additions to its Speaker's BureauKeith Pleas has the story on his blog now before the press release goes out.

INETA manages this group of speakers who jaunt around the world presenting at .NET Users Groups.  There's a lot of great presenters already in there, including folks I'm proud to call my colleagues, Carl Franklin, Billy Hollis, Tim Huckaby, Chris Kinsman, Juval Löwy, Paul Sheriff, Ken Spencer, Scott Stanfield, and the inimitable Keith Pleas among many others.

Turns out I've been asked to join INETA as well!  I'll be in Seattle at the .NET Developers Association in July presenting How I Stopped Worrying and Learned to Love ASP.NET.

Also in the list of 13 new additions to the Bureau are my friend Sam Gentile, Jon Box from Quilogy, Andrew Brust from Progressive Systems, Canadian and all-around cool person Kate Gregory, The ADO Guy Shawn Wildermuth, and the party king of Bawston, Mass, the fantastic Patrick Hynds.

Check INETA out at the INETA Ask the Experts Booth at TechEd next week!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Angst, ISO Standards, DataBinding Eval(), Malaise, DataGrids, System.Globalization, Fritz and the morning after...

May 29, '03 Comments [1] Posted in Web Services | ASP.NET | Javascript | Internationalization | XML
Sponsored By

Not much blogging this week...here's what I've been rambling about lately.

The DataGrid

I've had my head down in ASP.NET and the Data Grid control.  Our eFinance Application Server makes extensive use of what I like to call "strongly-typed XML" (XML with associated XSDs/XML Schema) and I've been doing lots of lovely DataGrids with Sorting, Filtering, etc as well as some dynamic charts. 

Globalization

I'm also deep in my most favorite (or is that favourite?) namespace, System.Globalization.  It's just so well thought out.  Lots of great stuff in here and much use of ISO standards like ISO 4217 for currency and number formatting (JPY, USD, GBP, ZWD, etc) and ISO 3166 for country codes (JP, US, GB, ZW, etc)...see a pattern?  I'm one of those dorks that dug the Dewey Decimal System and I dig nice ordered category systems now. 

One interesting thing, I'm running into a bit of trouble with number formatting, which I would have preferred to relegate entirely to the ASPX page...as if the ASPX page were truly the "View" to my Code-Behind "Controller."  While that's the dream, it's hardly the reality.  This kind of formatting creeps into my code-behinds, and leaps in to them when dealing with culture-specific data input.

A not-quite-perfect-pattern

Things get so mixed up between ASPX and Code-Behind on a moderately complex ASP.NET page (considering a multi-lingual site and multi-currency-in-one-grid situation), once you factor in DataBinding Eval() statements, Totals in Footers, Sorting and Filtering, it really makes me question the whole ASP.NET code-behind paradigm.  Sometimes my DataGrid event handlers feel better on the OnEventWhatever attributes of the DataGrid tag in the ASPX, and sometimes I just hook them up ala C# += EventHandlers in InitializeComponent().  Even Dino Esposito, a prolific writer on the DataGrid, puts page formatting all over the place in code-behinds (at the bottom) in his articles (although I take all article code with a mountain-sized grain of salt) apparently because there's just no other way to do it.

Is elegance possible?

Perhaps I've tried to fit too many hopes and dreams in a DataGrid and I should just grin and bear the tragic inelegance of it all.  After ten-plus years of Web Development [ah, I long for the days where I was 00001.0003@compuserve.com, ;) ] perhaps some higher power is trying to hint to me that rich cross-browser UIs just can't be truly "elegant" on what is perhaps a fatally flawed super-stateless HTML/QUIRKSMODE/HTTP/DOM/JAVASCRIPT/BAILINGWIRE base? 

Or...

alternately, it's 1am and time for bed.  In conclusion, I will say this: I can get more done in ASP.NET in a day than I could in Classic ASP in a fortnight and I don't have that lingering sense of next-morning shame that came with a truly horrendous ASP hack - and Fritz Onion played no small part in this personal achievement.

Today's Query

Other than building my own reverse-lookup hashtable at Application.Start, does anyone seen an obvious (or not obvious) and fast way given a currency string ("USD", etc) to get a CultureInfo and a NumberFormatInfo?  Perhaps I'm missing something obvious.

UPDATE: Peter Provost has a eye-opening reply post about this topic that makes a lot of sense to me.  If I start thinking about ASPX files and code-behinds as two sides of the same coin, then more "classical" MVC architectures fit nicely into the ASP.NET model.  I was stuck on what I felt was lack of elegance in interface between the two.  I'll try suspending belief for a bit and see what comes of it... :)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Not a bad weekend...

May 27, '03 Comments [2] Posted in Web Services | ASP.NET | TechEd | Speaking | Gaming
Sponsored By

Not a bad weekend, here's the highlights:

  • My wife bought a Honda Civic Hybrid.  The average mileage of my household is now ~50MPG considering my other car.
  • Enter The Matrix is truly amazing, and the video footage is also snazzy, adding a great deal (IMHO) of content and insight into the story.  Although, there is a bizzarre kiss between Niobe (Jada Pinkett) and Persephone (Monica Bellucci) that did make me wonder if this "exclusive footage" isn't really just "extra footage."
  • TechEd is going to be very snazzy this year.  If you spot me, please do say Hello.  Also, if you are in my DEV389 session, please start "the wave."
  • I continue to be impressed with ASP.NET 1.x.  I'm also convinced of two things:
         1. ASP.NET 2.0 is going to rock. 
         2. The whole "stateless web"-page-view-browser-metaphor, while scalable, is starting to wear on me.  
         3. Still, I long for the days where I'd telnet to cdconnection.com and send my credit card screaming in plaintext across the 'net. :)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

A tale of two techniques: The [ThreadStatic] Attribute and System.Web.HttpContext.Current.Items

May 23, '03 Comments [10] Posted in Web Services | ASP.NET
Sponsored By

Today's lesson learned: the [ThreadStatic] attribute is only useful when YOU control the ThreadPool (and the lifecycle of the threads).  It also reminds one to think about variable scope/lifetime especially in the context of ASP.NET. 

An interesting day and I ran into some code that made interesting (and arguably not necessary use of a static member variable).  More and more I feel that static member variables (whether hidden by a property accessor) will bite you in the ass unless they were really meant to be readonly (WORM - write once read many) variables. 

Two interesting things:

1. I noticed this behavior and saw that the fantastically smart Chris Brumme had good things to say about on DevelopMentor's DOTNET List.   It's kind of a DUH moment when you realize it of course it should work that way.   Definitely don't count on the constructors of static fields marked with ThreadStatic.

2. Don't slap a [ThreadStatic] attribute on a static member when you're operating within ASP.NET as chances are you don't control the thread life...you inherit a worker thread.  ThreadStatic gives you thread local storage, not HttpContext local storage!  If you need to store something away to be used later in the same HTTP request, think about my favorite ASP.NET class, the little-known and not-used-enough System.Web.HttpContext.Current.Items (aside: great article by Susan Warren on Context).  In ASP.NET your code is run on a WorkerThread from the 25 or so threads in the default ASP.NET worker thread pool and the variable that you think is "personal private to your thread" is personal private...to you and every other request that this worker thread has been with.  Under load you may well find your variable modified.

To sum up places to stash things in ASP.NET:

Object Description
Application A key/value pair collection of values that is accessible by every user of the application.
Cache The ASP.NET Cache object, which provides programmatic access to the cache. Arguably a fancier face on Application.
Items A key-value pair collection that you can use to pass information between all of the components that participate in the processing of a single HTTP request. This is a great place to put things that need to be shared between ASP.NET pages and components farther downstream that will inherit the current HttpContext.
Session A key/value pair collection of values that are accessible by a single user of the application (When using InProc Session in ASP.NET 1.0 Session is really just a pretty indexed-by-cookie-guid face on the Cache object!)

When using ASP.NET think twice, then think again, before throwing that static (or Shared) keyword in there.  Perhaps there is a scope better suited for what you're trying to do.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

More .NET Purity discussions...

May 16, '03 Comments [2] Posted in Web Services | ASP.NET
Sponsored By

Lots of good debate and discussion on the Myth of .NET Purity from a number of very nice people as well as some nice links and comment threads.

Some people were a little taken aback and invoked Rotor and Mono to illustrate the importance of Purity and Code Portability.  I replied in a few comments posts, but re-print my position here:

One fellow agreed and said "If you want to do cool stuff the vise gets a bit tighter."

Another fellow mentioned the JVM and the CLI to which I responded: Note that you started using "CLI" in your sentence, rather than the ".NET Framework" or the "CLR." Certainly the CLI (common language infrastructure) as a concept is great and is obviously portable, having been ported as Mono and Rotor. But I'm not talking about the CLI. Rather, we should remember the underneath any layer of abstraction (leaky or not) there is an implementation. The point of my article was to remind folks that the Microsoft Windows implementation - the CLR and .NET BCL (base class library) - depend HEAVILY on the underlying behavior, libraries and services of the Windows OS. Code Portability (certainly desirable for some, less so for others) is certainly possible at the C# and IL level, but writing cross CLI implementation C# is no different than writing cross platform "C." Think about that. When writing cross platform code (often confused with 100% whatever, and there's a difference!) one has to consider: compiler behavior, interfaces, the OSs underlying implementation of the API, the level at which the API was written, etc.

One surely can't expect a very complex C# Winforms app with all the fancy GDI+ goodness and user controls to just work on Mono (unless I'm missing something) - not until the underlying implementation of ALL the dependancies are written and implementing using whatever Linux OS primitives are required to provide these features.

My rant was originally prompted by a fellow who was saying that he was writing some WinForms to ASP.NET Web Services app and that he was writing it in "100% Pure .NET" to INSULATE HIMSELF FROM RISK in some way. Like he'd be protected and have code portabilty if he just made sure to do it all in .NET. And that is a Myth. Code and life are a lot more complex than a sound bite like "100% .NET." - Scott Hanselman

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.