All posts by Jeremy

Developping an app for the Windows Phone platform

For the last few months my colleague Charlotte and I have been working on a Windows Phone 7 app we hope to release soon. Attendants of our “Performance tuning and analysis during the Microsoft TechDays this week had a brief overview of this app.

In this post, I wanted to share with you all the tools we’re using to build this app.Most of them are free, so they might interest you…

Productivity / Code

Libraries

Source Control

Project Management

  • AgileZen (free for managing 1 single project)

Cloud computing

Web site

I personally love all those tools and libraries ! What do YOU use for your Windows Phone 7 development ?

 

Windows Phone performance analysis & optimization during TechDays

In about 2 weeks now, I’ll have the chance to be part of the French TechDays in Paris as a speaker. This year, I’ll own a session called “Windows Phone performance analysis & optimisation” with my colleague Charlotte.

The agenda looks like the following:

  • why performance analysis ?
  • device vs emulator
  • leveraging WP7 threads
  • using the VS profiler for WP7
  • tips and tricks

During the session we will use a “real” app we’re working on for a few months now (I’ll share more details after the session). We have some cool tips that haven’t been shared anywhere before, so if performance is a topic of interest for you, stat tuned !

Click on the following image for a link to the TechDays website:

I’m planning to share the most of the content of this session on my blog soon after the event.

Don’t hesitate to stop by and say hi…

ReSharper and code generation

I don’t know why I’ve found this feature only today, but I wanted to share another great feature of ReSharper. Let say you need to implement a C# structure. You may start with the following code:

public struct ServerItem
{
    public string Id { get; private set; }
    public DateTime? Added { get; private set; }
    public int ChildCount { get; private set; }
}

Then you start thinking, “I need to setup a constructor…” You can do it manually, but you can also ask ReSharper do to the job for you. All you have to do is press ALT+Enter (this might depend on your configuration obviously…)

ReSharper will generate the constructor for you:

public struct ServerItem
{
    public ServerItem(string id, DateTime? added, int childCount)
        : this()
    {
        this.Id = id;
        this.Added = added;
        this.ChildCount = childCount;
    }

    public string Id { get; private set; }
    public DateTime? Added { get; private set; }
    public int ChildCount { get; private set; }
}

Fine. Then you remember that you also need to setup equality members properly… You have to override Equals, GetHashCode… This is not complicated but it can become cumbersome and it often feels like a waste of time. Here is the ReSharper way of doing this:

1. Press ALT+Enter

2. Choose “Equality members” and setup the code generation:

And BOOOM ! You’re done:

public struct ServerItem
{
    public ServerItem(string id, DateTime? added, int childCount)
        : this()
    {
        this.Id = id;
        this.Added = added;
        this.ChildCount = childCount;
    }

    public string Id { get; private set; }
    public DateTime? Added { get; private set; }
    public int ChildCount { get; private set; }

    public bool Equals(ServerItem other)
    {
        return Equals(other.Id, this.Id) && other.Added.Equals(this.Added) && other.ChildCount == this.ChildCount;
    }

    public override bool Equals(object obj)
    {
        if (ReferenceEquals(null, obj))
        {
            return false;
        }
        if (obj.GetType() != typeof(ServerItem))
        {
            return false;
        }
        return Equals((ServerItem)obj);
    }

    public override int GetHashCode()
    {
        unchecked
        {
            int result = (this.Id != null ? this.Id.GetHashCode() : 0);
            result = (result * 397) ^ (this.Added.HasValue ? this.Added.Value.GetHashCode() : 0);
            result = (result * 397) ^ this.ChildCount;
            return result;
        }
    }

    public static bool operator ==(ServerItem left, ServerItem right)
    {
        return left.Equals(right);
    }

    public static bool operator !=(ServerItem left, ServerItem right)
    {
        return !left.Equals(right);
    }
}

The code-generation features of ReSharper has been there for a long time… But because I just found out the power of them, I wanted to briefly showcased them in this post 🙂