DVD +/ RW Conspiracy

Within the course of the past year, I recall seeing packs of DVD+RW or DVD-RW discs available in small quantities–as small as three in a package. I didn’t buy any then because I really don’t need re-writeable capabilities most of the time. Usually when I back up my files, I just burn them to a regular one-timer and throw it in my disc box with my other backups.

Today, I went to two stores looking for RW discs because I have a DVD recorder set top box that I use instead of a VCR. I normally only want to watch the shows I record once and then overwrite like I used to do with tape. I figured I would probably be able to find the RW discs in small quantities, but then I discovered a little conspiracy. Now maybe I just fell off the turnip truck here and most people already know about this conspiracy, but it made me angry. The smallest count I could purchase at either store was a 10 pack (discs including cases) and it cost about $20. $20 dollars!!? I only need one disc. Um, duh, who uses these things unless they intend to re-use them. Furthermore, who buys them 10 at a time?

Anyhow, I’m sure I’ll get over it, but it just points to a deeper problem with companies these days. They only care about their bottom line–not value for the customer. I understand that business is business and in the end the bottom line is what it boils down to as far as investors go, but it seems like this sort of practice just insults our intelligence and makes us loathe them.

The Cost of Doing Business

Dell LogoAs is true for most of us who use computers to make our living, I am often asked by friends and family for recommendations on what brand of computer to buy. Over the years my suggestions have changed, but the basis for those suggestions hasn’t. With the exception of Mac users, people don’t purchase computers for intrinsic value. It is always most bang for the buck and that is what I focus on.

In the course of the past four years or so my recommendation has been pretty consistent; Dell. Most of the time when I look around for deals, Dell is right in there with the rest to provide best bang for the buck and they provide world class customer service. That alone pushes it over the top in my mind.

But somewhere in the course of the last two years, in my own experience, something has changed. I purchased a laptop myself from Dell in October 2003. Knowing that laptops can be troublesome, I purchased the extended three-year warranty. That would soon prove to be my only saving grace.

Dell Inspiron 5150When I bought my laptop, I bought the best. I upgraded everthing. I got the 60GB 7200 RPM hard drive, DVD Rewritable drive, 1GB of memory, Firewire, and USB 2.0. It is was a smokin machine. I use it for my work and it has really helped my productivity when it comes to build times (especially compared to the 500Mhz PIII I had before it).

For the first year of owning it, I didn’t have any problems, but shortly after the one year anniversary, something happened. When I plugged in my laptop, the OS would not reflect the change in the battery monitor. I called Dell and they had me send it in. After transferring all of my work files to a backup computer, I sent it in and they turned it around pretty quickly. What I didn’t know was that this was the first in a downhill trend that has plagued me since.

Since that time Dell on two occassions has sent me parts that I could replace myself, but I have also had to send it in two times since and I am now on my third motherboard. Just last week, my sound card, which is integrated on the motherboard died and I am now in need of a third motherboard replacement which puts me on my fourth motherboard.

I recently did a search on eBay for my model of computer and found several of them for sale with bad motherboards, to be salvaged for parts. As best as I can tell the people selling those are the folks who bought the computer, but didn’t spring for the extended warranty. What a lesson to learn the hard way. If it had been me, I would be out $2500.00 after one year.
I understand that businesses have to reduce their costs to compete and that means that they have to cut corners, but the most egregious part of the whole ordeal to me is the fact that every time I call Dell, they add insult to injury by sending me to a call center in India.

I don’t want to sound ethnocentric here. I think India is a great country that focuses on technology and is becoming a real reckoning force in the field especially as it relates to computers and software development. The issue for me, though, is the fact that when I call in, my brain has to kick in to a high language processing gear in order to understand what the call center folks are saying. I know many of these folks have spent a lot of time learning to speak English clearly and are doing very well, but over the phone it is almost always necessary for me to have them repeat what they’ve said multiple times.

The end result of making these calls, leaves a lot to be desired. I often walk away feeling frustrated. Sometimes I go away feeling patronized. I’ve sometimes had to raise my voice to get my point across. In the end, I still have to go back through the same process of moving my work files to my backup computer. I then move my backup computer into my office (it’s a noisy desktop I just keep networked in a different room where no one is bothered by the sound) and set up the monitor and run a 50′ CAT5 cable to my network router. It’s a pain and takes time away from my work.

The bottom line is that it seems Dell, as well as others, have gone too far in the cuts they’ve made. I can’t imagine why you would offshore your call centers other than costs and that, frankly, demonstrates making the customer a secondary concern.

Dell was a great company when they were winning awards for their customer service. If they are still winning awards it is probably because everyone else is worse at it than they are. My question is when my family and friends ask me now to recommend which computer to buy, who should I tell them? It won’t be Dell. Lately I’ve been suggesting that people buy a Mac. I know they have their problems as well, but at least if you become a cult member you’ll feel better about it when things go wrong. Cults tend to do that to people.

I will make another call to Dell today to get my laptop fixed again. They are requiring me to send it in again for this third motherboard replacement. I know there is a point with Dell when they will provide you with a replacement, but frankly, I would settle for the same computer but one that is reliable. I’m afraid that’s not possible because there seems to be a defect with these motherboards, but I certainly hope that it gets resolved in some agreeable way (to me) by October 2006, when my three-year warranty runs out.

‘Firefly’ is Good Sci-Fi

Firefly TV Series
In many ways the only aspect of the TV series ‘Firefly’ that is science fiction is the fact that they use space ships and hover crafts. Even the weaponry is good ole’ fashioned gun powder and bullets (with a few exceptions where lasers are introduced). The point here though is that good story telling is what sets good television shows and movies apart from the rest. I like the sci-fi context, limited as it may be, in ‘Firefly’, but more than anything I think it is a great show that really enables you to relate to the characters. Though they are used frequently, special effects merely enhance the story rather try to become the story as so many shows and movies try to do these days (especially movies).

Many people have never even heard of ‘Firefly’ and may never hear of it since the series was cancelled back in 2003, the same season it started. This is a sad reality. I’m not sure what the culprit was, but it was never given the chance it should have had. As I said earlier, it is a really good show. My wife and I both enjoy it which is often not the case with sci-fi. We have now finished watching the whole series and find ourselves quoting it all of the time. My wife’s favorite line is from an episdoe when Zoe says to Wash (they’re married) “do you remember that sex we were going to have, ever again?” It’s my wife’s new favorite threat when I’ve done something that she doesn’t like. Now don’t get me wrong–the show is much more than clever lines, however, the lines like these and others really demonstrate relationships more like you see in real life. The show’s characters relate to each other in ways that make sense–they seem real.

Another aspect of the show that is just great is the way the episodes work together to draw a much larger picture. In relationship to my previous point, the “real”-ness of the show is demonstrated by the fact that when Joss Whedon (the writer) introduces an aspect of a character, he doesn’t expect you to just accept it. He demonstrates is further in later shows. He revisits aspects that really help us to relate even more.

For instance, when Malcolm (the ships captain) first met Jayne (the ships mercenary and block head–yes it’s a guy’s name), he was working for someone else. In fact he was pointing a gun at Mal. In the process of negotiating his way out of that predicament, Mal convinces Jayne (who is a bit of a simpleton in some respects but was hired for his muscle) to come and join him rather than shoot him by offering him better pay. Jayne accepts and turns on his previous boss. We are not left to just accept this about Jayne. In fact, Mal knows all along that because Jayne betrayed his previous boss, he is capable and even likely to be a traitor against him as well.

Whedon addresses this in the “Ariel” episode where they sneak into a hospital facility on this Aliiance planet (called Ariel). By the end of the show, though the plot to conspire is foiled when the Alliance turns on Jayne as well, we are led to believe that Jayne got away with it because none of the crew seems any the wiser of his plan. But then, Mal, out of nowhere, cold-cocks Jayne and interrogates him about his treachery. He then locks him in the outer bay of the ship and opens the outside door a bit while they are about to break atmo[sphere]. He gives Jayne something to think about and threatens to leave the door open. Once Jayne has been convinced that what he did was wrong and his absolute loyalty was required, Mal relents by closing the lock so Jayne won’t die. He then walks away. The show ends.

From this one incident, Mal is able to show mercy to a traitor, but by doing so purchases his loyalty. What a great story line. It really helps us gain respect for Mal as a great leader on his ship, and demonstrates that he believes that though being a traitor has been a major characteristic in Jayne, Mal believed all along he could change and helped to bring that about.

This is just one example of the neat nuances of this under-appreciated television series. There are many fans, my wife and I included, who would like to see the series continue. We borrowed the series from the local Library after seeing the movie ‘Serenity’ which was created as a last ditch attempt to revive the series (to no avail, but that is a different story). I am now planning to buy the series. It is really that good. I think it would be smart of Joss Whedon to make the whole series as it is now available as free video downloads online with someone like iTunes. I think this could very well create the size following it would take to get it off the ground again. I doubt Joss has the power to do this as the rights are probably not his, but it sure seems to me to be a good way to create a larger fan base for a series that is just downright good.

Resetting a .NET Installation

Recently I had to re-install an application I had written using C# on a Windows® 2000 server. The server had been restored after a crash from a system backup. The issue was that the registry had been corrupted and many keys had been destroyed altogether.

Once I got onto the server I realized that there were several components I use that needed re-installed. I decided to start with Windows® Update. While there I realized that the .NET framework 1.1 had not been updated. I went ahead with that update and rebooted. When the system came back online, I went back into Windows® Update and realized it was again reporting that the .NET framework 1.1 still needed installed.

To make a long story short, it turns out that I needed to force Windows® update to see the .NET framework as really uninstalled. I started with trying to install using the dotnetfx.exe redistributable file and then removing that, but that didn’t work. In the end it boiled down to removing one file. This file is called mscoree.dll. It is located in ‘C:\WINDOWS\system32’. I simply moved the file from this location to a temporary folder (in case it broke something and I needed to put it back). Once this was done, Windows update saw it as “really” uninstalled and actually re-installed everything.

So, should you find yourself needing to re-install the .NET framework after a system recovery, remember that the easiest way is to simple move the mscoree.dll file and you’ll save yourself a lot of time.

Note: I’m not sure if this is the same with .NET framework 2.0. You’ll have to try it out and let me know should you need to do this on a system that uses .NET 2.0.

Microsoft Love/Hate or Love to Hate

For a long time I have seen Microsoft as being evil in tactics but good in what they provide for developers. I use Microsoft’s tools to do my job and find that the majority of my experience doing so is positive. This is why I consider that I have a love/hate relationship with them.

The other day however, I was working and got notified that I needed to install an update from Microsoft, so I went ahead and had it do the install. Keep in mind that I was in the middle of doing something when I was notified. When the install had finished it asked me if I wanted to restart now or restart later. I clicked “Restart Later” and believed that would be the end of it. Within five or ten minutes I was getting notified again with the exact same question. “Restart Now” or “Restart Later”. This was getting very irritating.

Now, if you find yourself asking, “why didn’t you just restart?”, well then you’ve never been in my situation before. I was running and debugging code and trying to fix a problem with my work. When my mind gets into it, it is counter productive to pull away and have to wait. My mind gets on other things and I don’t tend to return to my work with the same vigor as I had before

After several hours of being notified every couple minutes, I realized I needed to download a large amount of data, so I started that process. I had to leave for a while and figured when I came back the download would be finished.

Bwah haa haa haaa haaaa!!! (I can hear Steve Ballmer laughing out loud).

There’s going to be none of that!! You think you have control over your own computer? Well, you don’t. And apparently Microsoft thinks you shouldn’t. When I returned to my computer later, it had restarted without getting the ok from me!!!! What the *&%#$!!!

I suppose part of the problem is that Microsoft doesn’t like getting blamed for security problems and so they enforce that you restart and accept the update, but this is just ridiculous. At least give me a third option on the reminder dialog that says “I will restart my computer as soon as I’m done with my work, I promise.” next to the “Restart Now”, and “Restart Later” buttons. C’mon Microsoft, I love the dev tools, but this crap makes me love to hate you!

C# and the ‘ref’ Keyword

Lately I’ve been thinking about the nuances of the C# language. A friend of mine and I were talking about the merits of C# as compared to Java. Of course, I don’t want to open that can of worms here, however I did realize that I appreciate small details in the C# language that are not present in Java. One of those details is the keywords used in method parameter lists. These include ‘ref’, ‘in’, and ‘out’. The reason these are significant is that in both C# and Java, how are parameters passed? Well we’ve all been told that, of course, parameters are passed by reference and so we go along happily with this information because most of the time for all intents and purposes it is true. But the deeper truth of the matter is that while references are passed, the are actually passed by value.

Here’s is some code to prove it:

public class Person
    protected string name;
    public string Name 
        set { this.name = value; }
        get { return this.name;}
    protected string email;
    public string Email 
        set { this.email= value; }
        get { return this.email;}
    public override string ToString()
        return this.name + ", " + this.email;

public static void main ( string[] args )
    Person p = new Person();
    p.Name = "Matt Long";
    p.Email = "matt.long@matthew-long.com";
    System.Console.WriteLine( p.ToString() );

    ChangeMyMembers( p, "Bob Smith", "bob@yyyyy.com" );
    System.Console.WriteLine( p.ToString() );

    ChangeMe( p, "Wendy Johnson", "wendy@yyyyy.com" );
    System.Console.WriteLine( p.ToString() );

public static void 
    ChangeMyMembers( Person p, string name, string email )
    p.Name = name;
    p.Email = email;

public static void 
    ChangeMe( Person p, string name, string email )
    p = new Person();
    p.Name = name;
    p.Email = email;

If you were to run this program, what would you expect the output to be? Here is the actual output:

Matt Long, matt.long@matthew-long.com
Bob Smith, bob@yyyyy.com
Bob Smith, bob@yyyyy.com

Is that what you expected? Well, since this whole post is about the parameter keywords, I would expect your answer is no. But what happened?

When we passed the Person reference to the ChangeMe() method we passed a copy of the reference. That copy is now only available in the method scope. If we change that reference, it won’t change the original–only that local copy. So when we call p = new Person(); we have assigned that local copy of the reference to point to an actual place in memory, however, it goes away as soon as we leave the method.

Now, to my knowledge there is nothing you can do to address (no pun intended) this behavior in Java directly. In C# however, enter the keyword ‘ref’. If we simply change the ChangeMe() method signature to look like this:

public static void
    ChangeMe( ref Person p, string name, string email )

And then when we call ChangeMe(), we also use the ref keyword like this:

ChangeMe( ref p, "Wendy Johnson", "wendy@yyyyy.com" );

We now get the output we expected:

Matt Long, matt.long@matthew-long.com
Bob Smith, bob@yyyyy.com
Wendy Johnson, wendy@yyyyy.com

I am not by my comments here going to enter into a “which language is better” holy war, however, the parameter keywords in C# are a nice feature. Here is an excercise for the reader. Can you implement a swap method in Java? If so, how? How would you do it in C#?

If you need some pointers for the Java way, you can start here: http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html. Then do an Internet search. (Here’s a little hint: you would have to encapsulate the parameters in a class that can be de-referenced in the swap method.)

If you want to learn more about the nuances of C#, a good way to do so is to read some interview questions. Take a look at these here.

Mac OS X86 Project

For a long time I have loved the Macintosh and the Mac OS platform. It has just been difficult for me to ever justify owning a Mac because the work I do is all Microsoft Windows based.

Recently there has been a flurry of posts over at Digg and other technology news sites that discuss how to install the Mac OS on Intel hardware. This, of course, has been made possible first and foremost by Apple, when they released development computers to premium members of the Apple Developer Network, and then ultimately by hacker types in the community at large who were able to circumvent the security technology that was intended to keep users from installing the OS on any arbitrary Intel based hardware and then making available a disc image of the installation.

After reading several posts, I decided to try and see if I was able to get the Mac OS running on my own Dell laptop. The main site with information about the MacOS X86 port is of course http://www.osx86project.org/ , however, there are others. I found the necessary files and created the install disc. I then purchased a secondary hard drive and bay for my laptop and ran the install last night. It worked very well. Out of the box I had networking support and audio support.

Software such as most of the iLife suite has to run using a technology named Rosetta which provides an emulation layer. This makes it quite inefficient to use most of those applications since they are already resource hogs without the emulation, so I am finding that I can’t really see using it as a permanent setup. I will purchase one of the MacIntel computers when they are available, but this has been a great way to get to know the Mac OS.

I also plan to start learning how to write code for the Mac when I get some free time. This is a great way to do it without having to make the initial investment yet. The time will come for that and when it does, I’ll be ready to start building applications for the excellent Mac OS X platform.

Yamaha PM7 Trumpet Mute

Ok. So this is not about programming, but I know a lot of programmers who are musicians. For all you trumpet players out there (I know there’s gotta be at least one), I bought the Yamaha PM7 practice mute because of it’s ability to, first and foremost, mute the sound so that I don’t disturb, kids, neighbors, very small rocks, etc. and, secondly, because it provides a way for me to record trumpet playing on my multi-track recorder (DAW). Well, I bought it believing that the “Personal Studio” that you usually buy it with wasn’t necessary. Plus I got the thing brand new off of ebay for $30 (retails for $70). I had figured that the “Personal Studio” was just acting as a simple pre-amp. Apparently there is something else to it. I borrowed the “Personal Studio” from a friend who had one already and it worked fine, so I now need to get one of those.

Anyhow, I just figured that others who buy just the mute would want to know that the “Personal Studio” (Yamaha ST9) is required for it to work. This information isn’t presented anywhere on the web including the Yamaha web site and music instrument vendors such as Musician’s Friend, etc.

At some point, I woould like to crack open the ST9 and and see what they are doing in there to make it work that my recorder doesn’t seem to provide. If there are any audio engineers out there with an idea, please let me know.

C# Memory Pinning: Convert a byte array to a data structure

C# Memory Pinning: Convert a byte array to a data structure. Have you ever wanted to simply typecast a byte array to a data structure and then use that data structure like you used to be able to do in C? Well, C# provides a facility to accomplish this.

This solution is several months old to me now, but I feel it is something very worthwhile for C# programmers to know.

Have you ever wanted to simply typecast a byte array to a data structure and then use that data structure like you used to be able to do in C? Well, C# provides a facility to accomplish this. Several months ago I needed to take a byte array 64 bytes long and extract different fields from it. At first it seemed that the only solution was to convert the byte array to a string and then use substrings to get what I needed. To add insult to injury, I then had to take each of the substrings and convert them into the data types that I wanted and then assign the members of my data structre to each of those. Something ain’t right about that!!

Now, being the stubborn programmer that I am, I was not satisfied with this solution as I used to have the ability to just typecast a byte array into whatever structure I wanted in C and dangit newer languages such as C# shouldn’t remove features. They should enhance existing ones along with introducing new ones.

Enter memory pinning. Now, I can’t take credit for finding this on my own. It was a tough find and I was only most of the way there when a co-worker of mine found the answer. Here is a code snippet to show how it’s done:

public static object RawDataToObject(ref byte[] rawData,
		Type overlayType) 
	object result = null;

	GCHandle pinnedRawData = GCHandle.Alloc(rawData,
		// Get the address of the data array
		IntPtr pinnedRawDataPtr = 

		// overlay the data type on top of the raw data
		result = Marshal.PtrToStructure(
			pinnedRawDataPtr ,
		// must explicitly release

	return result;

Becaues the garbage collector will normally have the ability to change the location of where we have our object allocated in memory, we have to actually pin it by calling GCHandle.Alloc() passing it a handle type of GCHandleType.Pinned.

In the application I was working on I knew that the byte array would always be the same size. If, however, it had been a variable size, then we would have to ensure that the size of the overlay type is the same as the length of the byte array.

Now that we know how to actually do the conversion from byte array to data type, we should probably look at the data types themselves. The data types and their members have to be explicitly set to their correct sizes in the code. The following is an example structure:

[StructLayout(LayoutKind.Sequential, Size=64, Pack=1,
public class MyDataStructure
	[ MarshalAs( UnmanagedType.ByValArray, SizeConst=40 )]
	public byte[] name;
	public byte eyeColor;
	public byte hairColor;
	public Int16 age; // Two byte integer
	public Int16 height;
	public Int16 weight;
	public Int16 noOfPets;
	public byte sign;

	[ MarshalAs( UnmanagedType.ByValArray, SizeConst=3 )]
	public byte[] birthDate; //yymmdd

	[ MarshalAs( UnmanagedType.ByValArray, SizeConst=10 )]
	public byte[] unused;

There are several items that need to be explained here. First off, our structure is actually a class. Both classes and structs can be used. Classes just need to be treated as structs and include no methods. Next, notice our StructLayout attribute. Here are the meanings of each of the fields used in this attribute:

  • LayoutKind.Sequential: Tells the compiler that the fields in the structure should be allocated in the same order they are laid out in code
  • Size: This is the total size of the structure. When this is set, you must ensure that the fields all add up to this number.
  • Pack: This is the packing size that the compiler should use to allocate memory for the structure. The default is 8, so if you left this blank, Pack would would be set to 8. In this case, however, we have set the pack to 1, ensuring that memory for the structure is all allocated together. Pack is only used when the LayoutKind is set to Seqential.
  • CharSet: Indicates how the data fields should be marshaled.

Next, look at each of the fields in the data structure. We are representing three different data types in this particular code snippet. They include a single byte a two byte integer and byte arrays which are normally used for strings. To indicate that a field should be marshaled as an array, we have to use the MarshalAs attribute specifying the size the array should be in the attribute rather than in the delcaration code.

Now, when we put this all together, it looks something like this:

// We assume GetNextRecord retuns the 64 byte array
byte[] arrayOfBytes = GetNextRecord();
MyDataStructure mds = (MyDataStructure)RawDataToObject( 
		ref arrayOfBytes, typeof( MyDataStructure ) );

// Now we can reference the data structure
// however we would like
string name = ASCIIEncoding.ASCII.GetString( mds.name );
string age = mds.age.ToString();

This solution works great if you have to read in a fixed length data record from either a binary file or even some hardware device. It’s a very cool technique (if you ask me).

Welcome to Long Pointers

Welcome to Matt Long’s weblog. Here you’ll find blog entries relating mostly to programming and mostly using C# with the .NET framwork.

Welcome to Matt Long’s weblog. Here you’ll find blog entries relating mostly to programming and mostly using C# with the .NET framwork. From time to time I solve programming problems that have an elegant solution and there is often a methodology or at least a code snippet I want to share with others. This is the place where I intend to do that. If you are looking for Matt Long’s company, it is now called Skye Road Systems, Inc. You can view the website at http://www.skyeroadsystems.com.

If you’re wondering about the site name “Long Pointers”, well it has a bit of a double meaning. Those of you who are reading this who are programmers may already understand it, but for others, a long pointer is “a 64-bit pointer that may point to an object outside its current process space”. If you don’t know what that means, don’t worry about. Most programmers don’t worry about it anymore either, because it was something you only dealt with in the C programming language, which by most accounts is antiquated and these days primarily used for embedded devices and legacy computer systems (with some exceptions). The double meaning comes in because my last name is Long and I am providing programming tips (a.k.a. pointers) on this site. Call it cheezy. Call it what you will. It’s here to stay.