Yavor Georgiev

Yavor is a PM at Snowflake working on developer experience. Previously at Docker, Auth0, Hulu, and Microsoft Azure.

Building portable C# apps with Mobile Services

20 July 2013

I don’t want to be one of those people who’s always going on about their ViewModel, but I was pretty pleased with the way I was able to factor the sample from my Build talk, so I thought I would share. My goal was to structure my Windows Phone 8 code in a way so I could reuse as much of it as possible if I decided to build a Windows Phone 7.5 or Windows Store version of the app.

I mostly followed standard MVVM best practices here, and I assume most of you are familiar with those. I leaned on MvvmLight as my framework of choice. The strategy here was to try to make all ViewModel and Model code easily portable. This was a natural fit with the Portable Class Library (PCL) support introduced in VS 2012. This is the high-level project structure I devised:

A lot of the app chrome is deeply platform-specific, so I needed platform-specific projects for those pieces: MyApp.Win8 and MyAppWP8. The key was to separate the ViewModel and Model code, which can be made portable via their own PCL projects: MyApp.ViewModel and MyApp.Model. These projects can be referenced from a variety of C# platforms (.NET, Silverlight, Phone, Windows, even Xbox) without any modification, that’s the beauty of this model.

There is one caveat with a PCL project: the way it works is by exposing a sort of lowest-common-denominator .NET surface area that is guaranteed to work across all the different platforms where that library is supposed to work. Clearly, the further back you go by adding more and more legacy platforms to the supported set, the .NET surface area your project can target shrinks. So you have to make a mindful choice given your business need, luckily VS makes that choice very easy for you. Here is what I picked for my PCL projects:

image

Let’s talk about the two PCL projects in a little bit more detail.

The ViewModel project

This part is not specific to Mobile Services in any way, and has been covered well already by other folks. The key thing to realize is that the ViewModel code needs to depend on the MvvmLight framework. So someone needed to design a subset of MvvmLight that can be referenced from a PCL project. Luckily Laurent has already done the hard work here, so just reference the Portable.MvvmLightLibs project from NuGet, and you’re done.

The Model project

This was the slightly more interesting part, since this is the project that needs to talk to Mobile Services and load/save data for my application. Other than my model classes, which are pretty straightforward, I designed a few service interfaces that my ViewModel code could use to talk to Mobile Services. Here are those interfaces:

~~~ csharp public interface IChatService { Task CreateUserAsync(User user);

Read More

Build 2013 talk: Connected Windows Phone apps made easy

01 July 2013

Thanks to everyone who attended my talk at Build 2013. Here are the slides and video recording from the talk. The demo can be found here.


Read More

NDC 2013 talk: Leave the backend up to us

01 July 2013

Thanks to all the folks who joined me for my Mobile Services talk in Oslo. Here are the slides and a link to my demo.

Here is the video from the presentation so you can follow along.

Yavor Georgiev: Leave the backend to us: building mobile apps with Azure Mobile Services from NDCOslo on Vimeo.

Read More

DevIntersection talk: web apps with Mobile Services

12 April 2013

Thanks to the folks who attended my talk at Devintersection last week in Las Vegas. Here are my slides:

You can find the code sample here

Read More

A problematic heritage

31 March 2013

What was going to be a simple link I wanted to share (via Aatish) got me thinking about the legacy of “problematic” monuments across the Balkans. Regardless of what they symbolize, most of these have fallen into disrepair due to the fall of the regimes that erected them in the first place.

The original post here shared a series of “spomenik” monuments built throughout former Yugoslavia. Here is a great essay by John Bailey that puts these in context.

Read More

Episode III: Exploring the richness of the Mobile Services Android client query model

28 March 2013

In today’s post we continue our Android blog series for Mobile Services. Here are the other posts in the series.

Today we will talk about the query model in the Android client. In our C# client we were lucky to be able to lean on LINQ, but after some research we found that there is no out-of-the-box equivalent in the Android platform. I’m glad to stand corrected here: please let me know in the comments if we missed something.

Given that, we decided to implement our own fluent query API that supports the same richness that you get with LINQ, so it deserves a thorough writeup. We’ll assume we’re working with our same reference type we used in our last tutorial, but we’ve added a field or two to make things more interesting to query against:

~~~ java public class Droid {

@com.google.gson.annotations.SerializedName("id")
private Integer mId;
@com.google.gson.annotations.SerializedName("name")    
private String mName;
@com.google.gson.annotations.SerializedName("weight")    
private Float mWeight;
@com.google.gson.annotations.SerializedName("numberOfLegs")	
private Integer mNumberOfLegs;
@com.google.gson.annotations.SerializedName("numberOfWheels")	
private Integer mNumberOfWheels;
@com.google.gson.annotations.SerializedName("manufactureDate")	
private Date mManufactureDate;
@com.google.gson.annotations.SerializedName("canTalk")	
private Boolean mCanTalk;

public Integer getId() { return mId; }
public final void setId(Integer id) { mId = id; }

public String getName() { return mName; }
public final void setName(String name) { mName = name; }

public Float getWeight() { return mWeight; }
public final void setWeight(Float weight) { mWeight = weight; }

public Integer getNumberOfLegs () { return mNumberOfLegs; }
public final void setNumberOfLegs(Integer numberOfLegs) { 
    mNumberOfLegs = numberOfLegs; 
    }

public Integer getNumberOfWheels() { return mNumberOfWheels; }
public final void setNumberOfWheels(Integer numberOfWheels) { 
    mNumberOfWheels = numberOfWheels; 
    }

Read More