Application Development for Windows 8: Why and How

    imageOver the past 5-7 years, we have all been observing a phenomenon that analysts call consumerization of IT. Without going into the history and details of this phenomenon, which is characteristic not only of the IT industry, it is worth noting the main thing - it is the "consumers" who today create the lion's share of the notorious added value - sometimes with their large numbers, sometimes with the ability and desire to overpay for new items and generally interesting ideas.
    The Windows operating system, which became widespread in the wake of consumerization in the mid-nineties, systematically developed until the mid-zero, when personalization of computing received a new powerful impetus - true mobility and accessibility.

    At the same time, with the filing of Apple, and simply because of the cheaper production of the corresponding screens, the touch interface began to gain immense popularity when the user works with applications using touches and gestures, directly touching the screen with their fingers. Another significant shift, which greatly affected the minds of application developers, was the result of the total mobilization of computing - simplification of applications. No, people didn’t work less with “complex” applications and their performance did not drop. They began to work and play with a computer (in the form of a phone, tablet or laptop) an order of magnitude more often, almost constantly, on the go. People need a much larger number of applications.
    clip_image003 [6]

    clip_image005 [4]But, as a result of the environment and the size of the devices, all these applications became very simple, most often aimed at consuming content or a game. In other words, without reducing the demand for building applications , there is a huge, substantially greater need for applications for consumption .
    Another characteristic feature is the popularity of app stores. This simple idea solved two crucial tasks: for the user - where to get the application, for the developer - where to sell it. For all the simplicity of the idea, for many years the so-called “sales channel” has been a headache for developers of consumer applications. This is just the case when direct instructions on where to buy and where to sell make the path from the developer to the buyer the shortest. And, of course, the simplicity with which individual developers or small teams can place their creations for sale has become an important factor in the success of modern application stores. This, by the way, is one of the few differences between app stores and classic retail.
    Each of us today, working with Visual Studio, AutoCAD, Photoshop, Excel or 1C, performs the same task for the world of software and computer manufacturers as it did 15-20 years ago - it buys “home and bread”. Picking up a smartphone or tablet, you become a buyer of “sneakers and orbits,” that is, goods with either a significantly higher turnover or, and more often “and,” with higher added value. Windows developers, long before the advent of the iPad, began a project to develop a new generation of the flagship operating system, where 3 tasks were solved: 1. Increasing battery life in three ways - general optimization, porting to other architectures (ARM) and, finally, developing rules for developers when the application minimizes consumed resources. 2. Optimization for touch-interface.
    clip_image007 [4]


    3. Creating an ecosystem for the sale and promotion of applications.
    As a result, a new Windows began to crystallize, promising to be the most significant shift in the paradigm of operating systems from Microsoft and, at the same time, the most risky. Since Windows 95, we have not offered such dramatic changes for developers and users. And given the enormous prevalence of Windows, today's changes are the biggest in history.
    At the same time, Windows 8 is the biggest opportunity for developers in history. Indeed, every Windows user has a Windows Store - an application store that is the main (and in some cases the only) application sources for his computer, whether it be a desktop, laptop or tablet. Windows 8 Economy is a good topic for a separate article. Now is the time to move on to application development.
    If you have not already downloaded Windows 8 Release Preview and Visual Studio 2012 RC, now is the time to put them to download. Windows 8 can be downloaded from here , and Visual Studio 2012 RC is available here . For development under Windows 8, you need Windows 8 itself.

    What is Metro?


    The main changes for the user and developer in Windows 8 can be described in one word - METRO. This term includes two new concepts: Windows Runtime (WinRT) and Metro UI.
    Saying “metro-applications”, we mean not only a new interface, but also a new development platform. It is important.
    What is a metro style app? In short, this is a fusion of a new interface paradigm, a new effective API and an appropriate development platform, plus integration with the system and other applications.

    Applications have one window with support for multiple views


    Unlike classic applications, Metro-style applications contain one window without chrome, which by default occupies the entire screen so that the user is not distracted by unnecessary details. A Metro style application can support a variety of layouts and views to provide dynamic and convenient user experience with a variety of design parameters and device screen sizes.
    clip_image008 [4]

    clip_image009 [4]

    Do apps let you use touch? pen, keyboard, and mouse input


    Metro style apps work seamlessly with a variety of input sources, including a pen, mouse, keyboard, and touch input. For all of these input sources, you can use a single set of events. Metro style apps include a default set of styles to ensure that the touch-sensitive user interface elements work properly.
    clip_image003 [7]

    Applications can interact with each other.


    Application contracts are an opportunity for users to easily search across multiple applications and share content between them. They expand the practical usefulness of your application, eliminating the need to interact with various API standards for specific applications when you need to access data stored in another application or created by it. At the same time, the user remains in your company environment. You do not need to know anything about the target application other than the declared support for the target contract, it just works.

    New controls and interface areas available in applications


    Metro-style applications contain several new controls that make it easy to organize effective user interactions. Among these elements, you can highlight the command bar (App Bar) of the application and charms (Charms).

    Application Command Line (App Bar)

    The application command line is located outside the application window and is its main command interface. Use the command line to place navigation items, commands, and tools for users. By default, the application command line is hidden and appears when the user swipes a finger in the direction from the top or bottom edge of the screen. It is a cover for the contents of the application and can be hidden by the user if he swipes his finger along the edge of the screen or interacts with the application.
    clip_image010 [4]

    Charms

    Charms are a defined and consistent set of buttons used in all applications to search, send, connect, configure and launch. We believe that these are the main working scenarios that all users want to execute in almost every application they use. Users can:
    • Search for content hosted in your or another application. In addition, content search in your application is possible from another application.
    • Share content from your application with contacts or services.
    • Go directly to the Home screen .
    • Connect to devices and send content, stream media, and print documents.
    • Use the settings to configure the application as you wish.

    clip_image011 [4]

    Applications use tiles instead of icons (Tiles vs. Icons)

    When the user installs your application, it appears on the initial screen as a tile. If you touch or click a tile, the application will start. An application can provide content using a tile, even when it’s not working. Using dynamic tiles ( Live Tiles) , the application is able to display useful data in a concise form with minimal battery consumption. An application can configure the system to periodically request updates to a web service, regardless of whether it works. In addition, Windows Push Notification Services (WNS) settings are available in applications to send messages directly from a web service to a dynamic tile.
    clip_image012 [4]


    clip_image013 [4]

    Writing applications in a language familiar to the developer

    You can create Metro-style applications in languages ​​that you know best, such as JavaScript, C #, Visual Basic, or C ++. Moreover, you can create components in one language and use them in an application written in another programming language.

    Selling apps through the Windows Store

    The main source of Metro style apps is the Windows Store. You create an application, specify the price, and the Windows Store will offer your application in the world market in more than 100 languages.
    clip_image014 [4]

    Winrt


    Until recently, Windows developers used two main groups of APIs: native through the Win32 API and managed through the .NET Framework. At the same time, the second group gradually developed, receiving various models for creating a user interface, working with data and services, building source code and application architecture, and so on.
    Meanwhile, Windows itself - that is, the Win32 API received not so many real impetus to the development of a basic development model. Perhaps the last significant phenomenon was COM. All these years, the computers themselves did not stand still. There were all kinds of sensors, network devices (including 3G / LTE, etc.), cameras, touch-sensitive screens. Finally, power consumption has become increasingly important.
    Thus, creating a new Windows, we realized that it was necessary to develop a new API, which, being native for the operating system, would meet some minimum requirements and trends of the times. As a result, Windows Runtime (WinRT) was born.
    What WinRT brings with it:
    1. This is a native API that works together with an optimized COM API. At the same time, managed environments can work on top of WinRT (and the .NET Framework in Windows 8 is an example).
    2. This is an object-oriented API that includes a generic type metadata format.
    3. WinRT includes support for many of the modern properties of personal computers (sensors, cameras, etc.). and energy conservation is extremely important here.
    4. This is a language-independent API that natively supports various models:
    a. C ++
    b. .NET Framework with C # and Visual Basic
    c. HTML5 and JavaScript
    5. The modern declarative model for developing interfaces in XAML or HTML5 has become part of the Windows API, and not an add-on on it.
    As a result, Windows applications were divided into 2 groups:
    1. Classic desktop applications.
    2. New metro applications. WinRT itself, in addition to the functional proper, which is responsible for the performance of certain functions, received a number of important components. These components are: 1. The subsystem of metadata and language projections. Thanks to it, components written in different programming languages ​​can call each other. 2. Brokers. These components carry two important functions:
    clip_image016 [4]

    clip_image018 [4]




    a. Support for data exchange between applications. For example, in cases where you want to send data from an application through an email client.
    b. Protecting some important calls through capabilities and explicit permissions. For example, if an application wants to use the camera, the system will first ask the user if he allows it. Similarly, for example, with GPS, the application should indicate such a need at the development stage, plus the user can explicitly allow or deny him the use of location information.
    There are also two other important parts of the Windows API that are available and used by metro applications:
    1. Application Model and the Windows Store API.
    This group manages the important components of the application:
    a. The composition of the components.
    b. Capabilities affecting the security and functioning of the system, such as access to location, file system, network, user identification, all kinds of integration points with the system, and so on.
    c. Interaction with the Windows Store and information about the application, which, as we already know, in the vast majority of cases, will be installed from there.
    2. DirectX and a subset of Win32 and COM API available for components and applications developed in C ++.
    They are necessary on the one hand for developers of games and multimedia applications (DirectX), on the other hand, for porting existing code (a subset of Win32).

    Application Execution Model in WinRT


    Separately, it is necessary to dwell on the execution model or, as you can say, the life of the application in Windows 8 and WinRT.
    The life cycle of a metro application is significantly different from that for classic applications. It can be divided into three groups:
    1. Installation.
    2. Execution.
    3. Removal.
    With the first and third, everything is more or less clear, although the Windows Store provides additional opportunities here. But the execution cycle itself requires special attention.
    The execution stages of an application are precisely described by the ApplicationExecutionState enumeration .
    clip_image019 [4]
    Simply put, if the user is not working right now with your application, the application itself does not work either. It either sleeps (suspended) or is completely unloaded. Read more about this in the Application lifecycle article .
    However, you should not think that in WinRT it is impossible to execute background processes. Two great documents very well describe the approaches and rules for developing background processes.
    Introduction to Background Tasks
    This paper describes the programming model to create background tasks, resource management policies for background tasks, and built-in user controls that allow the user to control per-app background task activity by using lock screen personalization.
    Background networking
    This paper provides information about an app lifecycle management model for apps that require real-time connectivity between the client and server. To address the lifecycle limitations for real-time connected apps, Windows 8 introduces a new set of APIs that enable users to build always-reachable apps.

    File System and Application Data in WinRT


    Another feature of WinRT is the procedure for working with files and data. To begin with, it should be said that in the general case, the data of metro applications are isolated from each other. This ensures the stability and security of both the applications themselves and the system as a whole.
    You can read more about these applications here , but the bottom line is that every metro application has three types of file storage:
    1. Local.
    2. Temporarily.
    3. Portable (roaming).
    The first type, as the name implies, contains files and folders that the application creates on the local computer in a special area allocated to this application.
    The second type is very similar to the first with the exception that as soon as the application is unloaded, the system can delete such temporary data at any time.
    The third type of storage is roaming, which is files and folders synchronized between all devices with Windows 8, where the same user who originally created the data in your application is registered. The user is identified by the Microsoft ID, which everyone also knows as LiveID.

    File System and Permissions

    All this does not mean that the application cannot access the files located on the rest of the disk space of the device. There are two mechanisms for this: File Pickers and Libraries .
    The first mechanism allows you to access files through a user request to select such files. He explicitly selects them, thus giving access to these files to your application.
    The second mechanism gives direct access to Windows document library files : Documents, Pictures, Videos, etc. This approach requires two conditions:
    1. Declarationthe fact that you want to access the libraries. The declaration is made at the stage of application development. When installing it from the Windows Store, the user sees which libraries the application will have access to.
    2. For some types of libraries (Documents and files on external devices), it is necessary to determine the association of the application with the file types . And it is precisely these types of files that it will gain access to.
    Read more about all this here .

    Application manifest and capabilities


    Above in the text, capabilities have been repeatedly mentioned in the context of the declaration by the application of some actions that it plans to perform in the system.
    Indeed, the application package scheme is important in itself, and the manifest file as part of it says a lot about the functionality of the program.
    Read more about this here . Also watch and listen to this BUILD conference session .

    Further steps


    This article provides an overview of the main ideas of Windows 8:
    · Why it was created just like that
    · What is Metro and Windows Runtime (WinRT)
    · What are the features of the functioning of applications in WinRT
    Now it's time to run Visual Studio 2012 in an already installed Windows 8 and try to write your first attachment.
    To do this, there is an excellent step-by-step guide " Developing Metro-style applications using Visual Studio 2012 RC ." It is very important to plan the application correctly - its interface, organization chart, integration capabilities with the system, etc. The Metro Style Application Planning Guide will help you .
    clip_image020 [4]


    useful links



    Also popular now: