Elephants Love Mango, Part 1/2: A Backstage Look at Evernote for Windows Phone 7

    Posted by Damian Meyers, creator of the Evernote client for WP7

    image

    Introduction


    A year ago, I worked in the IT department of a large retail company, managing a team of 11 people. In general, from my teens I was involved in software development, but I always wanted to try myself in a managerial position. I sold my two first startups before they turned into growing companies, so the lack of management experience remained my weak point to work on.
    Then the opposite situation arose. I liked the leadership work, it was quite capable of me, but I also felt the need for programming so as not to lose my skills.

    As a result, in my free time I wrote an Evernote client for Windows Mobile 6.5. It implemented a number of features that were not available in the official application, such as offline notes. And as soon as I finished work on it, Microsoft announced the reloading of its strategy in the mobile market and the release of Windows Phone 7 (WP7).

    At that time, I was beginning to understand that management was not for me and began to think about a new startup when Phil Libin, CEO of Evernote called me and asked if I would like to join Evernote and create a service client for WP7. It was very on time - of course, I agreed. And recently, we introduced the first version of the client for this platform.

    This is a story about what was implemented and what was not, what makes WP7 an excellent development platform, and what difficulties there are. I will also try to consider the possibilities that will open with the release of the next version of WP7, codenamed Mango.


    Decent development platform



    Old roots

    By choosing .NET and Silverlight as the basis for WP7, Microsoft immediately made the platform attractive to a large community of existing developers for .NET.

    Despite the fact that I had little experience working with Silverlight, I had been developing in C # for many years, and now there was an opportunity to apply the newly acquired skills then. If you already had development experience using technologies such as Language Integrated Query ( LINQ ), lambdas, and garbage collection, it will be difficult for you to abandon them later.

    Silverlight has existed for several years, and although the technology has not become popular on the Internet, it is quite in demand in intranet development for corporate environments.
    Silverlight and the Model View ViewModel ( MVVM ) development pattern are used together. You declare that your user interface will be processed as an XML language called XAML , which is declaratively bound to your ViewModel code. This means that you can test your ViewModel code separately, without having to use the user interface. Silverlight also got a fantastically convenient animation and visual control system.

    Superior Toolkit


    WP7 developers are pampered. Not only because we have a powerful mature and functional IDE in Visual Studio with such excellent plugins as Resharper, but also because we have a fast emulator, as well as a full-fledged separate design utility in Expression Blend.

    The emulator really works like a full-fledged virtual machine, using the capabilities of hardware virtualization on your computer. The plus is that it provides high performance, but at the same time, you will not be able to develop inside the virtual machine, since the emulator will simply not start in it.

    Blend allows you to design, develop animations and customize the user interface of the application. Although it was originally developed as a paid hi-end tool for designers, it caused a storm of emotions on the part of developers, so Microsoft made it free for WP7 developers. It’s easy and convenient to work with, since Blend allows you to focus on the appearance and interactions of your interface and engage in storyboard and animation without worrying about code.

    Community


    Community
    The presence of a strong community around WP7 development cannot be called something unique, however, perhaps, due to the youth of the platform, high activity is felt in the community.

    In addition to the usual places, such as Stack Overflow and Microsoft’s own forum , there are sites such as Windows Phone Geek that provide a constant influx of quality tips and tricks, as well as articles on this topic.

    Components
    Since the platform is still new, people are posting new frameworks in various places, but you can see that people are starting to gather around WP7Contrib .

    In the Evernote client for WP7, I used:
    1. Microsoft WP7 Toolkit
    2. MVVM Light Toolkit by Laurent Bunion
    3. Sequen Wildermouth's FadingMessage component from PhoneyTools
    4. Fluid List Animation by Colin Eberhardt with minor modifications .


    Some difficulties


    Lack of database

    Everyone has probably already heard about interviews on Google when they ask you to tell us in detail about the implementation of various hashing and sorting algorithms that you will never use in practice.

    Welcome to a world where this knowledge can come in handy. There is no database technology available to developers in the first release of WP7. All that is is an isolated storage and the ability to search files.

    The function of storing notebooks offline, coupled with the ability to find thousands of notes in the client, makes the lack of a database a sensitive hindrance. A note is in the same notebook and may have zero or more labels associated with it. You can view notes by notebooks or tags, and the list of notes can be sorted by a variety of parameters, including headings, date and geolocation. In general, a database would be very helpful.

    Several people became concerned about this gap and proposed database technologies of various levels of complexity and completeness. I spent several weeks at the end of 2010 and the beginning of 2011 trying them, and I did not find one that would satisfy all my requirements. In the end, I decided that it was easier for me to make my bike, and created my own simple mechanism.

    Platform errors

    It is usually rather presumptuous to think that you have found a bug in the platform - it is much more likely that the problem is in your own code. However, in the first release of a new platform, such as Windows Phone 7, sometimes the fault really lies with her.

    For example, you cannot set the focus on any control on your page after the focus has received the browser component. Or how do you crashes when you try to restore the selection of the third list item in pivot? Or unexpected error messages in your logs? All these things that I came across turned out to be WP7 problems, quite explainable by the platform’s youth. Just be more or less prepared for the fact that not only your code may be the cause of the problem.

    There are also some functions that you expected to find there, but they simply do not exist - for example, although you can download the data stream from the site, you do not have the inverse possibility of directing the stream to the site. This means that if you want to send data to the site, all the information in the sending process must be in memory. This is a problem when you upload very large files.

    And finally, the platform itself requires the launch of various functions in the UI stream in unexpected situations, such as access to IsolatedStorage or a network connection (even if it is initiated without the participation of the UI stream and, of course, does not use the WebClient class), which can affect performance .

    Smooth scrolling

    Given the platform’s emphasis on providing a fast, responsive interface, it was unpleasantly surprising how difficult it is to implement truly smooth scrolling when you have a lot of elements in the list, including those with images and possible dynamic loading. Oh yes, I mentioned that there could be thousands of such items in the list?

    I used the built-in ListBox. It provides user interface virtualization through VirtualizingStackPanel, which means that interface objects will be initialized only for visible elements. It also allows data virtualization: if the list to which the ListBox is attached implements IList, then it simply queries the list of elements that are currently needed, that is, you can dynamically load elements from the data source as necessary.

    Despite these advantages, I brought in the LongListSelector from the WP7 Toolkit. It has some interesting features, such as grouping and anchors, that tell you when a data list is used and when it is not. It provides user interface virtualization, but it lacks data virtualization - the first thing it does is go through each element in the list to which it is bound ...

    There are many articles and techniques for creating smooth scrolling. This is loading data from background threads, and pausing the download while scrolling. But still, it’s quite difficult to do everything right when you have many elements, and not all of them are in memory.

    In the next version of the client for WP7, I decided to return to using ListBox because of the advantages of a special approach to working with IList elements, where list elements are only requested when it is really difficult to do without them.

    Continuation

    Also popular now: