Windows Phone 7 SDK First Impressions

by Jon Davis 25. April 2010 13:20

A couple co-workers and I had a couple days’ opportunity at my day job to tinker with creating a Windows Phone 7 app as a proof of concept. We successfully created an app that lets you find and purchase a company product (complete with checkout, although the checkout part was web-based), access account information via a web interface, and contact customer support via either an e-mail form or a “Call Us” button that, yes, would dial customer support via the Phone function of the device. (Strangely, the Phone part was the only part that did not work nor give any “Not implemented” nor “Not supported” feedback.)

We accomplished all that in two days, plus some reading up on XAML knowledge (i.e. I’d spent the entire prior Saturday wading through the Petzold PDF that had been linked from the developer web site .. where is that Petzold PDF link now?), plus some insider knowledge of existing APIs and some preexisting web interfaces used with other mobile devices. The only huge hold-up for us, as far as I was concerned, was the learning curve of the tool chain. I mean, it’s C# which I’m fluent in, but it’s also XAML which I’ve used but never mastered, and it’s brand-new Silverlight 4.0 (a binary-incompatible derivative thereof, I think). And I’m still pretty green to MVVM and still don’t understand a lot of the basics of MVVM such as how and when to use ICommand, etc. But we got a prototype built, with only two days to do it.

That said and done, however, I walked away from that little mini-project with a few opinions. A couple years ago I tinkered with iPhone development with the Xcode / Obj-C / Interface Builder tool chain, so I have the two phone SDK experiences to compare.

One theme – “minimalistic” – to rule them all?

My immediate observation is that the UI aesthetic guidance in the Apple toolchain is nowhere to be seen in Microsoft’s toolchain, and I expect this will hurt Microsoft. Sure, Microsoft pre-packages a couple white-on-black templates as an aesthetic suggestion to get you started with a basic theme. But that’s where guidance ends. You’re given a few XAML controls to get you started, and everything starts at a bland white-on-black. A button, for example, it’s just a white rectangle, no gradient, no border bezel, same story as the white-square-on-a-white-line slider control, all to reinforce the idea that white-on-black is good because OLED displays consume 50% as much energy this way versus 3x more energy if everything displays in full color.

image 
Wow, Microsoft, you outdid yourselves here, that is a
beautiful slider handle! (Not.)

And on that latter note, why didn’t Microsoft innovate here, such as this: as soon as the user interacts with the device, for a full 15-30 seconds everything’s in rich, full color, then after 30 seconds of inactivity the view goes into “interactive screen saver” mode whereby the colors fade to inverse and you see the color scheme that’s on the device color scheme now? Toggle this behavior for your app or navigation “page” in the SDK with a boolean switch and a timespan setting. Just a thought.

Whereas, with Apple, in Interface Builder (Apple’s GUI designer) you’re given a nice big library of richly colored controls and widgets including a nice tab control on the bottom, a header control on top where you can have your richly labeled back and forward buttons, and a number of nice interactive controls such as a “checkbox” that actually renders as a beautifully detailed ON/OFF slider, complete with simulated physics and even a drop shadow on the moving slider.

It’s not the absence of aesthetic tooling that bothers me here. Actually, Microsoft opened the door wide open to aesthetic freedom, as XAML richly supports deliciously detailed interactive graphics with Expression Blend and the like. My issue is the fact that other than “minimalistic white-on-black” there is no guidance, which is an issue that plagued Windows Mobile 6 and previous Windows Mobile flavors. You will have some beautiful Windows Phone 7 apps like the Foursquare app, and then you will have some apps from people who learned Silverlight and go nuts with gradients and bright, flashy, ugly designs, or who simply ported their Silverlight apps straight over to the Windows Phone 7 SDK. Aesthetic inconsistency is going to be a nuisance. This happened in Apple’s developer community, too, but you’re almost required to do this with the Windows Phone 7 SDK because the prefab tooling in the Windows Phone 7 SDK is, at least so far, incomplete. Then again, this is still just a CTP (a beta), so we don’t know how much more complete the SDK will be on its release.

The SDK comes also with a “list application” template, which demonstrates how to have that pretty list that has the 3D rotating items when you tap on them or navigate around. That was really neat, but then I found myself scratching my head wondering how to make that behavior stick across the rest of the application? Can I declare this animation/storyboard definition once and reference it with a one-line behavioral reference of some kind across all of my “navigation pages”? If so, that was not demonstrated at all, and it looked like I’d have to copy and paste everything in the templated demonstration to each and every page I’d create. We ultimately just ignored the animation code, saddened that only the “root menu” showed this animation, because it’s really not worth it to copy/paste so much code (about 50 lines of XAML) everywhere, making a mess of the markup.

No HTML DOM interaction

My other complaint is with the Silverlight 4 web browser component. It is truly wonderful that Silverlight has an integrated web browser component, and I adore Microsoft for adding it especially for the Windows Phone 7 SDK, as it’s absolutely necessary to integrate the web browser with many Internet-enabled applications. That said, however, I found no easy way of interacting with the DOM from the Silverlight CLR. In Windows’ Internet Explorer, you had to make a separate COM reference to mshtml.dll before you could interact with the DOM. I used to do this heavily. Perhaps I’m spoiled. But not having access to the document interface and, as far as I can tell, only being able to navigate and toggle scripting support really worries me that my hands will be tied here. It was, after all, Microsoft who invented dynamic HTML with fully dynamic content back in Internet Explorer 4, when Microsoft’s innovation inspired me so much that I decided to go all-out into being a web developer. That was way over a decade ago. I still want that power; XAML doesn’t always cut it.

Silverlight (and XNA) awesomesauce in a bag

I didn’t have a chance to play with XNA on WP7 much yet, but just knowing that support for XNA is there is very exciting. XNA is a fantastic platform to build games on, as it is approachable even for a beginning developer. My only complaint about XNA is that there is no virtual keyboard support. I did verify by fiddling with it that the physical keyboard seems to be exposed in the XNA API, though.

Despite my complaints about the WP7 SDK, WP7 is going to be a game changer, and a huge hit for the developer community, I’m sure of it, simply because it allows you to leverage your existing C# or VB.NET skills and prototype functional software on the device with beauty and finesse. Heck, you can even leverage Ruby skills for it. For some unknown reason, IronPython won’t run on it yet; I’m sure support for that will come before RTM, particularly given the volume of feedback for it.

But you could already?

Actually, C# developers have been able to write Windows Mobile software quickly and easily for years, albeit not with Silverlight nor with XNA. Windows Mobile has lost the market share, consumer sales is now akin to Linux’s market share on the desktop—about 2%. Microsoft is going to have to work hard—harder than they have worked so far, from what I can see—at winning over people to the Windows Phone 7 away from the iPhone, which now takes up a huge chunk of the mobile market share. They have to compete as well with the Android which already sought to compete with the iPhone, Blackberry, and Windows Mobile, and is doing one incredibly good job at doing so.

Frankly, looking at the iPhone 3GS vs. Nexus One (Google Phone) demos, I can’t help but look at the Windows Phone 7 and laugh at it. Windows Mobile 6 may have had the awful Start menu, the most ridiculous interface ever to have been put onto a mobile device, but with that stupid Start menu the platform also retained the “many apps and their icons” notion of an application playground which is strong in the iPhone and Android as well but not so easy to find in WP7. I have difficulty seeing how a marketplace would even work for WP7—will installed apps be categorized and the user would find their installed apps by category? Surely WP7 will not just throw all apps into one giant vertical list, oh good grief, please tell me no!!

Microsoft has also been alienating people who identify things based on icons rather than text. The Live applications team have demonstrated this, for example, by dropping icons completely. In so doing, Microsoft is also alienating the international communities. Sure, text can be translated, but it doesn’t make a particularly great sell when the first impressions of an interface are of gobs and gobs of Engrish text and you don’t speak Engrish. Meanwhile, many of us who do speak English still prefer attractive icons over avant-garde lower-case text headings. When you have five or so menu items in 72 point font size, it’s fine, but when you’re trying to find something among 200 others, nothing beats the simple icon. Throwing away the simple icon on a grid won’t make this reality go away; this is not like a floppy drive, it is actually essential.

WP7’s minimalistic interface could actually end up being its downfall. They’re taking a huge chance and risk. I’m hopeful, but sadly slightly doubtful, that it will be enough to throw Microsoft back into the playing field.

Starting over

Maybe I’m just not getting it. Actually, Microsoft’s new direction has had me scratching my head so much that I’m convinced that I’m still struggling to get it, and that actually all of my concerns are quite intentional for Microsoft’s part.

This video demonstrates this quite well. Microsoft wants to “start over” not just with their SDK but with deemphasizing standalone installed apps and reinforcing the notion of a phone whereby the many apps are not just active but are integrated with each other.

The only problem is, I don’t see such cross-app integration demonstrated in the SDK, at least not up front, not yet. Also, why should I as a developer be excited about this new direction if the apps—my development efforts, and yours—are deemphasized in favor of prefab packaging?

Stoked and confused

Overall, I’m both stoked and confused. This is an exciting time to delve into this new technology from Microsoft. Microsoft really needs to fill in some holes, though, and these holes are less technological than they are design.  Their design and marketplace support strategies seem very vague.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

C# | Windows Phone | Silverlight

Gemli: Do We Need An XPath-to-Object Mapper?

by Jon Davis 14. April 2010 18:11

It dawned on me today that two fundamental problems exist in my day-to-day (and year-to-year) programming activities that haven’t been fairly addressed with all of our innovations in language and tooling improvements, and they are a) the absence of a flexible, late XML-to-object-graph binding mechanism, and b) the absence of an XPath-like query mechanism for CLR object graphs.

Right now I want to focus on a) the absence of a flexible, late XML-to-object graph binding mechanism.

Microsoft.NET inherently supports XML serialization and deserialization of object graphs, but what I’ve found so far is that

  1. the mappings are defined in explicit C# code (with attributes) at compile-time,
  2. class members must be sibling elements or attributes of their parent and cannot be “relational” cousins,
  3. XML trees must have a fixed hierarchy pattern or else manual serialization/deserialization code directly inside the class is required,
  4. in deserialization, serialized content cannot be XmlElement objects, and self-sufficiently XML-serialized objects often cannot be appended as children to other XML trees because of XML/XSD namespace declarations,
  5. extra or missing CLR members, or extra or missing XML members, do not always get handled gracefully when values are mapped at runtime.

Let’s take a look at each of these problems.

The first problem is simple. You add [Serializable] to your objects, and you express how the members align with the XML using [XmlElement], etc. There’s nothing much wrong with this, I don’t mind this, but because of 2) above, it’s pretty inflexible. For one thing, you cannot define BookName’s XML mapping with, say, [XmlElement(“../../Books/Book[@ID={BookId}]/Name”)], where {BookId} maps to the C# sibling member BookId, as a way of saying “map this member to cousin ‘Name’ in that other branch under Books”. The other issue with the first problem is that you cannot late-define a mapping of XML to an object without manual reflection and manual population of data. What if you have a POCO object that was never intended to be serialized?

(I already went over the second problem, as it aligns with the first problem.)

The third problem is that if you have “nephew” nodes that map as siblings, you can accomplish this, but not without manually implementing IXmlSerializable. I went down this path for Gemli.Data 0.3 in order to load up the O/RM mappings from XML, and I must say I am floored by how little confidence I have in my implementation. You’re literally poking at stream data with IXmlSerializable, not working with logical constructs at all, and I find that to be a thoroughly unacceptable way to deal with XML-to-object mapping considering the fact that XML and CLR object graphs are both expressive of their structures and hierarchies. Perhaps I am spoiled by the W3C XML DOM (System.Xml.XmlDocument), which is not used in XML deserialization, and rightly so, I suppose, since object-mappable XML streams can be huge (gigabytes) when expressed from an XML stream. We are left with few options, though, in the IXmlSerializable interface declaration.

The fourth problem goes something like this. Say that you XML-serialized an object, with rich XSL namespace semantics. Then, you created an XmlDocument that contains a bunch of custom XML markup. You cannot simply drop your XML-serialized object into the XmlDocument as a child element because your custom XML declares namespaces in its header. Runtime errors result because either the namespaces of your object are not understood (are not declared) or your object’s XML is declaring the namespaces and being put inside the body of the XML which is invalid. This is a fundamental problem with currently used XML/XSL to begin with, actually, that you cannot have nested namespace declarations inside the XML body, but this may or may not have already been addressed by the W3C with XML/XSL revisions, I don’t know.

On the fifth problem, where missing or extra members are not handled gracefully, this is actually an implementation detail and, truthfully, it’s not normally a problem because XSD and .NET attributes can accomodate (per generated xsd.exe output). However, combined with resolutions to the previously mentioned problems, this is something to keep in mind. Sometimes the problem goes the other way around, actually. Sometimes you need exceptions thrown if, for example, an XML element is missing. XSD and the mapping attributes in .NET define that, too. However, as far as I know there is no way to establish late bindings where such mapping behaviors can be defined at runtime.

Is There A Solution?

Actually, I’m not sure that there is a solution to these problems, or even a set of solutions that work together to address these problems. However, I am pondering on whether or not it would be worth my time to start working on some tooling in Gemli to make Object/XML Mapping easier.

The scenario that had me pondering such tooling goes something like this. Suppose you have an XML node with hierarchy described in XML that maps to an object graph, and you aren’t sure exactly just yet how the XML hierarchy or naming convention is going to flow, i.e. whether it will be a child of this element or a child of that element or if it will be at the root of the document. Let’s say that you want to express, in a hand-crafted, initially XSL-less XML structure, some kind of definition of an object graph and the values of the members therein. Let’s say that you already have some POCO objects that can accomodate the hierarchical structure of such a described XML tree. At this juncture, what tools are available for you to use to perform said mapping? Without going into your POCO code and manually declaring the XML deserialization behaviors, there is no straightforward way of doing this.

Tooling I might work into Gemli, then, might work like this.

First, consider the following XML and POCO sample:

<myBigFatXmlDocument>
	<blah>..</blah>
	<somethingElse>..</somthingElse>
	<aContainerOfSorts>
		<events>
			<event name="Big Spectacular Event">
				<dateTime>01/01/2011 12:01 AM</dateTime>
				<attendees>
					<attendee>
						<name>Bob</name>
						<phone>299-299-2999</phone>
						<rsvp>yes</rsvp>
					</attendee>
					<attendee>
						<name>Phil</name>
						<phone>288-288-2888</phone>
						<rsvp>no</rsvp>
					</attendee>
				</attendees>
			</event>
		</events>
	</aContainerOfSorts>
</myBigFatXmlDocument>
// POCO!

public class PocoEvent
{
	public string Name { get; set; }
	public int AttendeeCount { get; set; }
	public List<string> Attendees { get; set; }
}

By the way, I realize that it seems like a stupid design to have AttendeeCount be something other than a lookup of Attendees.Count, but bear with me here, I’m demonstrating something. Besides, what if you know that you have more attendees than you know the names of from the XML?

Second, I might cobble together a rough mapping document like this (this is NOT at all a proper definition proposal, it’s more of a “pseudo-code XML document” to get the point across):

<?xml version="1.0"?>
<xmlObjectGraphMap>
	<clrTypeMappings>
		<clrType name="MyProject.PocoEvent" xmlElement="event">
			<clrMember name="Name" xpath="@name" />
            <clrMember name="AttendeeCount" xpath="count(.//attendee)" />
			<clrMember name="Attendees" xpath="./attendees/attendee/name" 
				clrType="string" />
		</clrType>
	</clrTypeMappings>
</xmlObjectGraphMap>

Third, the C# code that performs the loading might appear this way:

// get node of first event in the list
var eventXmlNode = myXmlDocument.SelectSingleNode("//events/event[0]"); 

// deserialization setup
var graphDeserializer = new Gemli.Xml.ObjectGraphSerializer<PocoEvent>();
XmlNode graphMap = new XmlDocument();
graphMap.LoadXml(Server.MapPath("~/XmlObjectGraphMap"));
// drill-down; just use the XmlNode I need for the job
graphMap = graphMap.SelectSingleNode("//clrType[@name=\"MyProject.PocoEvent\"]");

// work is done here
PocoEvent objectGraph = graphDeserializer.Deserialize(eventXmlNode, graphMap);

What I have done, assuming that such tooling was implemented, was

  1. declare an XML node that defines the data I want to be loaded into an object graph,
  2. declare an XPath-to-object mapping strategy in ridiculously easy to read semantics, and
  3. load my POCO object graph without any manual declaration of XML serialization behavior outside of that simple XML mapping file.
  4. I also demonstrated, albeit poorly, how I used an XPath function to define an initial value of AttendeeCount, which can be manipulated in isolation from Attendees.Count (just assume this was a requirement).

It’s still not succinct enough. I could have just as well set up the API to take an XPath selection in .Deserialize() so that I wouldn’t have to call .SelectSingleNode(). For that matter, perhaps I could have written this block of code as succinct as this, using a couple do-it-all methods:

PocoEvent objectGraph = new Gemli.Xml.GraphSerializer<PocoEvent>(".\\myObjectGraphMap.xml")
    .Deserialize(".\\myXmlFile.xml", "//events/event[0]");

It could very well be that something in .NET, perhaps even LINQ-to-XML, supports this level of simplicity in the tooling of XML-to-object mapping. But I highly doubt it.

If someone out there reading this knows of some tooling that does this already, let me know. Otherwise, I am likely to get started on this in Gemli.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

PDC '09 Video For Parallel and Asynchronous Programming

by Jon Davis 7. April 2010 23:17

Just wanted to link to this for future reference. Been watching this while trying to test a deadlock from hell (I *HATE* WinDbg!!), thought it was interesting.

http://microsoftpdc.com/Sessions/FT20

It never dawned on me until watching this video that F# with its extensive "automagical" parallel-oriented semantics would a) be a killer toolset for Silverlight and WPF for producing very highly responsive UI, and b) be a brilliantly terse yet readable language (a cross between Python and PowerShell, except only in the good ways) to produce asynchronous code that is much easier to maintain than the C# equivalent.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

F#

Update For The Masses

by Jon Davis 6. April 2010 03:34

Greetings, my minions. I decided to grace upon all of you (all of you being myself?) a short moment of an update of what I have been up to lately, just to be sure that none of you think that I have let recent personal circumstances of the last 12 months wind me up in a wheelchair or bed as a brain-dead vegetable. Actually, nothing much has changed on the personal front.

Here’s what’s exciting these days.

  1. I’m still tinkering with pet projects but have been semi-focused on something I cannot talk about for a while. However, the project does use
  2. I just got an iPad, which I cannot afford and yet here it is. I am now very satisfied that I still have a jailbroken 2G iPhone, as I can do Internet tethering for the iPad without any hassle. My expectations for serious future app offerings are huge. My cats are happy. Werd.
  3. I’m getting extremely excited about Windows Phone 7. This is Microsoft’s great big opportunity to really compete with Apple’s feminine hygiene products and I think they just might even enter the playing field (although I must confess I really don’t like the busy-ness of the demo’d Windows Phone 7 main menu, especially compared to the consistency of iPhone app icons; I voted for the Zune interface because it was clean and uncluttered). I am particularly intrigued by Microsoft’s boldness in giving only Silverlight or XNA as API platforms for the Mobile 7 platforms. Hmmmm C# and Silverlight/XNA versus Obj-C and Cocoa Touch, hmmm, I wonder which one is going to be more ideal for developers? Duhrrrr…
  4. This is a great time to be a PC gamer!
    • Most recently, I finally got around to loading up Company of Heroes, which I bought three years or so ago in the inspiration of a [then] boss who had bought Command & Conquer “to play with friends”, and nobody but me wanted to play that. I borrowed the game but lost interest, so I bought CoH. Sadly, I got stuck on CoH in the second or third mission, it didn’t “click” how the game was supposed to be won, and I kept losing, so I gave up and the game sat there for a couple years. But a month or two ago I finally managed to get in there, and rinse, repeat, rinse, repeat, like a madman until I beat that level. From there, the game just “clicked” and I understood why this game was so awesome. Loved it!
    • A few months ago I also bought and beat Dragon Age: Origins. Excellent game, I must say! Very immersive offering from Bioware.
    • Another Bioware hit that I bought and beat was Mass Effect 2. It disappointed me a little, but it was still one of those “ZOMG I HAVE TO FINISH THIS” games.
    • Batman: Arkham Asylum turned out to be an outstanding, beautifully designed game. I was never much of a Batman fan, but this is a just plain drool-worthy game. It is also the first game that I’ve seen make obnoxiously verbose mention of support for 3D gaming. I had recently purchased some red/blue film glasses for situations like this, now that the nVidia GeForce chipsets and drivers natively support 3D, so I turned it on, and wow! Stomping through the Arkham Asylum halls really felt like being there. I now have a great deal of appreciation, though, of the “real deal”, the true 120+Hz monitors with which you can buy 60Hz synchronized shutter glasses where the content is different in each eye without color distortion. The red and blue thing is really uncomfortable.
    • I never did play Call of Duty: Modern Warfare 2, which I did buy, because I still haven’t finished Call of Duty 4: Modern Warfare, which is truly great game (one of the best action games of all time) but it’s just too hard for me. However, I did buy and beat Battlefield: Bad Company 2... Oh. My. Word. This game is absolutely incredible. It is by far the best multiplayer shooter I have ever played. And if the single player game wasn’t so short, it would be truly monumentally awesome, up there on par with the Half-Life series of the action genre. Sadly, it is indeed short, and when you see the credits rolling, you’re more irked than satisfied.
    • I got the lifetime subscription of Star Trek Online. It was a mistake. She’s dead, Jim. The ratings agree.
    • I’m feeling nostalgic about Homeworld, the best epic story in game form ever (tear-inducing!), and never did finish Homeworld: Cataclysm (too hard!) nor have I played Homeworld 2. They’re old games, but I’ve decided that I want to have completed them. So that’s what I’ve most recently fired up.

Now, my kindred children, return. Go back to your lives that are inspired by my doings, and dream big dreams, yes, big dreams, of being like me. LOL ... cat fur up your noses and all!!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:


 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  September 2018  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar