October 11, 2004 spout

“How is anyone supposed to know that?”

The high priests that run the Internet and the IT industry have betrayed the trust of the secular community.

My wife called me over to her computer the other day when she was worried about an email stating a problem with her eBay account. By reflex, I said, Oh, just ignore that.”

What? Why? They’re going to shut off my eBay account,” she said, motioning me over more urgently this time.

Looking over her shoulder, I saw an email that looked very official, including the eBay logo.

See?” she pointed at the From line. It’s from ebay.com.”

I know, sweetie, but hang the mouse over the link they want you to click. It’s a number; it’s not ebay.com”

Looking at me like I’d just broken the news about Santa Claus, But how is anyone supposed to know that?”

I didn’t have an answer. There really should be one.

October 11, 2004 spout writing

All The Fun, Half the UK Price

Curt Johnson, my marketing guy at Addison-Wesley, has let me know this morning at the UK Amazon is having a 1/2 price sale on my Windows Forms book this month. Plus, the UK guys have their own reviews that are just as nice as the US reviews. Who knew? : )
October 10, 2004 .net

Rob Relyea on Fixing the XAML Attribute Grammar

Rob’s been talking about fixing various parts of XAML lately, which is exactly the kind of result you want when a bunch of folks work with your technology and give you feedback on it. So, things will change and get better.

However, Rob isn’t telling us just want the changes are likely to be because, as he puts it, I’m not going into great detail in the description of our fix because I’d prefer to be the first company to ship our design.  :-)”

Like Rob, I find this amusing. I grew up in a period of Microsoft’s life where they were much derided for leveraging” ideas from the rest of the world and repurposing them for use in Windows (or *as* Windows in some cases). Now that MS has caught up and passed most of the rest of the world in many crucial areas of technology, it’s nice to see us grow into the role of thought leader instead of follower.

October 9, 2004 fun

Vermin King With Mutant Arm

(I couldn’t possibly explain. Click the picture…)

Rory Blyth
Saturday, October 09, 2004 12:50 AM
www.Neopolean.com

October 7, 2004 spout writing

You Too Can Be A Technical Writer!

October 7, 2004 .net

Settings, Collections and VS05b1 (oh my)

Here.

The one where I get to try out the interaction between VS05, Windows Forms 2.0, application and user settings (wahoo!), generics and versioning, discovering that, while this combo still in beta, it’s still pretty darn wonderful.

October 7, 2004 spout

Settings, Collections and VS05b1 (oh my)

I sat down to write a new Windows Forms application in .NET 1.1 the other day, but the Visual Studio 2005 beta 1 called to me with its menu strips” and its user settings” and most especially its generics,” and I just couldn’t resist.

To start with, it was such a pleasure to add a menu strip, add in the standard menu items (including graphics), then just strip it down to just the menu items I wanted. Then, as I added new menu items, the menu item object names were set for me based on the menu item text, e.g. startRetrievalToolStripMenuItem instead of menuItem1, which was fabulous. Not everything was wonderful, e.g. I couldn’t drag and drop menu items or use Alt+arrows to rearrange them , but overall the new menu control was a pleasant experience.

Even more pleasant was the app/user settings model. To add a setting to my application, all I had to do was bring up the properties of my project, add a named setting of whatever type I wanted (more on this later) and choose whether it should be an Application setting or a User setting. Both kinds of settings are loaded automatically when the app starts and all I had to do to save them was call Properties.Settings.Value.Save() when my main form shut down. Then, with the settings in place, e.g. MyUserSetting, I could get to it after the app started from anyone in my app with a type-safe access, e.g. Properties.Settings.Value.MyUserSetting.

And this didn’t just work for built-in simple strings and ints and such like. Oh, no. I was allowed to add custom and collection types like System.Collections.Generic.List as well. Plus, using generics, the underlying XML serialization mechanism worked great, because all of the types are known at compile-time (settings are stored in standard XML .config files @ c:\documents and settings\\Local Settings\Application Data\\\\user.config). Being able to declaratively set app and user settings of any type and then just use them in a type-safe manner, saving them with one line of code, loading them with zero lines of code and not having to flatten my collections into comma-separated lists made things so pleasant until I hit the ugly realities of beta software, especially as new features interact with existing features and each other.

For example, because the default AssemblyVersion attribute is set to 1.0.*” in AssemblyInfo.cs (which has moved to below the Properties folder of your VS05 project), every time I compiled, all of my settings were lost. That seems very counterintuitive to me. Why should a user lose all of their settings with the new version of the application? To work around this, I changed my AssemblyVersion attribute to a hard-coded string that I now have to remember to change manually, blowing the benefit of having a version number that changes automatically with each build.

As another example, like C++ const” of old, generics infect your code; use them in one place and you find yourself using them all over. That was fine with me (the generic Predicate for finding things in a List was so handy!) except that as of b1, the Windows Forms Designer gets all unhappy when you use generics. I have every hope that this will be fixed by b2, but as of right now, if I wanted to use the Designer (and it’s so sweet, how could I not want to use it?!?), I had to strip out any methods or properties in my visual code that exposed generics (although method and property implementations with generics works just fine).

Stripping out List brought me to the use of ArrayList instead. That worked just fine (System.Collections.ArrayList is even available via the Browse button when setting up app/user settings) until the XML serializer couldn’t serialize instances of the custom type that I was using to populate my ArrayList. The error looked like this:

Could not use Xml serialization for setting: SelectedExchanges. --->
System.InvalidOperationException: There was an error generating the XML document. --->
System.InvalidOperationException: The type MyNamespace.MyType was not expected.
Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.

When I start up the debugger to see the line of code where the error is happening, I ended up in Main because the code is part of the Application start-up for which there is no source code, making this even more difficult to debug. The problem was that the underlying serialization engine didn’t know what to do with this custom type. The clue was the mention of the XmlInclude attribute, which you can use to tell the serializer what types may be in the ArrayList, but you have to have somewhere to hang the attributes. In this case, that lead to a custom ArrayList type for the express purpose of informing the serializer (making me really miss the use of generics, where all of the types were specified at compile-type for me automatically):

[System.Xml.Serialization.XmlInclude(typeof(MyNamespace.MyType))]
public class MyList : System.Collections.ArrayList {
  public override object Clone() {
    MyList newList = new MyList();
    newList.AddRange(this);
    return newList;
  }
}

Notice also the Clone method. I added this later because the base ArrayList Clone method creates an instance of ArrayList, not my custom MyList type. Of course, since this was all run-time type errors, I couldn’t let the compiler tell me about these problems; I had to run my app and find them. Very frustrating, especially when generics makes these problems all go away.

Still, I’m very much enjoying the new productivity features in VS05 and Windows Forms 2.0 and when they work better together, I’ll be even more happy.

October 7, 2004 spout

Every Story I’ve Ever Written

I was working with a potential author on an article he’d like to write covering some ground I left uncovered in my original No-Touch Deployment piece for MSDN Mag. Anyway, he sent me the list of topics and then said the following:

There is a fair amount of material here it might benefit from being broken into chunks. I think I will write about small chunks at a time and then we see how much belongs in one article. Rereading your original article it struck me that you had [a] story that held it together, I need to find one for me.”

I’ve heard this kind of thing before, i.e. people ask how I turn a seemingly random set of topics into a story.” I’m all for that, but it’s not really such a chore. In fact, here’s the essence of every technical piece I’ve ever written:

So, I want to build this thing that needs to do this, that and the other. I started with this, did it this way and it worked. Now I need to do that. Oops. That didn’t work the way I thought it should. Here’s what I need to do to work around the problem. OK, now I want to do the other… [repeat]”

The secret is really building up from what the reader already knows with some minimal new, interesting thing and keep on like that til you’ve covered the ground you want to cover, stringing things together with transitions that give the reader the impression of one contiguous story. If you really want to get fancy, put a personal anecdote at the front that you use as an analogy, bring it up a few times during the piece and then wrap up with something clever that ties the your anecdote together with the ground you’ve covered by extending the analogy in a humorous way (but that’s optional).


← Newer Entries Older Entries →