my blog subscriptions

Thu, July 13, 2006, 06:23 PM under Links

Recently I trimmed down the number of blogs I subscribe to and will do that again over the next couple of weeks. It came to the point where there were always 3-5 thousand unread items in my aggregator... I could never catch up!

So on my quest to be more selective I faced the dilemma of what I do with group blogs. The same goes for aggregate blogs. (discussion for the difference between the two here)

Current plan is to split the group/aggregated feeds from the direct ones (i.e from the ones where a single person is blogging.. allegedly :-).

Goal will be to keep enough direct subscriptions so that by the end of each week I can say "I've caught up with all of them". Who knows, I might bring back my BLOTW feature (BLOTW 2004 and BLOTW 2005). Will share my OPML when I am done with the trimming...


As for the group and aggregate feeds that I subscribe to (I call them "mass feeds")... they will be in a separate area and will only be scanned occasionally rather than read thoroughly. So, in contrast with the direct feeds, I do want to increase the number of mass feeds I subscribe to. One of the reasons is that a lot of the blogs that I am trimming out are part of some mass feed already so I can keep in touch with those that way :-)

Here is my current list of "mass feeds" (let me know if there are others I should know of) in truly random order:

http://bloggingabout.net/blogs/
http://blogs.conchango.com/
http://codebetter.com/blogs/
http://www.dotnetjunkies.com/WebLog/
http://blogs.geekdojo.net/
http://geekswithblogs.net/
http://msmvps.com/blogs/
http://www.pluralsight.com/blogs/
http://www.developerfusion.co.uk/blogs/
http://blogs.vbcity.com/
http://wdevs.com/
http://weblogs.asp.net/Bloggers.aspx?GroupID=2
http://www.wintellect.com/Weblogs/
http://blogs.msdn.com/

... and my latest addition, the feature-rich:
http://www.dotnetslackers.com/ ("an emergent and popular .NET community")


Webcast follow up

Sun, July 9, 2006, 09:46 AM under MobileAndEmbedded
Thank you all that attended my webcast.

For those that missed it, you can replay it here: .NET Compact Framework for Desktop developers. You get the same experience except slide animations seem to have been taken out and of course you can't interact and ask questions.

Speaking of questions, looks like my content was so clear that I didn’t have to clarify anything :-p. Instead, here are some of the questions that I received.

Q1) I see from one of the last slides that you won't be covering SQL CE/SQL Mobile/SQL Everywhere. Please consider doing so in a future webcast.
A1) Thank you for the suggestion. In the mean time you can find info on SQL Everywhere here and here. Ask questions on this topic here.

Q2) Does Groove offer support for mobile devices yet?
A2) I have absolutely no idea. I would think not and indeed searching seems to bring back no relevant results so I'll stick with "no it is not supported at the moment" guess. If anyone has info to the contrary please enlighten me and I'll update this. Groove home page.

Q3) Are there any particularly cool open source projects for Windows Mobile?
A3) Yes, SDF from OpenNETCF. Source for v1.x is free and for v2.x available at a small fee. Binaries are free regardless of version.

Q4) What's your initial opinion of the new Mobile Client Software Factory? Is it useful for beginners or should novices focus on more meat and potatoes issues?
A4) I think it is a great effort. As everything else, only you know if it is of value for your particular scenario but definitely do check it out.

Q5) Windows Mobile or Tablet PCs?
A5) Mobility development is a wide field from laptops to tabletpcs to UMPCs to PocketPCs to Smartphones to watches! Depending on the job requirements one or more of the previous platforms can be chosen for any particular project. There is no universal answer.
Expect to read more on this blog soon regarding the Vista mobility story

Q6) Mapping for devices?
A6) See this and this. I would expect this to fully support mobile browsers or someone will be missing a trick.

Q7) In some Windows Mobile devices the .Net Compact Framework is in the system ROM in others it has to be downloaded and installed, what is the performance and other impacts of the built in framework vs a downloaded version?
A7) If you are building against a NETCF version that you expect to be in ROM on all your target devices, then there is no issue. If you don't, then you need to deploy the NETCF runtime with your app. In that case, NETCF is installed in RAM and hence using some of it (much like installing any application on your device). The other difference between the NETCF being in RAM or ROM is a tiny perf advantage in the ROM case. This is not something you should be worried about as it will definitely not be your perf bottleneck if you have one.

My Vista System Performance Rating

Sat, July 8, 2006, 02:49 AM under Windows | Vista
I had a couple of people ask me after my Vista sessions
"What are you running it on? It seemed *very* fast!"
Since I haven't installed Beta 2 on my main laptop (Toshiba Tecra M5) yet, for all Windows Vista demos I still use an M3.

Best way to show the spec and what Vista thinks of it is to browse to Control Panel -> System and Maintenance -> Performance Rating and Tools.

Screenshot follows:

--
UPDATE: Also see Windows Experience Index

Beta lifestyle

Fri, July 7, 2006, 11:48 AM under Random
How much pre-release software are you using? Loads right? Whether you love it or hate it, that is the result of increased transparency. Companies are not afraid to share very early what they are working on and have put systems in place to gather feedback from customers (while having an open dialog with users about features and quality). I have no problem with that and I think the breed of user that shies away from software that has the "Beta" label on it will become extinct very soon.

Looking back in the past, it used to be that I would have a separate (older) machine for testing anything Beta, then I moved to Virtual PCs, then I started installing stuff on my main laptop only if I knew it would uninstall cleanly. Now (and maybe this is part of my job, I don't know) I just stick anything that is coming down the pipeline on my laptop and couldn't care less about its stability or removability - I just want to play with it. I want it to always be there without having to switch to another (virtual or not) slower box. My current attitude culminates with the expectation that I will repave the box every couple of months (that is only 6 times a year!).

Since it was released, I've been running Office 12 Beta 2 and using Outlook/Word/PowerPoint 2007 every single day with no serious problems (outlook crashed once and was polite enough to offer me the option of starting in safe mode). IE has become my main browser again with IE 7 (now at Beta 3) after Firefox stole me away from it last year. I still haven't gotten round to putting Windows Vista on this laptop mostly because I inherited another laptop with Vista on it already (Feb CTP that I updated to Beta 2). That's next on my list and I might go for 5456 or Beta 2 or hung on a bit for the next one (so compared to some of you, I know am still behind in this game :-).

Do you find it is a bit like an addiction? I mean, when something finally gets released, I just want the next version already; case in point Live Messenger and ActiveSync 4.2

Note how I haven't even mentioned dev stuff such as NetFx3 or NETCF SP1 (out of Beta now) or any Orcas bits... as a developer, I take it as read that those things will land on my machine

Also note how I don't mention any of the Beta web stuff (i.e. thin client, no local bits) since, technically, that is cheating IMO :-)

using pattern

Mon, July 3, 2006, 04:20 PM under dotNET
Previously we described the using statement. After showing a quick code example and describing the intent of the construct, we proceeded to a more pragmatic description of what it does which I repeat here:
"The using statement accepts as an argument an object that implements IDisposable; it defines a coding block where the ctor of the said object is called at the start and the Dispose method is called in the end."

Taking the definition above, a design pattern is formed (or to be more precise in this case, an idiom):

Sometimes you have a piece of code that has to be enclosed between two code blocks A and B. Code blocks A and B are repeated in multiple places in your project(s). When you recognise that, you can extract a new class with a ctor containing code block A and the Dispose method containing code block B. Replace all client side occurrences with a using block passing in the newly extracted class.

As an example, instead of:
void SomeMethod()
{
Cursor.Current = Cursors.WaitCursor;
statusBar1.Text = "Busy...";
button1.Enabled = false;

// do some real work here

button1.Enabled = true;
statusBar1.Text = "Ready";
Cursor.Current = Cursors.Default;
}
we write:
void SomeMethod()
{
using (BusyTaskRegion bt = new BusyTaskRegion(statusBar1, button1))
{
// do some real work here
}
}
...after extracting the following class:
class BusyTaskRegion : IDisposable
{
private Control _c1;
private Control _c2;

public BusyTaskRegion(Control c1, Control c2)
{
this._c1 = c1;
this._c2 = c2;
Cursor.Current = Cursors.WaitCursor;
c1.Text = "Busy...";
c2.Enabled = false;
}

public void Dispose()
{
this._c1.Enabled = true;
this._c1.Text = "Ready";
Cursor.Current = Cursors.Default;
}
}
Another example would be measuring performance of some code (i.e. extract the timer setup and tear down into a class and then use it via using). I was trying to find the pattern formally documented online but I couldn't. However, I did find examples of its usage here, here and here (much better than my fictitious example above!).

When I first saw this (at a previous project for some impersonation code), it felt wrong on two levels. First, it felt like using was being misused in scenarios that it wasn't originally intended for (e.g. when people read the client side code they have to take an extra mental step to digest that no memory management stuff takes place). Second, it felt wrong to define classes that have just a constructor and a Dispose method with nothing else in-between.

What do you think?

using statement

Mon, July 3, 2006, 06:35 AM under dotNET
The using statement has been in C# for ever and was newly added to VB8 as well (Using). I hope everybody is familiar with it by now (not to be confused with the using directive typically appearing at the top of code files - Imports in VB). If I asked you to tell me about the using statement, I bet that most of you would use a code example , maybe something like the following.

Given a class like this:
class SomeType : IDisposable{
public SomeType(){
// do some ctor stuff
}

public void DoSomething(){
// do some useful stuff
}

public void Dispose(){
// clean up unmanaged resources
}
}
We know that the client code should use it like this:
SomeType st = new SomeType();
try
{
st.DoSomething();
}
finally
{
st.Dispose();
}
The using statement makes that cleaner, easier to remember and easier to enforce like this:
using (SomeType st = new SomeType())
{
st.DoSomething();
}
So, the easy way to describe the purpose of using (without a code example) is this:
The using statement offers an elegant way of ensuring that the developer does not forget to call Dispose on an object that (directly or indirectly) holds unmanaged resources. (My links to msdn at the top pretty much say the same thing)

Effectively, we all associate the using statement (or at least I always did) with not leaking. However, if we look at the using statement not from an intent point of view but instead from a practical point of view, we would probably come up with this:
The using statement accepts as an argument an object that implements IDisposable; it defines a coding block where the ctor of the said object is called at the start and the Dispose method is called in the end.

Next, we'll see how to take that last statement further to describe a design pattern.

Happy 20th to me :-)

Sun, July 2, 2006, 03:03 AM under Personal
Today, 2nd July is my birthday! I am glad they moved Tech Ed Europe to November this year, as I am sick of spending my birthday at a conference!

Oh and, yes, I am just 20 years old... if I count in hex that is ;-)

WM 5.0 projects on Vista

Fri, June 30, 2006, 04:27 PM under MobileAndEmbedded
It seems many NETCF developers are being bitten on Windows Vista after installing the WM 5.0 SDK for Visual Studio. The symptom is that although the SDK installation appears to go fine, the WM 5.0 project templates do not appear in VS2005.

The problem has to do with User Account Control (btw, I'll have a lot more to say about UAC in a future blog post). The way to work around it (on Vista Beta 2 at least) is to disable UAC and then install the WM 5.0 SDK thus getting the project templates to appear.

Specifically:
1. Launch "Control Panel"
2. Navigate to "User Accounts and Family Safety -> User Accounts"
3. Click on "Change Security Settings"
4. On the window that appears, uncheck the "Use User Account Control (UAC) to help protect your computer" checkbox (requires restart)
5. Now install the WM 5.0 SDK (or do a repair if you already had)
6. Launch VS2005 to verify you have the templates
7. Enable UAC again

The above combined with the WMDC update should answer most relevant queries...

.NET Compact Framework on Symbian

Tue, June 27, 2006, 03:18 PM under MobileAndEmbedded
Some people are asking about NETCF on Symbian. This makes me smile.

You see, every now and then, someone will bring out a Nokia phone and show me some end user feature and ask me how to achieve the same on a Windows Mobile device following it with a rant about how Symbian devices are dominant in the market compared to WM devices. My response is always the same. Yes, at the moment, Symbian is the dominant mobile OS when it comes to number of end user devices out there (not so sure in the enterprise/corporate world). However, from a developer perspective, that is completely irrelevant! Ask not how many devices are out there, ask how many of them are running an app that did not ship with the device. In other words, ask what percentage of Symbian devices compared to WM devices are running a 3rd party application that the user installed themselves. Windows Mobile *is* the dominant OS when you ask the right question and it is kind of expectant really: Every windows developer is a potential WM developer. The platform itself is built with running 3rd party apps in mind.

So going back to the original question, it shouldn't surprise us that it is being posed. An unfortunate developer has been asked by a decision maker to target a Symbian device and naturally the developer wants to use a modern, RAD and powerful platform.

The best development tool for all your needs is of course Visual Studio. To that end, there is an add-in for Visual Studio that allows targeting non-WM devices BUT note that this does not use the NETCF on the target - it is just a tool thing.

The best development runtime/framework of course is the .NET Compact Framework (ok, so I may be slightly biased :-)). When I was at MEDC a South African guy (Dusan Babich) approached me with some brochures and interesting ideas about porting the NETCF to a subset of Symbian devices. He didn't have a demo to show at the time but he said they were very close to releasing. I am not sure how far it got but this is their website should you wish to follow up.

I also found this excellent paper on porting the NETCF to Symbian phones. Just to keep the balance, here is an article on porting Symbian apps to Windows Mobile SmartPhones.

So there you have it. A slightly lengthier reply than what I had in mind originally but it is good to have context, right? To wrap it up, my advice is to target the Windows Mobile platform that gives you a versatile range of devices with a common API (and the story will get even better with future versions of SmartPhone and PPC form factors converging, I would imagine). If I am perfectly honest, I am not sure WM will win the consumer market tomorrow, but it is definitely slashing into the enterprise space right now and once it is done there, more of an end user focus should follow, in my opinion.

Vista: Glass in C#

Sat, June 17, 2006, 05:32 AM under Windows | Vista
We looked at glass in Vista previously so please read that to make sure we are on the same page and using the same terminology... I'll wait...

Great, now that you are back, let's see how to get glass in our C# applications. For starters, if glass is supported and enabled on the user's PC, then your non-client area will by default get the glass effect. In other words, the titlebar and borders will have glass (nothing more for you to do). The question is how to extend that into the client area like other OS applications do (as we saw last time).

There are 3+1 things we need to do:
1. Check that it is supported before proceeding further.
2. Extend the frame into the client area.
3. Paint the extended area black.

Optionally,
4. Allow the user to drag our window by pressing in the glass area as if they were pressing on the window's caption bar.

So let's go!

1. First, let's make sure we are not on a legacy OS:
    if (Environment.OSVersion.Version.Major < 6)
{
Debug.WriteLine("How about trying this on Vista?");
return false;
}
After that, we need to check that glass is enabled by using the DwmIsCompositionEnabled API which resides in Desktop Window Manager (dwmapi.dll)
    // [DllImport("dwmapi.dll")]static extern void DwmIsCompositionEnabled(ref bool pfEnabled);
bool isGlassSupported = false;
DwmIsCompositionEnabled(ref isGlassSupported);
return isGlassSupported;
2. Extending the frame requires setting up a margins structure and passing it to another DWM API: DwmExtendFrameIntoClientArea.

So if we want to extend a bit from the top of the window(i.e. we don't care about extending from the bottom, left or right sides) we can use the following code:
    // [DllImport("dwmapi.dll")]static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins);
Margins marg;
marg.Top = 20; // extend 20 pixels from the top
marg.Left = 0;
marg.Right = 0;
marg.Bottom = 0;
DwmExtendFrameIntoClientArea(this.Handle, ref marg);
3. If you run your winforms app now, you'll find a black strip at the top. This is where we need the alpha blending and using a black brush does just that (tricking GDI that has no notion of an alpha channel).

So, in your form's paint event handler add the following code:
    SolidBrush blackBrush = new SolidBrush(Color.Black);
g.FillRectangle(blackBrush, 0, 0, this.ClientSize.Width, marg.Top);
4. Moving the form programmatically can easily be achieved by catching the mouse down/up/move events and some simple logic but instead we can use the following magic:
// make windows do the work for us by lieing to it about where the user clicked
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);

if (m.Msg == 0x84 // if this is a click
&& m.Result.ToInt32() == 1 // ...and it is on the client
&& this.IsOnGlass(m.LParam.ToInt32())) // ...and specifically in the glass area
{
m.Result = new IntPtr(2); // lie and say they clicked on the title bar
}
}

private bool IsOnGlass(int lParam)
{
// get screen coordinates
int x = (lParam << 16) >> 16; // lo order word
int y = lParam >> 16; // hi order word

// translate screen coordinates to client area
Point p = this.PointToClient(new Point(x, y));

// work out if point clicked is on glass
if (y < marg.Top)
return true;

return false;
}
5. There is no 5 :-) Just as a gotcha, if you decide to extend the client frame after the form has been displayed (and hence its handle has been created), you should call
this.RecreateHandle();

Note that there are other simpler approaches that use winforms Transparency but they seem to suffer from a very undesirable effect: When the user clicks on the glass area they are actually clicking on whatever is behind the form (true transparency is not what we want here).

Download a complete sample here.