Posts
293
Comments
27
Trackbacks
206
April 2004 Entries
Code in books

Code in books has always been a dilema; what language should we use? For books targetted at a aspecific language it's no problem, but what of books aimed at a technology, such as ASP.NET books. The general consensus is that C# programmers can generally read VB better than VB programmers can read C#. It's a catch-all statement, and obviously doesn't cover everyone, but on the whole it's probably right. Certainly in the ASP.NET community I reckon it's more accurate.

So, the dilema is what to do with code samples. And we're talking samples within the book, not downloadable ones. Do you just sweeping ignore one language? For a generic technology book using on C# would limit your audience as VB people wouldn't buy it, while using VB would deter less people. It's good to see people voicing an opinion on this; a book that puts samples in both languages. While this is great, there are problems. First is I'd feel that if every code sample was in both language the book would feel really fragmented; it would break up the actual content too much. Also for larger samples, such as a page or two long, that would mean four pages of code. I'm not particularly keen on this, although I have to admit I've done it in the past. The other thing is that it increases the cost of the book; more samples means more pages means more costs. Those costs (editing, reviewing, printing) inevitably get passed on to the consumer.

So what's the solution? Well, I don't have one, but I'd sure like to hear your views. I don't dislike the multiple languages scenario, but it depends upon the book. Until we all have electronic books where you can just select a language option (a la MSDN) we're stuck with making a choice. What do you prefer?

posted @ Wednesday, April 28, 2004 10:25 AM | Feedback (-33)
ASP.NET 2.0 Themes and Profiles

Here's something that might be useful if you're starting to look at ASP.NET 2.0. Master pages allow you to centralise the site design, Themes allow users to customise (to a degree) UI and the personalization Profile allows easy configuration and access of personal settings (such as the theme). Because of the way the control tree is constructed, the Theme either has to be set declaratively (in the Page directive or web.config) or in the new PreInit event. The question is what do you do if you want all pages to a) use a master and b) have the Theme set from the Profile. Common sense would dictate that you use the PreInit event in the master page, but it doesn't exist, forcing you to use PreInit in every page. Now I don't like typing in the same code into every page, and I suspect you're the same.

The solution is to use a custom base class for the page, which can be set for the entire site in web.config:

<pages masterPageFile="site.master" pageBaseType="MyPage" />

Now create your custom base type, placing the file in the Code directory to avoid all that nasty compilation step:

 Public Class MyPage Inherits Page Protected Overrides Sub OnPreInit(ByVal e As System.EventArgs) Dim p As HttpProfileBase If User.Identity.IsAuthenticated Then p = Profile.HttpProfileBase.Create(User.Identity.Name) Else p = Profile.HttpProfileBase.Create(Request.AnonymousId) End If Page.Theme = p.GetPropertyValue("Theme").ToString() MyBase.OnPreInit() End Sub End Class 

Since all of your pages inherit from this class, they automatically inherit this behaviour, having their Theme set from the Profile property of the same name. It even works for anonymous users (don't forget to mark the property as allowAnonymous).

posted @ Monday, April 26, 2004 9:05 PM | Feedback (-59)
Funny error messages
Sorry, just had to post this exception I've just received. I've always thought exceptions were for things that didn't complete sucessfully.
posted @ Thursday, April 22, 2004 4:17 PM | Feedback (2)
Betas, Intellisense and Perception

So here's an interesting point. When we have a problem when using beta code do we just naturally assume it's a problem with the beta? I had some questions to ask the team so Alex asked me to report a bug with the BulletedList control, where the BulletStyle attribute didn't seem to be working. He's checked the code several times and wondered why the attribute wasn't being acted on server side, but being passed to straight through to the client.

He's off to a conference so I looked at the code, and spent half an hour or so trying to work out the exact situation where it wasn't working, so I could provide a good code sample along with the bug. It's only then that I spotted he'd mis-spelled the attribute as BulletSyle - missing the t from the Style. We'd both read what we'd wanted to read, rather than what was there, and both decided it was "that damn beta code".

Of course IntelliSense would have picked it up if we'd been using VS (only had the framework on that machine at the time), but it's interesting the way we both assumed something else was wrong; our perception being that beta software was more likely to be wrong than our code, which two of us had checked. We expect beta code to be flakey, hence the assumption. Of course we all know assumptions are bad, but it's amazing how easily you fall into the trap.

Now I've publicly embarrased myself, it's time to try and do some coding that actually works.

posted @ Thursday, April 15, 2004 4:04 PM | Feedback (0)
VPC is driving me mad

I've had VPC installed for some time, but have only just started using it in anger, what with Whidbey builds and all. So I ahve Whidbey running on VPC with a bunch of windows open, plus several windows on main OS. I'm quite a heavy user of Alt-tab, so have a habit of using that to switch to the VPC image to check something. This is where the habit drives me mad, since once in the VPC window I just automatically Alt-tab to go back to the previous window (invariably Word, since I'm doing book work at the moment). But of course it doesn't switch back because I'm now in a VPC windows, so it just switches between the windows in that image. Arrggghhhhhh. Driving me mad. Is there a way to turn Alt-tab off? And would that even work - what I want is alt-tab to actually ignored by the VPC OS and bubbled up to the hosting OS. Gues I'll just have to get out of the habit.

posted @ Tuesday, April 13, 2004 10:14 PM | Feedback (3)
Travelling to the USA
There's been a lot written about the upcoming changes to immigration (ie finger printing and photos) for all travellers, including those on the visa waiver program (such as the UK). I'm not going to comment on the rights or wrongs, but rather remark on what the undersecretary for border and transportation security said. He said "[the security measures] should not create massive backlogs ... it takes only 23 seconds per person to take fingerprints and photos and check them against government files". Nicely put, as it 23 seconds doesn't seem a lot. What's glossed over of course, is that 23 seconds is in addition to the normal routine, and it's cumulative. If you're third in the queue you wait 46 seconds, and so on. With 300 people on the average big plane (a rough guess), and the person at the back has to wait 300*23 seconds - that's 6900 seconds or 115 minutes. Nearly 2 hours. Hmm, nice.
posted @ Monday, April 05, 2004 5:58 PM | Feedback (2)
Learn 24 7

Yesterday I spent the day at Microsoft UK for the first meeting for the WeFly project. This is a .NET 2.0 project for a DVD of training material, supported by the Learn247 site. I wasn't involved in the previous DVDs, but am in charge of the ASP.NET track for the new one. This means I'm defining the requirements for the ASP.NET application, creating and recording the training sessions. The team currently stands at 9 people; two developers (writing the applications), two multimedia people (creative content, graphics, design, and DVD production), and 5 architecture and content creation people. Others may well be drafted in for specific technology areas.

The project will be tracked on the Learn247 site forums, where we'll have documentation, weekly code drops, and soon a blog where we can all talk about how the project is coming along. It's a pretty cool application, and we're going to be soliciting input from the community. So get yourself over to the site and check out the previous applications.

posted @ Friday, April 02, 2004 10:25 AM | Feedback (1)