#TWalk #WangQiu: Progressive Enhancement Applied in Mobile Development
At the Baidu Developer Conference Xi'an in June 2012, Qiu Wang (@Sheldon-Qiu ), a front-end engineer from ThoughtWorks, gave a talk titled "Progressive Enhancement in Mobile Web Development". Later in the OpenSpace session, he also served as a topic panel leader for a discussion with attendees, and the author interviewed him about progressive enhancement, details of which are below.
InfoQ: Please tell us briefly about yourself and the work you currently do?
Qiu Wang: Hi everyone, I'm Qiu Wang, a front-end engineer at ThoughtWorks, a JavaScript language enthusiast, usually like to study technology to find breakthroughs, good at sharing experience. Recently been focusing on testing techniques for front-end development. Currently the development work involves some WebApp work, the platform used by the customer is mostly iOS Safari browser, in order to better solve the compatibility problem, we started to use the development idea of Progressive Enhancement (Progressive Enhancement), and gradually have a deeper understanding of it.
InfoQ: What is the core of PE and talk about your understanding of progressive enhancement?
Qiu Wang: PE is a development idea where content is the core and on top of that we add styles and scripts to make it look and behave. I think that for the user, BA, UX, content can be the content and functionality that the site brings to the user who visits, specifically the text in the site, but also the interactive features that the site brings to the user, such as sending emails, filling out forms, and maybe even the visuals, color scheme, typography, reading experience, etc. that it brings to the user. But, for us developers, the core content of PE is our HTML code, the clean and easy to understand markup guys. HTML is the basis for the Web to deliver content, for developers to make pages functional, and for almost all browsers to render pages functional, and for developers to add CSS styles and JavaScript code to make content work better on better browsers and enhance the user experience. The development of television is a good example of this. The TV sets in the house were changed from black and white in the early 90's to CRT color TVs around 00, and as technology has evolved, to now having LED HD TVs and even 3D TVs. For users, TV sets bring them TV shows, and after watching CCTV for so many years, advanced TV sets bring users a new viewing experience, bringing not only color, but also HD picture quality and a rich viewing experience. On the flip side, the same content TV shows can be broadcast on older TV sets and the content is just as accessible to users, it's all backwards compatible and therein lies the benefit that PE brings to the table. The development of browsers, from Netscape to the current Chrome is a similar process of development, from browsers that do not support image display, only simple text and links, to support images and grid layout, to the current WebGL graphics technology, gradually provide a better experience to the user. Our websites should give users the same experience as possible, not the exact same. You also can't expect a Kindle's silk browser to perform as well as Chrome. We need to take a fresh look at solving the problem of browser compatibility. Our development needs to shift from compatibility-oriented development to usability-oriented development, meaning that the functionality brought to the user by the website is cross-browser from the beginning, which is a different point of concern from elegant degradation.
InfoQ: From a current perspective, what progress has PE made and what are the main problems encountered?
Qiu Wang: Web technology is changing rapidly, due to the differences in browsers and platforms, PE development has become more complex, from the beginning of the three-layer structure to the current multi-layer structure, we can use CSS directly for enhancement, or JavaScript for enhancement, but also mixed together for enhancement, in addition to the dependencies between enhancements. For example, JavaScript support has an enhancement, and WebGL support has another enhancement attached, the latter dependent on the former. Although the model of PE becomes complex, we should control the complexity of the program by designing to control the layers of enhancements and the number of enhancements in each layer.
InfoQ: Please talk about what are the main concerns in mobile development?
Qiu Wang: I think the process of mobile web development and desktop web development is the same, so there is no need to deliberately separate them. The main points to note when developing web applications using the PE approach are the following components.
InfoQ: How do you do PE testing?
Qiu Wang: The testing of PE can be boiled down to one phrase, which is to test individual enhancements based on ensuring that the most basic functions are sound. This way we can ensure that we can provide users with a fully working version of the script, whether they are on a slow network, or accessing the site with a browser that does not support enhancements, or even if they disable the script for security reasons. To achieve this, we can start with these points.
InfoQ: As incremental enhancements are developed, the experience can even form a chain from bottom to top, so what should be done with all the enhancements built on top of it if the bottom layer of content changes?
Qiu Wang: This situation is one of the worse ones; whenever development encounters a change in the underlying program, it tends to lead to extensive changes and is inevitable. Our concern should be what we need to modify and the quality assurance of the modification. We develop each enhancement through object-oriented development, all enhancement points are managed, and when the underlying code is modified, it is easy to analyze which enhancements need to be changed, plus automated PE testing ensures that our changes do not affect the functionality before and after the enhancement. In PE development, the number of layers of this chain structure and the number of enhancements per layer should be controlled, as the complexity of testing will increase exponentially with each extension of an enhancement. As of yet, PE development is not as complex as this.
InfoQ: How do you choose the right enhancement during the enhancement process?
Wang Qiu: Web development has a principle that prioritizes the use of CSS to solve problems before considering JavaScript solutions. In PE development, it becomes especially important to be modular in order to have styles and scripts that are dynamically loaded on, and also to use a Library like Modernizr to help with development. If the enhancement is more complex and involves a lot of View manipulation, then some front-end templating techniques can also be used.
InfoQ: Since the features are incrementally enhanced, there are more points to cover for testing, and the enhanced part may be good but not necessarily good before the enhancement, even if no one used the version before the enhancement. Is all this extra effort worth doing?
Qiu Wang: I think it's worth doing, the benefits of PE on cross-platform are obvious to us because we don't pursue it so deliberately, the compatibility issues are solved at the moment we start development. Also, PE being content-focused allows us to always keep our focus on the content we should be providing to our users, because content is where the business is top of mind and generates value. Using the payment feature as an example, if the site doesn't provide the most basic version of HTML for users to complete the payment, losing even just 5% of users over the course of a year is a huge loss. Also, PE development in terms of usability, we even need to consider whether the content of the site works in the reader, whether it displays well enough in print mode, etc. I guess that's one aspect of the quest for excellence in software. For development, PE also brings robustness and expansiveness to our programs, making our front-end code more manageable and compatibility testing more comprehensive.
InfoQ: During your discussions with developers at the Baidu Developer Conference, what topics were the developers more concerned about?
Qiu Wang: I'm very happy to talk to the developers on site. The main topics mentioned are about dynamic loading CSS and JavaScript in progressive enhancement, about how to choose between WebApp and NativeApp, and talking about web development trends, such as games, 3D development. Some developers are also interested in hiring for the front end of our company. The whole process was fun and I learned a lot from interacting with them.
InfoQ: Are there resources recommended for learning (articles, projects or books, etc.)?
Qiu Wang: Here you can recommend a book on Progressive Enhancement, Designing with Progressive Enhancement, also, you can find many articles on Progressive Enhancement on http://www.alistapart.com/. For development, check out the official websites of Modernizr and jQuery Mobile to see how to use them. Also, there will be articles related to progressive enhancement in my blog, so feel free to subscribe.