Scott Hanselman

Wesner's thoughts on Collection versus List

August 2, '04 Comments [3] Posted in NDoc
Sponsored By

Wesner offers his thoughts on my question, What's the difference between System.Collections.Generic.Collection and System.Collections.Generic.List?

I think there are two possible reasons.

  • Collection<T> appears to be a replacement for CollectionBase, which provided virtual methods to detect insertions, deletions and changes.
  • The new List class no longer provides any virtual methods as did the original ArrayList for performance reasons..
    [Wesner Moise]

He also educates us on some of the differences between List<T> and the 2.0 ArrayList.

  • List<T> does not use any virtual methods. As a result, a number of methods such as the list indexer methods can now be inlined.
  • With the default constructor, List<T> and Whidbey ArrayList do not allocate any memory for its items, so an empty list represents a very compact object--comparable in size to an empty array. (8 bytes for Array, 12 bytes for List, 16 bytes for Whidbey ArrayList) It uses the empty array trick that I wrote about in an earlier post. In contrast, earlier versions of ArrayList would allocate space for 16 items by default.
  • The initial buffer size when an item is actually added is 4 items not 16 as before.
  • List<T> returns an struct-based enumerator, so that iterating through foreach now involves no memory allocations at all.
    [Wesner Moise]

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

Medtronic Minimed 508 Insulin Pump vs. my New Paradigm 512 Insulin Pump and Blood Glucose Meter

August 2, '04 Comments [6] Posted in Diabetes | Movies
Sponsored By

This is a primarily technical blog, so I don't post pictures of pets (don't have any) or other personal bloggy things.  However, I am an Insulin-Dependant (Type 1) diabetic with an Insulin Pump and most folks know that, and I've blogged about Diabetes before: Scott's Diabetes Explained - The Airplane Analogy.

I've been diabetic for a decade, got it when I was 20.  It doesn't run in the family, nor do any of my relatives have Type I diabetes.  A few of the oldies have Type II, but these days who doesn't?  The theory is that I got the flu (possibly a coxsackie virus) and when it was all over I was left without a usable insulin-producing pancreas.

When I was diagnosed, my blood sugar was around 500 mg/dl and yours is probably 80 mg/dl.  (I currently aim for <= 150 mg/dl).  I had gone from 180 lbs to about 130 lbs because I was pissing away muscle.  We think I was uncontrolled as a diabetic for at least six month before folks noticed I was wasting away.  The weight came back on after I got under control.

Diabetes sucks egregiously.  It's the leading cause of blindness, kidney failure, and heart disease.  I have checked my blood sugar by pricking my finger between 5 and 10 times a day for the last 10 years (about 30,000 times so far).  Hurts every time.  Folks always ask "Does it still hurt?"  You get beaucoup callouses, but yes, it hurts. 

I check my blood sugar (glucose) then make a decision based on some training they give you when you're diagnosed, some equations and hunches.  I took shots 4-6 times a day for six years.  Ironically, I hate needles and giving blood.  Go figure. :)

A month before my wife and I went on my first date I got an Insulin Pump, a Minimed 508.  It looks exactly like a pager with a clear tube coming out of it, except it costs $6000 US and delivers insulin.  (It does vibrate and have a remote control though.)

The pump doesn't know ANYTHING about my blood sugar, and there are no pumps on the open market today that can detect blood sugar either continuously or at an interval.  If you think your friend has one, you are either mistaken or they are in a clinical trial for something coming. I've done two clinical trials myself.

The pump is a one-way device - delivery of insulin only.  There is a small needle/canula that I stick in my side every 4 or 5 days.  I move it around; sometimes I feel like I'm putting holes in me faster than I can heal them.  It's a good thing though, as I used to have to stick a needle in me many times a day, now the needle and tube is in there all the time.  I keep the pump with me 24 hours a day, it can't be removed for more than a few minutes at a time (bathing, etc.) 

Here's an example.

Let's say my blood sugar is currently 100 mg/dl.  FYI, 50 mg/dl would be dangerous.  30 mg/dl would be Emergency Room.  200 mg/dl or more for long periods is a bad idea also.  So the goal range is 100-200 mg/dl.  I know that (from a whole series of past calculations) that:

  • 1 Unit of Humalog Fast-Acting (starts in 15 mins, last 3 hours) Insulin will lower my blood sugar 50 mg/dl. 
  • 1 Unit of Humalog will "cover" 15 grams of Carbohydrates. 

So, ideally, if my BG (Blood Glucose) is 100 mg/dl and I want to eat a 30 gram Granola Bar, I'd take 2 Units of Insulin and expect my BG to be BACK at 100 mg/dl after about 3 hours.  Make sense? 

Carbohydrates hit you fast - immediately and they spike blood sugar quickly.  If I ate that Granola Bar and didn't take any insulin, my BG would go to 200 mg/dl in short notice and likely higher.  Blood sugar is like a helium balloon, once it gets high, it likes to accelerate.

Protein hits you slow - in about 3 to 5 hours. Fiber will also hit you slow.  This is all that talk about the Gylcemic Index of food.  For example an apple without skin would hit faster than one with skin.  White bread hits faster than wheat.  You get the idea.  (Rice Cakes are horrible for you, by the way)

OK, here's where it gets more interesting.  Let's say that I have lunch at Subway.  A foot long steak on wheat is 80 grams of carbs and 20 grams of protein.  That's ~5.4U of Insulin now and ~1.3U either over, or in, 4 hours. 

Now, let's say that dinner comes around and my blood sugar is 200 mg/dl.  That's too high and I'll need a "correction" as well as enough insulin to cover dinner.  I want to be at 100 mg/dl, but I'm at 200 mg/dl.  That's 2U (Remember 1U = 50 mg/dl) to correct, PLUS whatever I need for dinner. But, if dinner is at 3 pm for some reason, then I've still got some fractional amount of "active" insulin in me from lunch!  If I don't take it into consideration I could over correct and crash later.

Well, you get the idea.  Anyway, I got a NEW pump this weekend.  A Medtronic Paradigm 512 Insulin Pump with Wireless Blood Sugar Meter.  It's freaking awesome.

When I check my blood sugar on this meter, it immediately wirelessly transmits the reading to the pump.  (I "married them" with a dance of serial number registrations and encryption as a first setup step.) 

The pump has a Wizard that I programmed earlier with all my details: Insulin sensitivity, type of Insulin, Carb/Insulin Ratio, etc.  The Wizard then keeps track of my blood sugar and active insulin.  If I count my carbs correctly, it will make a suggestion as to how many Units of Insulin to take.  Mind you, it's just a suggestion.  I have to make the final OK and/or adjustment for legal reasons.  God Forbid it should make a mistake, so I'm happy to be in the loop. :)

It works great.  Yesterday we went to the movies and I had an ENTIRE bag of Peanut Butter M&Ms (75g) and had perfect blood sugar afterwards.  This doesn't mean that I'll start eating crap.  Remember the Airplane Analogy - dramatic altitude changes are hard to control, steady and even is always the best bet.  But it was so much easier on the head to let a computer do the calculations that I've been doing 6 times a day in my head for the better part of ten years.  (Try not eating M&Ms for ten years, then see how YOUR demeanor changes. ;) )

For the next few years, the diabetic themselves will have to "close the loop" - but this pump and meter are a rockin' sweet next step and the coolest thing to happen to my diabetes in the last decade.

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

Visual Studio.NET MSI Setup Creation: "Cannot delete folder. Folder is not empty or it might contain excluded files, which are not shown"

August 2, '04 Comments [5] Posted in Programming | Tools
Sponsored By

The real tragedy of this error message is that there is no way to show the excluded files.  So you have to guess.  In this instance, a random Thumbs.db file got into the Visual Studio Setup Solution (vdproj, and unfortunate extension that describes and unfortunate tools) and was subsequently excluded.  When it came time to prune a directory of images, I was denied while deleting an IMAGES folder - with no way to figure out which file was hidden in that folder.  Only a miracle and a hunch caused me to remove the stray Thumbs.db (it was certainly out of place).  Then the directory was deleted without incident. 

Time wasted: 13 minutes.

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

.NET 2.0 - What's the difference between System.Collections.Generic.Collection and System.Collections.Generic.List?

August 1, '04 Comments [1] Posted in Programming
Sponsored By

Anyone want to tell me what's the difference between System.Collections.Generic.Collection and System.Collections.Generic.List?

  • Collection<T> looks like a list, and it even has a List<T> internally.  EVERY single method delegates to the internal List<T>.  It includes a protected property that exposes the List<T>.
  • List<T> uses an array (T[]) internally and includes all this great anonymous delegate/predicate stuff like Find() and FindAll().
  • They both implement IList and ICollection.

Another weird one, Microsoft.VisualBasic still has the oddball Collection class that implements ICollection and IList.  Presumably this type exists only to help VB6 developers make the transition?

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

"Neo, there is no boolean." - Web Services, Product Releases, Travel and Famous Bloggers.

July 29, '04 Comments [3] Posted in ASP.NET | Web Services | Ruby
Sponsored By

A bit of a random, but nice day.

  • Rory joined Microsoft as a cartoonist for MSDN.  There's some presenting in the job description as well.  Congrats Rory.
  • The Portland Nerd Dinner was lovely, as usual.
    • Thanks to Jim Blizzard for the free books.  Jim represents everything that is good about Microsoft.
    • Thanks to Chris Sells for being so approachable about all things Longhorn.  Chris also brought a crew along from the O'Reilly Open Source Convention.  There were a few people who we having iBook Drum Circles that couldn't make it, but I DID very much enjoy meeting and talking to Sam Ruby
    • Sam Ruby was a kind, soft-spoken and very insightful fellow who told me a number of great insights into ATOM and the making of a new "standard."  Such things, if they are good, seem to take off with a life of their own, don't they?
  • I'm heading to BAY.NET tomorrow (PDX->SFO) to talk about Web Services and darnit if I'm not nervous to meet Simon Fell.  I'm looking forward to talking to him (and the group) about the chaos around null, nil, specified and "just not there."  I predict a blood bath of newbie confusion.  Fully. 
    • Is it null?"
    • "Yes, nil"
    • "But it's there"
    • "No, it's there, but it's marked nil" 
    • "Is it specified?"
    • "It's both specified and it's nil" 
    • "So if it's not there it's nil and not specified"
    • "No if it's not there, it's specified but nil itself is then unspecified."
    • "But is the boolean false then?" 
    • "There is no boolean"
  • Anyway, I shall try my best for the talk to not suck egregiously.
  • Had a big internal release of a magical thingie I've been working on all this time and we're all a titter with excitement.  Inconvenient that I'm travelling the same day, but Patrick Cauldwell has the whole thing on lockdown, so I know we're solid.  (I am disturbed though that his 9-year-old thinks Breakin' was better than Breakin' II: Electric Boogaloo. At least we agree on the tour de force that was Krush Groove.)

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.