Clemens Vasters posted a great article on what’s really behind a Service Oriented Architecture from the implementation standpoint. He makes some very astute points about why schemas are important for expressing service contracts, and what the implications of SOA are on implementing scalable solutions. Having wrestled a bit with this myself, I agree with his conclusion that old-school OOD is not the way to approach this particular problem. Also, with regards to the stateful vs. stateless issue, I really like his take:

Ruling out that state is implicitly shared between services (in memory or on disk) is a direct consequence from this and also serves the scalability purpose, because it further eliminates co-location assumptions about services and enables clustering. Note that this isn’t about “stateless” or “stateful”. Everything is stateful while it runs.

I’ve been a big fan of XMLSpy for a long time. It’s one the best XML tools out there, and I’d have to say the very best schema editor. Now with their new version 2004, you can integrate XMLSpy directly into VS.NET, and use all the functionality of XMLSpy without having to leave everyone’s favorite development environment. Very cool stuff. I much prefer the schema editor in XMLSpy to the database-centric one that ships with VS.NET, so it’s nice not to have to launch yet another app to get at it.

I love appropriate applications of technology, and I just came across a really cool one. Our public transit system here in Portland (Hillsboro) OR now has up to the minute bus tracking information available for cell phones (trimet.org/wap) and wirelessly connected PDAs (trimet.org/pda). You put in what route and which stop you are at, and it will tell you when the next bus is coming. How cool is that?! As someone who both has a WAP phone and commutes to work on public transit (since I can’t afford one of the new 2004 Prius), I’m pretty excited. This is possibly even better than WAP/PDA accessible movie times, which was formerly my favorite application of wireless technology. Since they are pretty static, I actually get my movie times through AvantGo on my PocketPC (a ViewSonic v37).

Werner Vogels posted a great article on what Web Services are and aren’t, and why they represent Service Oriented Architecture, and not a Distributed Object Architecture. Don’t let the name SOAP fool you.

Just finished struggling through yet another Windows Forms issue that had us completely baffled. Writing multi-threaded WinForms applications brings up some very interesting challenges, and involves learning a bunch of new stuff, some of which is not at all obvious. See my previousposts on InvokeRequired for a good example. There end up being some really interesting consequences of the boundary between the CLR only world, and the underlying implementation where windows have to deal with message pumps. While WinForms insulates us from the real underlying PeekMessage calls, they are still there, and at some point the rubber has to meet the road, so to speak. The problem I just had to deal with is way to complicated to even summarize here, but the core of the problem was that if I call Thread.Sleep on short intervals in a loop with calls to Application.DoEvents in between, the GUI doesn’t update correctly, but if I call Form.ShowDialog then it does. WinForms knows something about message pumping that I don’t, which doesn’t really come as a surprise.

Some days I think that this is way harder than MFC was, but on other days (like today) I realize that the real difference is that WinForms frees us to hurt ourselves in new and different ways that were too hard to achieve before. I can only think that’s a step in the right direction. J

It’s a bit off topic, and not strictly speaking technical, but I’ve got to say I’m totally digging Rhapsody. For a very reasonable fee ($25 a quarter) I can now listen to something like 20,000+ albums from anywhere I’m online. Much easier than trying to haul around 10 or 20 Gb worth of MP3s, and I can play music from anywhere there’s a broadband connection. There’s no activation or other association with a given machine, so as long as I remember my credentials I can listen from anywhere (one place at a time, of course). So if I really want to listen to Rob Zombie, Fatboy Slim and the Rolling Stones in the space of 20 minutes ( I hadn’t realized what a Rob Zombie fan I really am ) it’s all there. There are a few noticeable holes in their collection, but they’re adding new albums all the time, so I have high hopes. And best of all, it’s legal and guilt free. And if I really must listen to something when I’m not online (which doesn’t seem to be all that often) then I can burn most of their tracks to CD for $.79, which is comparable to Apple of Buy.com’s offerings.

Groovy

Now if only Rhapsody supported the blogging plug-in… (Right now it’s Mad Flava by Fatboy Slim)

Fixed. If we move all our initialization code to run after the controls have been fully created and added to their parent’s Controls collection then everything works just fine, and InvokeRequired returns what it should. Again, the more I think about this problem the more it makes sense that it would work this way. However, what I would expect is for the call to InvokeRequired to throw an exception if it can’t really determine the right answer (e.g. isn’t initialized properly?) rather than just returning false. If it had thrown an exception we would have found the problem right away, rather than having to discover it the hard way. And since calling InvokeRequired on a control without a parent is apparently an exceptional case, it would be the right thing to do.

If anyone who reads this is or knows a PM on the WinForms team, you might mention this issue. J

I spent some time late last work working with my colleague Jeff Berkowitz on what seemed like a pretty sticky problem. He’s got some more info about the problem here, but the quick description is that we were in a situation where Control.InvokeRequired was apparently returning an incorrect value. Our code was clearly running on a thread other than the GUI thread, and yet InvokeRequired returned false. Disconcerting to say the least.

Jeff spent quite a bit of time tracking down the problem over the weekend, and the conclusion that he came to is that if you want to call Control.InvokeRequired and get a rational and deterministic answer, the control you are calling it on must be embedded in the control containment hierarchy all the way up to a top level Form. What we were doing involved creating controls but holding them in memory without putting them into the “visual” hierarchy of the application, meaning that they were not contained by a parent Control or Form. Apparently if that is the case, InvokeRequired doesn’t return the correct results. (Note that so far this is based on experiential evidence and not “scientific” data.)

The longer I think about this the more I’m not surprised that this is the case, but I’ve never seen any hint of documentation (from MS or otherwise) that indicates that this is true. The solution (at least for us) is pretty straightforward, and involved moving some initialization code until after all the controls have been fully created and sited in forms. Not a big deal, but it does prevent us from doing some up front initialization in a place where our users wouldn’t notice it. Now it’ll take a progress dialog. Seems like a reasonable price to pay, but it would, of course, be nicer if it worked the way we expected it to.

So far I’ve done some experiments with a couple of the options I mentioned in my last post. I tried styling the incoming XML document into something I could read into a dataset, and then used SqlDataAdapter.Update to persist the changes. This works pretty well, but the biggest issue ends up being foreign key constraints. I think you’d either have to do some pretty funky stuff in the stylesheet, or clean up the foreign keys once they were in the dataset, although that only works if your dataset doesn’t have constraints to begin with.

Then I tried OPENXML, and I’ve got to say that so far that’s the way I’m leaning. It turned out to make things much easier if I style the incoming XML into a simpler format (without all the namespaces) then pass that to OPENXML. The OPENXML code turned out to be way less hairy than I had thought it might be, and I can handle the transaction in the stored proc rather than using DTC transactions. All in all, not a bad thing. It’s almost enough to make me not care if things change in Yukon in ways that would make this not work, or be obsolete. It’s pretty slick in the near term. I haven’t tried any performance testing, but it seems to me that the OPENXML solution is faster.

I could try the other option of parsing the XML in C# and then making transacted ADO.NET calls to persist the data, but I don’t really want to go there. It’s the business-layer XML parsing I’m trying to get rid of, and it’s a lot more code.