The premise of combining designers and developers to create a better experience is not new, but it has also never been an efficient collaboration. In Microsoft’s new user interface platform Windows Presentation Foundation (WPF)1, an emphasis has been placed on the collaboration between these two roles, creating a revolutionary way to create software. Evidence of this claim can be found in both analyst reports2 and in solutions being brought to market3 today.
What has Microsoft done differently? 4
This paper is the result of both research and firsthand experience by the authors. The research was conducted with a number of agencies currently working with WPF, and their insights are peppered throughout the paper. Additionally, the Expression product teams themselves were interviewed, not only because of their extensive knowledge of the platform and tools, but because the Expression products themselves were built using WPF. There is significant density to the paper, not all of which is relevant to every audience. The paper has multiple agendas and serves multiple purposes. The best way to navigate through the paper is to pick a path based on what you seek.
The section “The XAML Revolution” is geared toward those new to the platform who want to understand the underpinnings that make the new iteration possible. It is more technology focused and delves into the reasons that XAML enables a new kind of developer/designer collaboration.
The next two sections, focused on roles and tools, provide a bird’s-eye view on the workflow as a whole and are perfect for people who are overseeing and coordinating a project. They are also appropriate for designers and developers themselves, because the sections talk about how their day-to-day job may change when using this new platform and tools.
The final two sections are oriented specifically toward designers and developers; they contain tactical tips and tricks for those venturing into the platform. These sections may be of less interest to audiences other than the rank-and-file members on the production line. Microsoft’s Silverlight, a cross-platform plug-in for creating rich interactive Web experiences, also uses XAML. Many of the tools that are discussed in this paper generate XAML that can be used in a Silverlight application. Despite the significant overlap, this paper does not address Silverlight for several reasons. First, although Silverlight 1.0 has been officially released, many of the associated tools for creating Silverlight projects are still in alpha and beta states. Second, this paper focuses on creating rich interactive applications for the desktop; Web applications are different enough that they warrant separate treatment in a future paper. The key to realizing frictionless developer/designer collaboration in WPF applications is XAML. However, XAML alone does not engender this new collaboration; it is the underlying WPF platform, manifested through XAML, which allows for the efficiencies to be realized. As such, it is critically important to understand how XAML works, how WPF is manifested in XAML, and some of the architecture of the system as a whole. Unpacking the questions “Why use a markup language?” and “What differentiates XAML from other markup languages?” leads to interesting insights and deeper understanding of the possibilities inherent in the platform. There are several markup languages for expressing user interfaces today: HTML, XUL, SVG, WordML, and more5. These languages, especially HTML, are the evidence of the success of using markup for displaying user interfaces. XML-based markup languages are well-suited to represent hierarchies and parent/child/sibling relationships that appear in a user interface.
A key to the success of markup syntax is the ability to be at once human readable and machine readable. This is an important point to call out because it speaks to the approachability of markup, especially compared to the learning curve that comes with procedural programming languages. There are many people with no experience writing software who are not intimidated by the syntax of HTML, for example. However, being able to understand the actual markup itself is an option and not a necessity. Tools are essential to generating markup syntax; in the case of HTML, the proliferation of HTML WYSIWYG editors has been key to its success.
XAML too is at once human readable and machine readable, allowing one to easily toggle between a tool and a text editor, a benefit that should not be underestimated. XAML not only provides much of the functionality of existing markup languages but adds new features and capabilities not available in other technologies. XAML excels in three key areas: expressivity, comprehensiveness, and extensibility.
<html xmlns=“http://www.w3.org/1999/xhtml” > <body> <input type=“button” value=“Click Me” /> </body> </html> |
|
<Page xmlns=“http://schemas.microsoft.com/winfx/2006/xaml/presentation”> <Button Width=“100” Height=“50” Content=“Click Me” /> </Page> |
A page with a button. HTML syntax on the top row, XAML syntax on the bottom.
XAML can represent more than controls, text and layout. It also has an entire syntax for representing lower-level vector graphics for describing shapes, paths, gradients, and more. The lower-level representations have a similar syntax to existing vector-based languages, providing easy migration from other vector-based languages.
<rect x="1" y="1" width="398" height="398" fill="none" /> <path d-"M 100 100 L 200 100 L 200 300 z" fill="#A3A993" stroke="A8806C" stroke-width="3" /> |
|
<Canvas xmlns=“http://schemas.microsoft.com/winfx/2006/xaml/presentation” Width=“398” Height=“398”> <Path Data="M100, 100L200,100 200, 300z" Fill="#A3A993" Stroke="#A8806C" StrokeThickness="3" /> </Canvas> |
Vector based representation of a triangle. SVG syntax on the left, XAML syntax on the right.
This expressivity goes beyond the representation of 2-D vector graphics to the arena of 3-D. XAML natively can represent 3-D scenes including cameras, lighting, matrix transforms, and meshes.
“XAML rocks because designers can work in tandem with developers. Most of the time I work with my own separate Blend projects, but there is also a constant weaving between myself and the developers. It’s almost like we are playing tennis, volleying projects back and forth. With each exchange we both learn a little more about the tool and each others’ perspectives. In result, this benefits the project and the end user.” Kalani Kordus, Designer, Yahoo
“Because XAML dissolves the barrier between designers and developers we are no longer forced to work with a hard design freeze. Instead it’s more a ‘design slush’. This means as long as the basic visual language is there, the rest can remain fluid up until the last minute with little-to-no impact on the work I’m doing. We haven’t been able to do this with other technologies because they simply can’t support the rapid and concurrent iterations that are happening with both the presentation and the code.” Lee Brenner, Developer, frog design
Ultimately, the new collaboration means that iteration of a project can now happen in a much more fluid way. There is no longer the “one-way street” where a change to a specification downstream means a radical reworking of the entire application. The result opens up new possibilities for collaboration between the designer and developer, where a kind of dialogue is possible with the potential to foster greater creativity.
To help address navigating these new waters, we’ll look at the implications of XAML for designers and for developers7. Then, we’ll look at the workflow between these roles.
In the new collaboration model, the designer’s prototypes can be actual functional prototypes. Using new tools such as Expression Blend, a designer does not need a developer to help mock up a concept. All the various interactions possible are available to the designer to wire up, from button clicks to image loads to resize events. The result is that a relatively sophisticated prototype can be created without the need for a developer to be involved, thus improving productivity in the process.
Once created and approved, those prototypes can likely be used in the final product, instead of just being a byproduct of the design process that has no applicability to the final product. Robert Tuttle, from frog design, said, “Our prototypes in the initial stages of a project used to be between 100% and 50% throwaway. With WPF development, our prototypes are down to 20% throwaway.”
One important thing to call out is that, with the designer intimately part of the software development itself, designers (may) need to be more conversant in the implications of their work from a software perspective. Consider the classic pillars of software development: performance, maintainability, versioning, quality control, stability, etc. A designer’s work could affect any one of these topics, and thus the designer may need some education and training to understand the implications of their participation in the development. Because they are most likely using a tool to create the XAML, there is the possibility that they could create something with the tools that isn’t optimal from a software engineering perspective. Thus, they need to understand the implications of the tool(s). Specific ways to prepare for this are part of the third section of the paper.
In the “old way,” designers created mock-ups of the software, requiring developers to re-implement that vision, an inherently “lossy” process. In the “new way,” XAML is the lingua franca between designers and developers.
Another change brought by XAML for the developer is a need to structure projects that are conducive to optimizing the workflow. Tasks such as creating the initial project, setting up directory structures, resources, modules, and more become that much more critical for the developer to establish. Much of the success and efficiency that can be realized by XAML comes with up-front planning, most of which falls in the hands of the developer.
Implied in this assertion is the additional recommendation that developers need to understand XAML. In researching this paper, there was unanimous agreement that “XAML fluency” is a necessity for developers working on WPF. Ken Azuma, a Senior Experience Architect from 2nd Factory and author of a book on Expression Blend, noted, “As projects grow in complexity, there is a need for close attention to be paid to the XAML itself.” While much of the XAML will likely be created with tools by a designer, the developer needs to understand the implications of what these tools have created. The developer may also be responsible for integrating and structuring the various assets created by the tools; thus, understanding XAML is imperative. The reality of WPF development is that XAML is more than just an implementation detail. Relying solely on the tools without understanding what they are creating can lead to a less than optimal outcome down the line.
While there is no single recommended team model because skills are different across teams, there is one single best practice that we have identified across all models: identify a clear owner for each task or deliverable. Let’s elaborate these team models so the ownership recommendation can be explained.
The ideal integrator is an individual with design sensibility and good knowledge/understanding of WPF and XAML. The integrator becomes the owner of the XAML and the interface between the developer and designer, making sure that the XAML file is always optimal. It is the integrator’s role to structure the XAML and modularize the XAML where appropriate. As such, the integrator is a XAML expert and understands WPF concepts such as inheritance, styles, and resource look-up.
One of the advantages of having an integrator is that some of the onus of responsibility is lightened for the designer and the developer. With an integrator, the design team might not need to ramp-up on XAML to get their assets effectively integrated into the project. For designers who do not want to learn the new tools or don’t have the time in an aggressive project, they would be able to create assets in their familiar tools (for example, Adobe Illustrator) and export as XAML; the integrator then does any modifications needed to integrate this XAML into the project. Likewise, for developers who do not want to be concerned with how XAML impacts their code, the integrator can act as a buffer. Especially for short-term or aggressive projects, an experienced integrator can very quickly incorporate all the right visuals into a project and help to educate the developers/designers along the way.
On the other hand, it should be observed that there are potential downsides to the integrator role. It can be argued that understanding of XAML should be shared across the team and not isolated to a single point of failure with the integrator. Also, it has been observed that on larger projects, the integrator can become a bottleneck to the process because of the inherent ‘iterative’ nature of design - one hardly ever creates an asset or comp and not ‘polish’ or revise it. The designer-to-integrator transfer can be a task that repeats very often and that creates unnecessary overhead for each hand-off. In addition, an integrator can inadvertently change the original designer’s vision by making tweaks when integrating the XAML into the project. Finally, as a project scales, multiple integrators in a project are harder to manage because their work may overlap and ultimately burden the designers and developers.
Because every project and every team is different, it is hard to make a specific recommendation on whether an integrator is a key ingredient to success with the new workflows engendered by XAML, but we needed to highlight the role as a possibility for those starting a new project.
In the designer/developer model, there is no need for a new role, but rather a need for establishing processes to manage how graphic and interactive assets are incorporated into the project. There are two main approaches that developers and designers have used to optimize workflow: the harvest model and the collaborative model.
Within this model, the depth of the designers’ contributions depends on the fluency of the designers with the WPF tools. For example, the designer may be handing off exclusively graphic assets exported from a tool, or the designer may be creating actual WPF animations, styles, and templates that are then incorporated by the developer. So, within this workflow, it is possible for the designer to be quite well-versed in the capabilities of WPF but still be one step removed from the project.
The advantage of the “harvest” model is that designers are directly contributing to the project without the responsibility of understanding how these contributions impact the project. The disadvantage is that the designer is abstracted from the project such that iterations still require a handoff procedure.
Fundamentally, the difference between these two options is about the boundary between the designer and the developer. There is not a hard-and-fast rule about how to demarcate this boundary. In fact, increasingly, the line is getting blurred as the software industry is seeing more and more designers who can code and developers who can handle graphic and interaction design. Regardless of the skill sets, what’s important is to be explicit about what the boundaries are between the different roles for a given project. Clear understanding about who “owns” the XAML is critical. Another critical aspect is a packaging/hand-off strategy for these assets, which is covered in the tips and tricks section. Though XAML can be edited with just a text editor, it is more productive to use RAD (rapid application development) tools to create the user interface. Because XAML is XML-based, there are many tools that can either edit or export XAML. We don’t cover every tool on the market in this paper, but we focus on the most popular. We have grouped the tools into three distinct categories: (1) tools that target XAML, (2) tools that export XAML, and (3) WYSIWYG XAML editors.
Similar to Expression Design and Adobe Illustrator, these 3-D converters are one-way tools and have the same potential for loss of fidelity when rendered as XAML.
Expression Design | Expression Blend | Visual Studio 2008 | Adobe Illustrator | |
Layout | Static, absolute positioned | Dynamic | Dynamic | Static, absolute positioned |
Styliing | No | Visual Editor | No | No |
Templating | No | Visual Editor | No | No |
Resources | As export option | Visual Editor | No | No |
Code Support | No | Basic editor | Rich IntelliSense | No |
XAML Round-trips | One-way | Yes | Yes | One-way |
XAML exporting | Limits capabilities early to prevent lossiness | Yes | Yes | Lossy. Tools have more features than WPF does. |
Animation | No | Visual editor | XAML editor only | No |
For example, consider the following scenario: A designer creates a button in a tool and exports the art as XAML. Then, a developer modifies the XAML that was exported, perhaps changing a name. It is then decided that the button’s color needs changing. If the designer goes back to the one-way tool and makes the color change, the XAML that is exported does not have the name change made by the developer. The button may no longer work in the project and will require that the developer go back and tweak the XAML again. Thus, the optimization for iteration is compromised.
A solution to this problem is that one must take great care when integrating XAML that has been exported from a tool. There are several tricks to minimize the chances that the XAML will be corrupted when the asset needs to be re-exported:
Both Expression Design and Expression Blend have features to help create groupings that can be reused as objects.
In Expression Blend and Expression Design, if you import a raster image that was created at 72 pixels/inch and is 216 pixels wide, Blend will scale the image by 4/3 (or 96/72) times its size. The reason for this scaling is that the image was 3 inches wide (216/72), so Blend scales it so the size in WPF is still 3 inches. If the image had been created at 144 pixels/inch, Blend would scale the image by 2/3 (96/144).
Similar scaling occurs in Expression Design if you open an Adobe Illustrator file that had units in pixels; if the illustrator file was in points, it will not be scaled (because points are also resolution independent).
When working with layout, it helps to understand the content model in WPF. Some WPF layout controls can have one (and only one) child; other controls allow for multiple children. Some of those that allow multiple children allow those children to overlap; some don’t. These requirements can be cumbersome, but can be generalized for designers into this generic guidance:
For example, the default control template of a button is a ContentPresenter inside a ButtonChrome.
<ControlTemplate TargetType="{x:TypeButton}"> <Microsoft_Windows_Themes:ButtonChrome ...> <ContentPresenter ... /> </Microsoft_Windows_Themes:ButtonChrome> </ControlTemplate> |
A button based on the standard Windows theme.
If we wanted the button to be round, we could replace the ButtonChrome with a Grid and a round ellipse for its background.
<ControlTemplate TargetType="{x:TypeButton}"> <Grid ... > <Ellipse .../> <ContentPresenter ../> </Grid> </ControlTemplate> |
A custom button.
Using control templates a designer to create a button that looks like almost anything by replacing the button’s internal visual elements. It is important to note that replacing the template does not replace the behavior; this button still responds to clicks and mouse hovers with no additional work.
Once the skeleton (or visual elements) of a control have been defined by the control template, WPF also provides rich styling support for customizing the look and feel. By using a style, we can create a reusable group of settings (or attributes) to attach to an existing UI element to customize its look and feel.
To address a frequently asked question, the difference between control templates and styles is that a template replaces the visual composition of an element, while a style simply sets existing attributes or properties of an element.
There are many more details about how styles and templates work together that are not covered here, but a designer and developer should study and understand these two concepts carefully. These are the pillars of the separation (UI from code) that helps make the new collaboration model workable; by taking advantage of control templates, data templates, styles, and resource dictionaries, it is possible for developers to focus on logic (behavior) and designers to focus on visuals (UI).
Along these lines, if a developer has the option to create something either in XAML or in code, XAML is usually the better choice if whatever is created (an animation, for example) will need to be polished or tweaked by the designer in Blend. The discipline of working in XAML is an added cost for the developer, but it ultimately reaps productivity rewards and well as creativity rewards. If it can be opened in a design tool, it has the opportunity to have another’s hands on it. But if it is isolated in code, the designer is prevented from accessing it directly.
A great example of the usefulness of being able to open projects in Blend comes from the Blend team itself. Samuel Wan, a program manager with Expression Blend, noted, “We built both Blend and the skin for Design using Blend. The ability to get immediate visual feedback from the tool was invaluable. In the case of Design, we were able to overhaul the look and feel of an eight-year-old product in a matter of months.”
To avoid this type of problem, the WPF tools provide design-time APIs in the Microsoft.Windows.Design namespace to check if you are running inside a designer. With these APIs, you can check for the design environment and execute different code to prevent your control from throwing an error.
For example, Blend supports creating data templates through a simple drag-and-drop operation of dragging a data schema (a CLR object or an XML schema). If the data and schema is ready before the designer starts the layout of the user interface, this will save time for both the designer and the developer. This way, the designer is accomplishing more than layout of the user interface; the designer is binding the UI to the business object schema, saving the developer from having to do that later. Using the schema from the beginning also saves the designer the work of modifying the design later because of changes to the data model.
A note about names: be aware that when you name an object (x:Name =”” or Name=””) the XAML compiler generates a variable as a member of the code-behind class; for most scenarios this is very useful for the developer and usually low-cost at run time (a few bytes of memory and a couple instructions of initialization code); you just need to be aware of the extra reference to your object. If you were loading and unloading named objects at run time, you would need to set the variable created to null for the garbage collector to clean up the memory for this variable while the class is still in memory.
The actual size of the XAML file can get extremely large, causing readability and maintainability issues. This can become especially problematic in the event that a person needs to hand-tweak the XAML. Blend provides a handy feature called “View XAML” that allows you to jump into the XAML right from the representation of the visual tree.
This helps, but it doesn’t entirely solve the XAML bloat problem, as sometimes it is more difficult to see the templates or resources that are part of a XAML file. Modularizing XAML files is key, especially for a large project. Essential to modularizing XAML files is understanding what the different parts of the XAML files actually do. Paul Stovell16 breaks this down nicely, classifying XAML files as either functional XAML or resource XAML. Functional XAML files include things with top-level elements like Window, Page or UserControl. Resource XAML files have two subcategories: generic resource XAML files, which contain resources that are used throughout the application such as Brush and Style resources, and specific resource XAML, which contain resources specific to a particular Window, Control, or Page, such as a 3-D geometry. Stovell has an example application with a proposed directory structure that is worth checking out.
Aaron Jasinski, a designer on the Expression team who worked on the user experience and styles for both Expression Blend and Expression Design, noted that this was an essential tool for tweaking the user interface in many cases. The designer would be able to see a live view of what the application would look like and make changes to the properties. Then, a developer could incorporate those changes into the code. While SNOOP certainly isn’t as sophisticated as a complete design tool, it is a very handy mechanism to modify the user interface at run time. This paper would not have been possible without the help of many people. Thanks to Tim Aidlin for doing the graphics, the numerous reviewers who gave invaluable feedback and the early adopter companies whose experience with the platform helped inform the paper.