Saturday, March 26, 2005

Toshiba M200

I bit the bullet recently and bought a new Toshiba m200 tablet pc. Its an incredible piece of hardware, but I have found a few things that are annoying which will be posted over a period of time. The first was that the hard disk made a distinctive click sound whenever it was being used. This would have been  no big deal but  it was making the click sound around once a second. At first I thought it was the lsass process because it was performing IO every second, but some help from the filemon utility (sysinternals.com) showed it was a Toshiba provided system tray utility ndstray.exe. This lead me to go nuts and uninstall a heap of Toshiba supplied packages that came with the machine. There were around a dozen or so of these things. Its not easy to figure which of these extras are needed and which aren't. All of the packages listed in the screen capture below are part of the Toshiba supplied set. It also made for a full windows system tray. A list of Toshiba executables names can be found here and there’s also a faq link page that was useful.


 

Tuesday, March 22, 2005

Jim Gray on Channel 9

An absolutely fascinating interview with Jim Gray is over at Channel 9. He labels his views as “the lunatic fringe”. Huh!? It all made wonderful sense to me. A lot of the big discussion points of today’s software directions were covered – web services, asynchrony, parallelism, 3–tier versus 2–tier, commodity hardware effects etc. Recommended viewing and bound to start a few heated “discussions”!

Thursday, March 10, 2005

Field Name Colors

Eric Gunnerson wrote a post on field name conventions where the conclusion was that having an m_ prefix in front of field names makes it easier to identify fields versus variables. This is particularly useful when you’re looking through unfamiliar source code. Regardless, I still prefer not to have adornment on code names past what would be used in normal language (and have always recoiled from Hungarian notation). It just seems cleaner to be able to read source and have it sound close to a natural language sentence as far as the class, field, property and method names are concerned.

It would be great if the IDE could color field names differently from variable names, so you could easily differentiate them in code without having an ugly prefix being used just as a field marker. Did a search on lady bug and found a match on this type of functionality and voted for it:

Suggestion Details: Syntax coloring: Identifiers differenciation (local variables, fields, properties, methods, events)

If such functionality were available, I’d probably not go pyrotechnic with the colors and just differentiate the fields with a different color.

Tuesday, March 08, 2005

DisposableResource

This post contains some very minor variations of the Dispose pattern implemented in a class that implements IDisposable. A typical example of how to implement the Dispose idiom can be found over here. The DisposableResource implementation shown below separates out disposal of managed resources from the disposal of unmanaged resources. The derived class implementor then just has to override either DisposeOfManagedResources or DisposeOfUnmanagedResources or both depending on their resource management requirements. I know its a minor thing, but it just saves having the if-then logic contained in the Dispose( bool ) method being duplicated all over the place. There’s also a couple of convenience methods. The ThrowIfDisposed method can be called whenever you want to ensure this object has not been disposed of. The DisposeOf method does a null check and then disposes of the supplied object if it can. This saves some typing and improves clarity in disposal method overrides.


/// <summary>
/// A base class that provides resource-management functionality for
/// derived classes. Derived classes should override the <see cref="DisposeOfManagedResources"/>
/// and/or the <see cref="DisposeOfUnmanagedResources"/> methods. Default implementations
/// of both these methods are provided so that derived classes only require
/// specializations that apply to derived class resource management requirements.
/// </summary>
public class DisposableResource : IDisposable
{
private bool hasBeenDisposed;

/// <summary>
/// Initializes a <see cref="DisposableResource"/> instance.
/// </summary>
public DisposableResource()
{
}

/// <summary>
/// The finalizer for a <see cref="DisposableResource"/> frees the
/// unmanaged resources but not the managed resources.
/// </summary>
~DisposableResource()
{
Dispose( false );
}

/// <summary>
/// Disposes of this object. Both managed and unmanaged resources are freed.
/// </summary>
public void Dispose()
{
Dispose( true );
GC.SuppressFinalize( this );
}

/// <summary>
/// Throws an <see cref="ObjectDisposedException"/> if this object has already
/// been disposed. This method can be used to check the validity of object
/// usage.
/// </summary>
protected void ThrowIfDisposed()
{
if ( hasBeenDisposed )
throw new ObjectDisposedException(
"This object has already been disposed: " + ToString() );
}

/// <summary>
/// Disposes of the supplied object if the parameter value is not null.
/// </summary>
/// <param name="disposable">The object to be disposed.</param>
protected void DisposeOf( IDisposable disposable )
{
if ( disposable != null )
disposable.Dispose();
}

/// <summary>
/// Frees resources within this object. This is separated into freeing
/// managed and unmanaged resources. Managed resources are only freed
/// if requested. Unmanaged resources are always freed.
/// </summary>
/// <param name="freeManagedResources">
/// Whether managed resources are to be freed.
/// </param>
private void Dispose( bool freeManagedResources )
{
if ( hasBeenDisposed ) return;

if ( freeManagedResources )
DisposeOfManagedResources();

DisposeOfUnmanagedResources();

hasBeenDisposed = true;
}

/// <summary>
/// Frees all managed resources held by this object e.g. unhooking events,
/// disposing of all IDisposable members etc. Derived classes should call
/// base.ManagedDispose() as part of their implementation.
/// </summary>
protected virtual void DisposeOfManagedResources()
{
}

/// <summary>
/// Frees all unmanaged resources resources held by this object.
/// Derived classes should call base.FreeUnmanagedResources() as part of the
/// implementation.
/// </summary>
protected virtual void DisposeOfUnmanagedResources()
{
}
}

Media Center Update

Our big screen TV karked it a month back, so I haven’t done much with the media center experiment up until recently. We had an extended warrantee on the TV so ended up getting a totally new unit. It’s definitely worth paying a few hundred dollars on big ticket items to get the extra warrantee period. The new TV (Samsung) even has this large stowaway area to put video recorders and the like in. The section is as wide as the whole unit but only 12cm high – so you need a slimline case for a PC to fit. This is great as the better half doesn’t like the idea of a butt ugly PC case in the lounge room.

At the same time I had to use the PC intended for the media center experiment (P4, PCI Express. SATA) as a replacement for an over-heating old Athlon system. The old Athlon system got turned into a Sempron 2700 system with an nforce 2 motherboard. The cost of the Sempron process and the new motherboard was incredibly good value. The price/performance ratio of current hardware is amazing. The converted system then had Media Center 2005 installed and hooked up to the TV. My problems/annoyances with the media center so far have been:

  • Fan noise.
  • Having to buy a DVD decoder. Power DVD 5 came with the DVD player, but that didn’t support media center. Currently I’ve been in the eval period for a couple of decoder packages.
  • Occassionaly stutterring/pauses when viewing live TV.
  • The remote control crapped out for a while. A solution was found on thegreenbutton, but it was disappointing to have the failure in the first place.
  • The lack of an EPG (Electronic Program Guide). I found a small package that adds EPG functionality for Australian TV. Its very rough around the edges but does work. An annoying problem is that the times for programs are occassionally wrong.

All of the above is frustrating. Apart from the “lack of EPG madness”, the rest of the problems could be accredited to the general approach of combing arbitrary components rather than using an approach where the hardware is fixed (game consoles, tivo etc.). I’ll keep looking at problem resolutions at quarter-pace for a while as a side project. Overall, I get the impression this is really an area for the home entertainment vendors to own and for a media center pc to be a small niche. All it would take is a reasonably priced PVR with a DVD player, EPG support, a basic UI and a hard disk for me to chuck the PC out of the lounge room. Actually, it would be nice if the Xbox 2 had this sort of functionality.

Friday, March 04, 2005

Class Designer C++ Support Cut

Bummer.

Given the complexity of C++ reverse engineering compared to the simpler/cleaner languages such as C#, VB.NET and J# this is understandable. I hope support for C++ in the class designer is added as some form of service pack to VS.NET 2005 in the future (and not in VS.NET 2007, 2008 or whatever the next version will be).