Still here

October 23, 2007 19:57 by dgood
I am America (And So Can You!) - One word:  Hilarious.  Technically, that's three.

Yes, I'm still alive.  I've been very busy lately.  I jacked up the radiator cap on my Jeep and I've been busy putting a new Jeep under it.

ProgrammingGoody, you say?  Blog about software, eh?

How's this:  Boxing and Unboxing in C# can be tricky operations for the inexperienced or uninformed.

Example:

struct Point
{
    int X;
    int Y;
    public Point(int x, int y){ X=x; Y=y; }
    public void Move(int x, int y){ X = x; Y=y; }
}

public static void main(string args[])
{
    Point p = new Point(0, 0);                // value type
    ArrayList arr = new ArrayList();      // only holds reference types
    arr.Add(p);                                         // Box it

   ((Point)arr[0]).Move(5, 5);               // Unbox it

   Console.WriteLine("Point: {0}", arr[0]);
}

When the Point struct is unboxed, the pointer to the boxed Point on the managed heap is used to copy the values from the heap into a new instance of a Point value type on the stack.  In effect, there are now two separate instances of Point - one on the stack and one on the heap.  Using Point in this manner will not lead to the desired outcome.

The same mechanism applies to any value type stored as a boxed reference.  (Hint: think Session state)


This one's for you, Classic Colin.

Cheers.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Words For Words

January 25, 2007 21:28 by dgood
Catchy title.

I had my friend Jason hook me up with an account at his site WordsForWords.com. I do read a number of books and I'd like to contribute to the site, plus it gives me an outlet for discussion. I almost said I read a lot of books, but A) that's relative, and B) not *nearly* one hundred books a year like Todd Gerber. I'm in the more conservative wife-house-job-twin boys 10-20 per year category. Although, to be fair, Todd is just as busy.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Book meme

January 15, 2006 20:56 by dgood
A little over a year ago I was thinking to myself: "Self, I should read more." So I do. Since then. I resolved to read more books, you see. I read far too many magazines. My subscription list: MSDN, Dr. Dobb's (it's free), Queue1, Communications of the ACM1, Software Engineering Notes1, Computer2, Spectrum2, Outdoor Life, Popular Woodworking, and Sports Illustrated. Not to mention the sundry catalogs and whatever my wife happens to read. I'm exhausted just thinking about them all. Now understand, I love books. I generally don't get rid of any books unless they're obsolete computer books, in which case I usually just donate them to Goodwill. Perhaps my favorite place is 3 inches to the north of the bargain tables at the local Borders. I find a lot of great books in on those tables. One of my most recent accessions is Edgar Allen Poe: Complete Tales & Poems for $5.99. If nothing else, my boys will have it readily available for the 8th grade English assignments one day. Lucky. While I haven't exactly vowed to read 100 books, I do whiteboard my "must read" list every year (usually tech books - I generally read fiction on a whim). So for 2006, my tech list consists of... So there it is. Not too glamorous. I finished The Best Software Writing I just this past week. I'll post a separate review. And now, I'm well on my way from journeyman to master. I imagine I'll slow down dramatically when the weather turns nice. Or not. Thus concludes my book meme. 1. With my ACM Membership 2. With my IEEE Membership

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5