Scott Hanselman

Who ever said software development was just another job?

June 03, 2004 Comment on this post [0] Posted in XML
Sponsored By

This was just too good not to share…emphasis is mine.

Via Peter Provost, I came upon Kris Syverstad’s post drawing an analogy between great software developers and great athletes. Kris’s post in two sentences: Great developers and great athletes strive to be the best, and have the talent and drive to become so. The best developers are the ones who seek out help when they need it, and take steps to actively seek out learning opportunities on their own.

I think Kris’s analogy is right on. I found it ironic that Kris very clearly lays out the attitude one needs to excel in this business, and the absolute antithesis of this attitude is displayed in one of his comments. The comment I’m referring to was “[Building your skills on your own] takes time outside of your 40 hour work week and it is unpaid. So, what is the incentive?” 

Hrmm…investing in yourself? Personal pride? The desire to be the best? Loving what you do?  

I’ve had the privilege of working with some really, really great developers. I’ll tell you one thing they all have in common: software isn’t something they just do for 40 hours a week to pay the bills. [Brain.Save()]

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

ComputerZen.com - Episodes you may have missed...

June 03, 2004 Comment on this post [2] Posted in ASP.NET | Web Services | DasBlog | XmlSerializer | Speaking | PDC
Sponsored By

It's the wife's birthday so I shall be out of pocket for the weekend and I may not have time to blog.  But, I realized that I have a whole 2+ years of blogging up here that you may have missed.

Thus, I present "Syndicated ComputerZen in Syndication or Episodes You May Have Missed" for your pleasure. 

  • Bringing data "along for the ride" with CheckBoxes and the ASP.NET DataGrid
    Work WITH the Grid, not against it;  Listen to the Events and Nudge/Influence the Grid; just because code is on CodeProject or in Google Groups doesn't mean the writer knows the DataGrid from his own Ass.
  • ASP.NET: Postbacks for Algernon
    Pretty PostBacks when using RewritePath; Complex Custom Confirmation Dialogs on LinkButtons in DataGrids while STILL maintaining PostBacks (whew!)
  • But what price my soul?  The one where I muse about the potential for going to hell for writing really smelly code.  What to do when you've built a great monument, but there's bird poop at the top that you're responsible for.  Does it take away from the accomplishment?
  • Exporting Tabular Data to Excel from ASP.NET  My #1 most popular post.  Geez...look at the Referral List.  It's worth checking out.  Amazing.
  • XmlSerializer Madness Learning about when the XmlSerializer caches its generated assemblies, and when it doesn't.
  • The Day I Moblogged the PDC Keynote The lengendary post where I blogged the PDC Keynote from the only device with coverage - my BlackBerry.  My left thumb, in particular, has yet to recover.

If you find it useful, I may dig in to the archives again. (This post was brought to you by the upcoming dasBlog MonthView.)

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

The Winners are Announced (Finally) in the TabletPC "Think In Ink" PowerToy contest

June 02, 2004 Comment on this post [2] Posted in Programming | Tools
Sponsored By

The winners are in (I turned mine in minutes before the deadline and spent 17 minutes on it) for the Does Your Code Think In Ink Contest.

Thanks to Julia for noticing the announcement in PC Magazine via TabletPCTalk.

The Grand Prize ($15K!) let you create your own Font with your handwriting.  That's a pretty amazing concept.

The First Runner Up is weird...kind of like Alias SketchBookPro on LSD.

And my little sad applet that won me $2500 and a copy of Visual Studio Enterprise Developer (which is available for sale) was originally called "ZenBar," then "GoogleBar" and was changed by the contest owners when it was packaged up into an MSI to "Web Search Power Tool."  I thank them very much for the righteous changes. 

Additionally, big ups to my homies over at Tabula PC for a great writeup on the tools and what they do.  They said "If it weren't for this last runner up, I'd be really dejected right about now. Scott Hanselman saves the day! His Web Search Power Tool may not be pretty or glamorous, but is exactly what I want from a power tool - it's actually useful."

Also interesting to note is that I apparently live in South Carolina if you believe PC Magazine.  Considering that I live in Oregon and that I know no one in S.C., it'd be interesting to learn when and how I moved there, and how long I'll stay. :)

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Returning DataSets from WebServices is the Spawn of Satan and Represents All That Is Truly Evil in the World

June 01, 2004 Comment on this post [11] Posted in TechEd | Web Services | XML
Sponsored By

(Nah, I don't really believe that, but it's a good title, no?  DataSets have there place, just not as publically visible Business Objects or from publically accessible WebServices.)

Barry Gervin commented on my "quick bash at DataSets" and that I didn't explain my reasonining.  In his post, Barry commented on Harry Pierson's statement that one shouldn't use DataSets in a Web Service because they aren't compatible with non .NET Platforms.  Barry says, "This isn't true. A DataSet is just XML."  Well, of course it's XML, but if I say, hey take this sentence, it's in the ASCII character set (who care's if it isn't English) Le "DataSet" n'est pas votre ami si vous faites des Services de Web.  Well, Barry can understand that, but I no hablo French. ;)

DataSets are bowls, not fruit.  Do you really want to return bowls?

A DataSet is an object, right?  But it's not a Domain Object, it's not an "Apple" or "Orange" - it's an object of type "DataSet."  A DataSet is a bowl (one that knows about the backing Data Store).  A DataSet is an object that knows how to HOLD Rows and Columns.  It's an object that knows a LOT about the Database.  But I don't want to return bowls.  I want to return Domain Objects, like "Apples."

"Use Strongly Typed DataSets," you say.  "They are the same as Objects, and look how intellisquish works now!"

No, they still aren't Domain Objects, a Strongly Typed DataSet is just a bowl with a picture of an Apple on it.  "Look there's an Apple INSIDE - we've broken it down into columns!"  DataSets are a shoddy replacement for a good Domain Model (and that includes Strongly Typed DataSets). 

Barry has a very good argument for the use of DataSets on his site, and I won't go through his list agreeing and disagreeing with various points.  I will say this, however, it seems that his arguments support the use of DataSets in a Data Access Layer - not in a Business Object Layer.  THAT I would support.  Additionally I understand the usefulness of DataSets in a classic (intranet) Client-Server WinForms app with lots of DataBinding. 

Returning DataSets from a publically accessible Web Service is a BAD IDEA©.

Now, why shouldn't we return DataSets from WebServices?  DataSets and their serialized XML format includes a pile of information that has little to do with the Domain Model itself.  DataSets may be DiffGrams, they may or may not include schema, and they represent "Sets of Data."  They are an object of one type, DataSet.  Whether there is a Java version of a DataSet object available doesn't matter.  They are late-bound by nature, as even a Strongly Typed DataSet encapsulates conversion of types back and forth from SqlDataTypes to typical CLR types and calls to Rows["Apple"].  DataSets are the Class equivalent of an Variant - an Object that can be any kind of Object - only serializable as XML.  Returning an object of type DataSet or Typed DataSet via publically accessible Web Service would succeed only in confusing a Java person, stymying any chance of interop, and giving them more ammo to use against .NET.

To be clear, I WOULD architect a system that included DataSets if I felt that they provided an exceptional value.  I'm just promoting that folks BE AWARE of the ramifications of their decisions.


Tagential aside: There's some yummy best practices up on TheServerSide.NET.  Here's my favorites:

  • Using a DataReader vs. a DataSet: The DataReader was of course faster. It was faster by 16% in this particular case.
  • SQLDataReader vs. OleDBDataReader: Going with native drivers is always better. The SQLDataReader was 115% faster than going through OLE.
  • DataReader Column Reference - By Name, Ordinal, or GetString(): The order of speed? dr[0] was the fastest, followed by dr["ProductName"], followed by dr.GetString(0) as it has to do the conversion.
  • Inline (DataReader) vs. Controls (DataGrid): The inline script was 233% faster than a DataGrid component.

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

A reminder on "Three/Multi Tier/Layer Architecture/Design" brought to you by my late night frustrations.

June 01, 2004 Comment on this post [16] Posted in ASP.NET | Learning .NET | Web Services | DasBlog | XML | HttpHandler
Sponsored By

I was going over some C# code that was written for a non-profit earlier this year.  It was fairly typical code and that's what disturbed me so.  It consisted of a single ASP.NET Application with most of the work happening in the Page_Load.  Although there was only one database, the connection string to that database appeared in at least a dozen places throughout the code.  There were a few places where a SELECT * from WHATEVER occurred and they spun through a DataReader in order to set a boolean called "HasRows" to true. 

So, I had to do something.  I understand that not everyone cares, and that not everyone had (or chose to have) any formal Computer Science or Software Engineering academic life (not that there's anything wrong with that.)

Disclaimer: This post is just general advice.  I know that reams of paper have been written on how to design software, layers, tiers, services, etc.  This post is just to remind a few people that you can't have multiple layers until you start thinking about the responsibility of each layer - the contract and binding.  Life has hierarchies and layers and responsibility - and so should most software.

That being said, here's little reminder about layers of abstraction.  They are typically a good thing.  Remember though, that in "Scott World" (which is hopefully your world also :) ) a "Tier" is a unit of deployment, while a "Layer" is a logical separation of responsibility within code.  You may say you have a "3-tier" system, but be running it on one laptop.  You may say your have a "3-layer" system, but have only ASP.NET pages that talk to a database.  There's power in precision, friends.

  • The Presentation Layer: For the vast majority of programmers who are doing ASP.NET, your pages live for one reason, to present an interface to the user.  That is usually HTML/XML. (ya, ya, I know you might produce WML, CHTML, or GIFs with HttpHandlers but this whole post is a generalization)
    • Things your pages shouldn't know about: Your pages shouldn't know that a physical data store exists.  DasBlog does a lovely job of abstracting away the data store and presenting only an object model to the user.  Your ASP.NET pages shouldn't know about connection strings, Connections, Commands, or anything like that.
    • Things your pages should know about: Your pages should know about your Domain Model.  Your objects, your stuff.  If you're a librarian, I suspect you'll have a Book object.  Perhaps a Librarian Service that knows how to Get and CheckOut books.  He/She (the Service) no doubt knows how to Search for Books also. 
  • The Business Logic Layer: 
    • Things your BizLogic Layer shouldn't know about: Ideally your business logic layer shouldn't know there is a database.  It shouldn't know about connection strings or SQL.  It shouldn't know about much of anything except whatever format you choose to represent your objects in (preferably NOT DataSets.)
    • Things your BizLogic Layer should know about: It should know about business rules (This payment will need 5 days of lead-time to be paid, or that book can't be checked out by two people at once) but not the details of storage.  It might present public methods like "GetBookByISBN" or "CheckOutBook(Book b)" or "ReturnBook(Book b)."
  • The Data Access Layer: Depending on how "purist" you want to get, you can merge the DAL with the Business Layer.  At a minimum you should be able to perform CRUD operations.  Create, Read, Update, Delete.  Fundamentally most apps are just GETS of stuff and PUTS of stuff.  Keep it simple.  If your backing data store is XML files, or a Web Service or a Database, it shouldn't matter, and ideally your Business Layer (above) doesn't even know!  It knows there's a DAL to talk to, but it's all about responsibility.  If you are designing a layer, know your in's and out's and for Goodness' Sake know your responsibility.  If you don't, back to the drawing board until you do.
    • Things your Data Access Layer shouldn't know about: It shouldn't know about HTML, and it shouldn't know about ASP.NET.  It should avoid knowing about business rules that don't related directly to how the data is stored (like cardinality.)
    • Things your Data Access Layer should know about: It should know about accessing data in whatever form it's stored.  It might have functions like "InsertBook(string name, string isbn)" or "InsertBook(Book b)" if you don't mind it knowing about your Business Objects (I usually don't).  It should act as an Adapter between your Data Access Layer and your Data Store.
  • The Data Store: This might be a SQL Server; then you'll need CRUD Stored Procedures to ReadBooks, UpdateBooks, etc.
    • Things your Data Store shouldn't know about: Your Data Store shouldn't be generating messages in language.  That means don't have your Stored Procs generate English messages.  Sounds silly, but I've seen it before in the wild, so it bears repeating.  It's your Data Store's job to get data to the DAL, and little else. 
    • Things your Data Store should know about: Storing stuff.  'Nuff said.

This may seem overkill, but believe me, once you've done it a few times, you'll appreciate it when you come back to mess with the code in the future.  Remember also that much of this CRUD stuff can be auto-generated by CodeSmith or by Deklarit.  Please, do resist the urge to open up a SqlConnection from your next ASP.NET page.

Why should you do this?  Because of the 'ilities and because the simplest even-slightly layered design hides complexity. 

  • Flexibility: "The ease with which a system or component can be modified for use in applications or environments other than those for which it was specifically designed."
  • Maintainability: "The ease with which a software system or component can be modified to correct faults, improve performance, or other attributes, or adapt to a changed environment."
  • Reusability: "The degree to which a software module or other work product can be used in more than one computing program or software system."
  • Scalability: "The ease with which a system or component can adjust to changing load."
    [All these definitions are from the IEEE Standard Computer Dictionary.]

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

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