I’ve been playing with Rx (Reactive Extensions) quite a bit lately and I have to say it’s one of the most powerful features added to .Net since LINQ. That probably isn’t too surprising since a lot of people call Rx “LINQ to Events”.
One common task when creating UIs is to call some function, like a filter or search, when the user stops typing. Anyone who has set this up before knows how painful it is but with Rx it’s dead simple.
private IDisposable textBoxObserver;
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
textBoxObserver =
Observable
.FromEvent<TextChangedEventArgs>(SomeTextBox, "TextChanged")
.Throttle(TimeSpan.FromMilliseconds(500))
.ObserveOnDispatcher()
.Subscribe(HandleSomeTextBoxTextChanged);
}
void MainWindow_Unloaded(object sender, RoutedEventArgs e)
{
textBoxObserver.Dispose();
}
private void HandleSomeTextBoxTextChanged(IEvent<TextChangedEventArgs> args)
{
var tb = ((TextBox)args.Sender);
var text = tb.Text;
SomeFunctionYouWantToCallWhenTheUserStopsTyping(text);
}
There are a lot of other really cool uses for Rx so I’ll be posting more soon. Until then you should check out 101 Rx Samples or this simple implementation of drag & drop in Silverlight.
I’ve created a new project for Behaviors on CodePlex, the WPF Behavior Library. A behavior is basically just a set of attached properties and functionality you can attach to a visual element. By attaching the behavior to the bit of UI you give it the additional functionality.
The first behavior I’ve included is Drag & Drop. There are a few drag and drop behaviors out there right now but they all require a lot of modification to use in other applications. Most of them only work for a subset of the UI elements that inherit from ItemsControl (mostly the ones that have their own ItemsContainers), some can’t move items between windows, and some don’t allow you to change logic behind moving items. In short none were general purpose enough to just grab a dll and use the behavior.
So take a look at the WPF Behavior Library, give feedback, report bugs, suggest new behaviors and features, or contribute.
There has been a lot of well-deserved hype over the Windows 7 phone since Mix10. The developer story they’ve put together is amazing. They’ve given us a model that is as easy to develop for as Android while staying as powerful as the iPhone. The interface is simple and intuitive and is on par with other smartphones (except for lack of cut-copy-paste support). It even adds a host of social features that I haven’t seen from its competitors.
But I think it’s more likely to fail than succeed for one simple reason: Microsoft still hasn’t realized the difference between being an incumbent in the market and being a challenger.
- An incumbent needs to focus on the person who is upgrading from the previous version. They need to make sure nothing major breaks when you upgrade, the user interface stays consistent, all of your old data transfers without the user realizing any updates were needed or at least so easily that my grandma could do it, and a few features need to be added to make sure the user has a reason to upgrade.
- The challenger needs to do everything the incumbent does (at least the most popular features). If they don’t any user who tries out your new product won’t be able to do what they could with the incumbent’s product and won’t switch. They also need to add significant new features that the incumbent doesn’t have or users will have no reason to switch and most will just stay with the incumbent’s product since they’re already comfortable with it.
So let’s take a look at the Windows 7 phone and what it offers.
- The user interface is good and will work well for anyone who’s used an iPhone or Android-based phone. There are no real surprises or innovations in the UI but it is on par with the major players.
- It does all of the things expected by a phone. It makes calls, sends text messages, has a camera, and has a calendar.
- It does all of the things expected by a smartphone. It gets on the internet with a real browser, has email and calendar syncing capabilities, and runs apps.
- It has a bunch of cool social features built-in which the others don’t have except via apps.
- The developer story is very good. Much better than the iPhone’s all around and more powerful than Android’s.
So the Windows 7 phone does what we’d expect of a smartphone and adds a better developer story and some social features. That matches with the requirements to be a viable challenger doesn’t it? Well yes, it matches up very well and that’s what has the Microsoft ecosystem all excited. One problem is that social features in general don’t really seem to draw in customers (think Zune), especially when the other phones have apps that will give you the same functionality if you really care. So you probably aren’t going to get many customers to buy one just by adding social features.
Which brings us to problem number two. Developers aren’t going to develop for the Windows 7 phone unless there are enough users (potential app buyers) to make it worth the cost of developing the application. Users, for their part, aren’t going to buy the phone unless there are enough apps to replace the ones they used on previous phones. So you have a classic chicken and egg problem. I asked the Microsoft representative at Mix10 how they were planning on dealing with this and the only answer he could give me was that we should all “take a bet on the [Windows 7] phone”. That will work for a few developers but probably not enough to fill your application marketplace with amazing apps that will make people want to switch.
The question I’m left with is: What will I need to see in order to take a bet on developing for the Windows 7 phone?
- Android problems – I see Android and Windows 7 phone as aiming for the same group of users. Both are aiming for users that don’t want to switch to AT&T and developers that don’t want to develop in Objective-C or deal with Apple’s app store. Apple is suing HTC, the maker of the best Android phones (Droid, Nexus One) of the current generation, and trying to stop them from being sold in the US. If Apple wins the suit it will be a big victory for the Windows 7 phone since it will nearly erase the year lead Android has.
- Low uptake of the iPhone on Verizon – Many smartphone consumers who don’t already have an iPhone seem to have held off because they don’t want to switch to AT&T. Apple’s exclusive contract with AT&T ends this year and they’re widely expected to announce an iPhone for Verizon along with iPhone OS 4.0 this summer.
- Marketing – It’s no secret that Microsoft’s marketing doesn’t do too well when targeting consumers (although they’ve gotten better). They will need to have a massive and well timed marketing push from this summer through a few months after launch. When Apple starts releasing iPhones on Verizon people will need to know there’s an alternative coming out and maybe they should wait a couple of months to check it out. When the Windows 7 phone actually gets released there will need to be some amazing marketing to beat the marketing Apple and Google will surely be doing at the same time. They will need to worry less about things consumers don’t care about (speed/memory of the hardware, ease of development, etc) and more about what the phone will allow them to do. If their marketing team doesn’t come out with a catch phrase like “You can do that” (note to Microsoft marketing, you can use that if you send me a free phone) then they probably aren’t going to do well. Want to check your work email, facebook inbox, and gmail all from the beach with just a glance? You can do that!
- Kick-ass Marketplace – It will need to be dead simple for users to use and find things they will like and want to buy. Something like a rating system and Netflix algorithm built in maybe? It will also need to be extremely easy for developers to get their apps on the marketplace and to upgrade existing apps. If there has to be some sort of application vetting process it needs to have easy to understand rules, a rapid turnaround time, and should probably only focus on malware, ratings (e.g. G, PG, PG-13, R, X), and category.
They’ll need at least three of the four to have better than even odds. I’ll be watching closely with fingers crossed.
Well Mix10 is wrapping up and I’m beat. I think my brain needs some time to process everything I’ve seen and learned but some interesting nuggets are floating around in there already. If anyone out there is still wondering if attending Mix is worth it, stop wondering. The sessions aren’t the real reason people attend a conference like this, they’re merely the excuse. The real reason to attend Mix is for the conversations. You are constantly having great dialogues with the presenters, with your peers, or with Miguel de Icaza, Erik Meijer, or Bill Buxton. It’s these conversations that are the true value of Mix, the sessions you can see for free online within 48 hours from the time they occurred.
Windows 7 phone
The biggest story at this year’s Mix is the “unveiling” of the Windows 7 phone. Overall I have to say that I wasn’t extremely impressed and I think it’s likely to flop. Unless Microsoft’s marketing department can pull some magic out of their collective hats the phone is going to run into the classic chicken and egg problem between applications and users. I have some arguments to back up that statement but they’ll require a post of their own.
IE 9
IE 9 looks like a step in the right direction. The demos were impressive but you’d have to be a fool to do a major demo where you didn’t beat the pants off your competition, especially when you’re running with most of the chrome and user features turned off. I’m sure the Chrome, Firefox, and Opera teams could all put together similarly impressive demos showing how their browsers leave IE 9 in the dust. Historically Internet Explorer has never had a place on my computers and I haven’t seen anything from IE 9 that is likely to change that position.
OData
I don’t really have anything to say about OData. It looks like a cool solution to a problem I’ve never had. I will most likely consume an OData service at some point and I’ll definitely look into it some more then. I was happy to see LINQ integration since that was the first thing that popped into my head when I saw the first demo. That got a clap from me me and like one other person during the keynote which leaves me curious if everyone else just expected it or if they haven’t realized the amount of power LINQ puts at your fingertips. I’m betting it’s the former.
Silverlight
The big winner at this Mix was Silverlight. With Silverlight 4 it’s becoming a very real solution for the internet connected applications of the future. I honestly believe Silverlight or something like it is the future of internet applications. I can run an application on the web, from my desktop, from my laptop, from my phone, or from anywhere else and always have the same data and settings shared to whatever device I’m on. That’s a really powerful story from a user’s perspective. From the developer’s perspective using MVVM I can run the exact same model and viewmodel for every device and create multiple views so I can choose the best for whatever screen the user wants to see. That takes away quite a few pain points and represents a pretty big cost reduction to management.
A++
If you were only able to choose one book to make you a better programmer, that book would be Code Complete. There is a reason it’s the highest voted answer to the StackOverflow questions What is the single most influential book every programmer should read? and What development book made the most impact on you as a developer? as well as many others. Notice that second place for both questions is Pragmatic Programmer, you should go read that too, after Code Complete.
There really isn’t anything I can say about Code Complete to describe how truly awesome it is. From your future self and all of the people you work with please buy it and read it from cover to cover. I’m not kidding, you might think you know everything it covers, and if you’ve been programming for a few years you might even be right, but you won’t have thought about each of the topics explicitly and in the detail covered by Code Complete.