Public musings, often on software development RSS 2.0
# Monday, October 27, 2008

So although I've been heads down, I have noticed that .NET 4.0 and the latest Visual Studio 2010 CTP have been released.  There are alot of great things coming but one which may cause a little confusion based on it's name is CoVariance.  Both C# and VB are getting CoVariance but what does that mean.  Well let's start with generics.  When teaching I like to introduce generics by saying “OK now this feature is called ‘generics’ but it’s all about specifics.”  I then discuss how polymorphism allows us to generically handle an object but how that can introduce two issues (1. minor is boxing 2. major is loss of type checking - since everything is an object)  What ‘generics’ allow us to do is to tell the compiler which specific type will be in a collection and that resolves both of those issues in our benefit.  This is an abreviation of a full explanation and added simply to place CoVariance in context, since it deals strictly with generics.

 

Unfortunately one of the challenges with generics is that you can cast a List<string> into a method thats looking for a list of objects list<integer> and just allow the code to run against whichever generic collection containing either strings or ints you pass in.  Now, even in VB6 it was not uncommon to have several different buttons connected to the same event handler.  In fact if you have a grid or similar construct with embedded controls this is still a common pattern, where the event handler is told which row the event came from.  The reason is very simple, each row will have a similar piece of code that differs only by which row should be impacted and you wouldn’t want to rewrite that code.  

 

Similarly, you probably have several different collections each of which is associated with a specific type through a generic declaration.  There will be certain actions that you want to take on any of those different specific collections.  This new feature allows you to define a single method and tell it to execute on any of the generic collections which support it’s expected interface.  The idea is you can have a single copy of your code that knows how to work generically with the different collections associated with different specific types, that you will pass it.  The good news is the compiler can see the type information for every planned access and even do type checking for each different type, thus you get the power of a polymorphic object with all the compiler based safety of strong typing.

 

 

Monday, October 27, 2008 4:33:28 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
.NET | Technology | Visual Basic
# Wednesday, October 15, 2008

Although apparently the author of the article isn't a big fan - kudos to President Bush for allowing local park managers to decide whether or not to allow mountain bikes within the park.  Note that this doesn't automatically grant Mountain Bike access throughout the park, but rather allows the local park manager who will be familiar with where such access is appropriate (away from endangered flora and fauna) to grant such access and generally manage that portion of the park.  In terms of comparison to something motorized, mountain bikes are significantly lower impact (many of the damages associated with bikers are found with hikers - the only one that would really be different imho is erosion impact)

http://nbcsports.msnbc.com/id/27183753/wid/18298287/?GT1=45002

Wednesday, October 15, 2008 10:04:46 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
Cycling

I ran into some code today which caught me off guard.  In the event handler for the Exit menu item was the command:

Application.Current.Shutdown()

(Note I've omitted the ; for C# syntax vs VB)

Now traditionally I've always used:

Close()

(I've omitted the 'this' or 'me' as well as the ; for those looking for language specifics...)

So is there a difference and is one better?  Well there is definitely a difference and in my opinion each is definitely better in a certain scenario.

The core similarlity is that both need to be called from your main application window thread in order to shut the application.  Thus calling close on a dialog doesn't shutdown your application, although calling shutdown from your main thread even in a dialog will...  each will also call all the appropriate events for closeing windows and disposing of objects.

The core difference comes down to how your main application thread responds to the events which are fired as it prepares to close.  The Shutdown command is unstoppable the app will close regardless of what one of the event handlers attempts.  However, the Window_Closing (in WPF) event allows you to update the status of the CancelEventArgs (e) to indicate that the shutdown should be prevented.  Thus if for example the user asked to exit and then the app said "but you have unsaved changes Save, Continue, Cancel?" which is something typically caught in the Window Closing event (since it's triggered when you click that cute little X in the upper right corner to close your window). 

The problem - if you've called Shutdown, it doesn't matter if the user says - "Cancel" your app is slamming down. 

Thus unless you are attempting to handle a sudden error condition ("Must stop now to avoid corrupting data.") you probably want to rely on the Window.Close() method instead of the Application.Shutdown method.

Wednesday, October 15, 2008 4:05:55 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
.NET | Technology | Visual Basic
# Tuesday, October 14, 2008

Well in theory the correct title for the group is the ASP.NET Special Interest Group of the San Diego .NET Users Group, but that didn't flow in the post title.  I'm speaking at their meeting on the 21st in relation ot SharePoint and ASP.NET.  Here's the description of the session I'll be doing:

SharePoint and its feature enriched cousin Microsoft Office SharePoint Server (MOSS) are becoming a standard part of company web properties.  As such ASP.NET developers need to understand how to create custom applications which can leverage this Microsoft product.  This presentation is going to look at setting up a shared SharePoint and ASP.NET development environment.  It will then look at debugging for custom workflow applications and examine a custom ASP.NET Web Service which leverages the OpenXML office document format to generate a Word document on the server and add that document into a SharePoint document library.  The presentation will leverage the Sales Forecast OBA code base which is publicly available on CodePlex with a focus on the ASP.NET , Visual Studio 2008 and SharePoint integration.  

 

The meetings are held at the Microsoft San Diego offices in La Jolla.  For more information go to their website at:

http://www.sandiegodotnet.com/Meetings/ASPNETSIG/tabid/59/ctl/Details/Mid/387/ItemID/113/Default.aspx?selecteddate=10/21/2008

Tuesday, October 14, 2008 4:38:38 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
.NET | Technology
# Friday, October 10, 2008

One of those things that just make me shake my head...

I have a computer I keep in the company domain.  Someone or something (I don't know who or what and to be honest don't care enough to find out, just enough to document the insanity) appears to have created a policy either at the domain or on my machine that automatically resets the default printer to OneNote.

For starters this is bad because it means that even though I go to the effort to make Printer 'x' my default because it's close to my office, the next time I restart, I instead have my default printer reset to OneNote... which is pretty annoying.

But a better question is why given that I already have an electronic copy of whatever it is I want to print I would want to print it to One Note.... so I could have an electronic copy... 

More importantly it pretty much kills all those nice print short cuts MS put on everything where I can with a single click print whatever I want to my default printer... but, nope doing that just causes my system to pause while OneNote starts - wasting my time - so I can shut OneNote - wasting my time - and go through the full multi-step process of selecting a printer - wasting, well you get the point.

I hate to think that it's just the act of installing OneNote that does this...

http://connect.microsoft.com/onenote/feedback/ViewFeedback.aspx?FeedbackID=363469

Friday, October 10, 2008 3:02:16 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
Musings
# Monday, October 06, 2008

Monday, October 06, 2008 11:43:28 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -

So after quite the busy Spring I needed some downtime so I haven't posted in a while.  I was all set to restrart posting back in September with a post that will be coming online here shortly but although I had done the work, things got hectic and so posting was postponed. 

Well it's time to get rolling again.  I have the book I finished at the start of Summer coming out in the next couple weeks, I've got the cover article for this months SQL Server magazine, I'm speaking at the ASP.NET User group here in San Diego on the 21st, and then again at Code Camp in LA prior to PDC.  I don't have a ticket to PDC, but if you want to offer me one I'd be happy to take be there.

So over the next day or so I'll get a nice technical post on Silverlight 2 Beta 2 in place and a short post on how I'm losing weight (and you can too :- ) and generally start things going here on the blog again.

Monday, October 06, 2008 11:23:53 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
About the Nerd
# Wednesday, June 18, 2008

Another of those diseases which doesn't get nearly enough coverage given the number of people it effects each year is Melanoma.  This article talks about how by useing a patient's own blood cells and essentially cloning them and reinserting them they can attack an otherwise potentially fatal cancer.  http://www.breitbart.com/article.php?id=080618212711.38ht6zq0&show_article=1 Some of the stuff that is going on in medicine today is just amazing.

Wednesday, June 18, 2008 4:56:24 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
Musings
# Saturday, May 10, 2008

I wanted to make a quick shout out to my favorite 'new' kids television show.  As with every parent of a toddler you go through a phase where you get inundated with kids shows.  Some like Teletubbies or Barnery are pure torture (My son doesn't watch these shows).  Others like the new Mickey Mouse club are instantly appealing and for an adult at least watchable (the first 3 or 4 times for a given estimate, after that your brain still turns to mush).  Of course in posting this I'm admitting that my son (age 2) watches TV - which is of course the root of all evil according to some.

However, this post is focused on my favorite of today's current array of morning kids programming.  In the preceding paragraph I mentioned shows that are rather old, and I don't want compare say Barney to 1970's era Captain Kangaroo.  Different eras have different shows.  The first thing I learned about modern pre-school kids TV in the morning is that there are two definite leaders - Disney and PBS Kids.  I know several of you probably think I've missed both Cartoon Network and Nickelodeon.  I didn't you see Disney and PBS both follow a minimal advertising model for the morning stretch.  Admitedly PBS keeps that model 24hours a day but to me the fact that Disney has matched this model from 6AM through Noon is impressive.

In general Disney has a better set of shows when it comes to the combination of entertainment and education.  By this I mean that when I consider the shows my son pays reasonable amount of attention to the Disney shows keep his attention while several of the PBS shows while potentially more educational are met with 'no- no' meaning - take me back to Disney.  After all one of his favorite shows is the Mickey Mouse show and Mickey's appeal is great and the show includes things like counting, shapes and colors.

That's great however last fall Disney and PBS Kids each 'introduced' from my standpoint a new show.  On Disney the new show was Bunny Town.  It was preceded by weeks of over-promotion telling us how great it would be. As usual the overwhelming hype was indicative of just how weak the show was.  On the other side although to the best of my knowledge there wasn't overwhelming publicity, but PBS Kids introduced a show - the only show which we can switch to even against a showing of Mickey.

By now if you recognize the title of this post you know that show is Word World.  This is an awesome show, they introduce the idea of building words from letters.  The computer graphics not only create characters but literally use the letters to create the object they describe.  For example the Dog character is an adaptation of the letters Dog with legs, ears, tail etc. added.  The letters don't just disappear or appear they are used to create objects and the graphics are of the type you could only create in the past couple years. 

I have no doubt but that watching this show feeds into the fact that my son knows all of his captial letters (note reading books and playing with letters in the tub and talking about them elsewhere - including license plates - also plays a big role , not to mention that my son is surprisingly bright.) At any rate, the show is well produced and you can check out their site including a sample episode at: http://www.wordworld.com/

To view the show's opening scene head over to PBSKids.org (http://pbskids.org/wordworld/video/montage.html?load=montage1) or to get a feel for how the characters behave check out the embeded video below - although it omits the rich animated scenery and just focuses on the characters and building words.

Saturday, May 10, 2008 10:11:35 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
Musings
# Friday, May 02, 2008

This is one of those musing posts and comes from one of the challenges I have when teaching a feature that Microsoft chose to call 'Generics'.  I think this name was picked by someone, who while reasonably familiar with English wasn't a native speaker of the English language.  Thus they found a definition and thought it applied - allow me to elaborate.

What is a .NET Generic - well in short - under the original implementation of .NET collection classes contained a set of other objects.  However, these classes didn't know specifically what kind of object they contained.  Instead a given collection might contain more then one different type of object, for example numbers stored in a collection with strings and image objects.  It wasn't possible to say thata given collection would contain only a specific type of class. 

With the introduction of 'Generics' it was possible to indicate that a given collection would only contain a specific type of object.  That's right the feature Generics describes a set of rules and syntax for ensuring a collection is of a specific type.  Now the challenge comes from how the definition of generic is phrased in some dictionaries: "Relating to or descriptive of an entire group or class"

Notice that the preceding definition basically associates the definition of a generic with a class.  Thus if you were searching the dictionary for a word that described a class - well there you have it.  Unfortunately this use of the word "class" doesn't relate to the use of the word "class" in object oriented programming.  In this use a class is more of a category of like items - not the definition of a single item. 

Webster's Revised Unabridged Dictionary - Cite This Source - Share This

(http://dictionary.reference.com/help/web1913.html)

Generic

Ge*ner"ic\, Generical \Ge*ner"ic*al\, a. [L. genus, generis, race, kind: cf. F. g['e]n['e]rique. See Gender.]

1. (Biol.) Pertaining to a genus or kind; relating to a genus, as distinct from a species, or from another genus; as, a generic description; a generic difference; a generic name.

2. Very comprehensive; pertaining or appropriate to large classes or their characteristics; -- opposed to specific.

Webster's Revised Unabridged Dictionary, © 1996, 1998 MICRA, Inc.

 

That's right the word I most frequently use to describe the feature Generic is the one which defines the opposite of the definition of the word generic....

I don't think Microsoft can really do much about this, it's just one of those things that make you wonder...

Friday, May 02, 2008 11:46:25 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
.NET | Musings
Archive
<May 2012>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
About the author/Disclaimer

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

© Copyright 2012
Bill Sheldon
Sign In
All Content © 2012, Bill Sheldon