User and Program Interfaces in .NET


At the top layer, .NET provides four ways to render and manage user interfaces:

  • Windows Forms

  • Web Forms

  • Windows Presentation Foundation

  • Console applications (not shown in Figure 1-1)

.NET also provides several techniques for interprocess communication, either on the same machine or between different machines. These include Web Services, .NET Remoting, and the new Windows Communication Foundation.

Using .NET effectively requires understanding the strengths and intended uses of these technologies, and how to choose among them for specific circumstances. The following sections provide a brief overview, with references to additional chapters in the book that go into more depth.

Windows Forms

Windows Forms is a more advanced and integrated way to do standard Win32 screens. All languages that work on the .NET Framework can use the Windows Forms engine, which duplicates the functionality of the old VB forms engine. It provides a rich, unified set of controls and drawing functions. It effectively replaces the Windows graphical API, wrapping the Windows GDI kernel in such a way that developers normally have no need to go directly to the Windows API for any graphical or screen functions.

Chapter 15 describes Windows Forms in more detail and notes significant changes in Windows Forms versus older VB forms. Chapter 16 continues discussing advanced Windows Forms capabilities such as creation of Windows Forms visual controls.

Client Applications versus Browser-Based Applications

Before .NET, many internal corporate applications were browser-based simply because of the cost of installing and maintaining a client application on hundreds or thousands of workstations. Windows Forms and the .NET Framework change the economics of these decisions. A Windows Forms application is much easier to install and update than an equivalent VB6 desktop application. With a simple XCOPY deployment and no registration issues, installing and updating become much easier. Internet deployment via ClickOnce also makes applications more available across a wide geographic area, with automatic updating of changed modules on the client.

This means that “smart client” applications with a rich user interface are more practical under .NET, even for a large number of users. It may not be necessary to resort to browser-based applications just to save on installation and deployment costs.

As a consequence, don’t dismiss Windows Forms applications as merely replacements for earlier VB6 desktop applications. Instead, examine applications in .NET and explicitly decide what kind of interface makes sense in a given scenario. In some cases, applications that you might have assumed should be browser-based simply because of a large number of users and wide geographic deployment instead can be smart-client-based, which can improve usability, security, and productivity.

In other cases, it might be appropriate for parts of your system to expose a Windows Forms interface, and other parts to expose a browser-based system. Because logic for data access and other system chores is compatible with both of those UI technologies, multiple forms of user interface could easily work with the same server-based functionality.

Web Forms

The part of .NET that handles communications over the Internet is called ASP.NET. It includes a forms engine, called Web Forms, which can be used to create browser-based user interfaces.

Divorcing layout from logic, Web Forms consist of two parts:

  • A template, which contains HTML-based layout information for all user interface elements

  • A component, which contains all logic to be hooked to the user interface

It is as if a standard Visual Basic form were split into two parts, one containing information on controls and their properties and layout, and the other containing the code. Just as in Visual Basic, the code operates “behind” the controls, with events in the controls activating event routines in the code.

As with Windows Forms, Web Forms are available to all .NET languages. This brings complete, flexible Web interface capability to a wide variety of languages. Chapters 19 and 20 go into detail about Web Forms and the controls that are used on them.

If you have only used ASP.NET in versions 1.0 or 1.1 of .NET, you should know that ASP.NET 2.0 has dramatic improvements. With even more built-in functionality for common browser tasks, applications can be written with far less code in ASP.NET 2.0 as compared to earlier versions. Capabilities such as user authentication can now be done with prebuilt ASP.NET components, so you no longer have to write such components yourself.

Windows Presentation Foundation

As mentioned at the beginning of this chapter, changing hardware technologies often force changes in our software platforms and development tools. Recent advances in display technologies provide an example. Video hardware has become more powerful. Display devices have become available in many different sizes, resolutions, and aspect ratios.

Developers are accustomed to making decisions about what resolution to support for their applications. Should it be 800×600? Or 1024×768? As such options multiply, decisions become much more complex, and it becomes desirable to find a more complete solution by supporting a wider variety of display devices.

Microsoft’s answer is Windows Presentation Foundation (WPF). At its core, WPF is vector-based, rather than bit-mapped. This enables user interface objects such as controls and shapes to be scalable to any size or resolution. Users of vector-based drawing programs are familiar with this advance, but with WPF it becomes available for general programming use.

WPF also tightly integrates many other display-related technologies, such as animation, styling, and three-dimensional visualization. Media, such as video playback, can easily be placed on any user interface surface.

Microsoft’s ambitions for WPF go beyond just supplementing Windows Forms for local interfaces. A version of WPF is planned for non-Windows systems. It is tentatively called WPF/e, sometimes referred to as WPF Everywhere. WPF/e will enable browser pages to incorporate many of WPF’s sophisticated UI features, even if those pages are running on non-Windows systems such as the Apple Macintosh.

Chapter 17 provides an introduction to WPF, and Chapter 18 discusses integration and interoperability of WPF with Windows Forms.

Console Applications

Although Microsoft doesn’t emphasize the .NET Framework’s capability to write character-based applications, the framework does include an interface for such console applications. Batch processes, for example, can now have components integrated into them, and those components can write to a console interface.

As with Windows Forms and Web Forms, this console interface is available for applications written in any .NET language. Writing character-based applications in pre-.NET versions of Visual Basic, for example, was always a struggle, because those versions were completely oriented around a graphical user interface (GUI). Visual Basic 2005 is independent of user interface technology, and can be used for true console applications along with forms-based and browser-based user interfaces.

Web Services and Windows Communication Foundation

Application development is moving into the next stage of decentralization. The oldest idea of an application is a piece of software that accesses basic operating system services, such as the file system and graphics system. Then we moved to applications that used a lot of base functionality from other system-level applications, such as a database - this type of application added value by applying generic functionality to specific problems. The developer’s job was to focus on adding business value, not building the foundation.

Web Services represented the next step in this direction. In Web Services, software functionality becomes exposed as a service that doesn’t care what the consumer of the service is (unless there are security considerations). Web Services enable developers to build applications by combining local and remote resources for an overall integrated and distributed solution.

In .NET, Web Services are implemented as part of ASP.NET (refer to Figure 1-1), which handles all Web interfaces. It enables programs to talk to each other directly over the Web, using the SOAP standard. This has the potential to dramatically change the architecture of Web applications, allowing services running all over the Web to be integrated into a local application.

Chapter 26 contains a detailed discussion of Web Services.

Moving beyond Web services, the Windows Communication Foundation (WCF) provides the next generation of decentralization. WCF is new in .NET Framework 3.0. It subsumes most of the technologies used in earlier versions of .NET for interprocess communication. Web Services, for example, can be completely wrapped by WCF.

Other Microsoft technologies that are either wrapped or have their functionality replicated in WCF include Enterprise Services, Microsoft Message Queue (MSMQ), and .NET Remoting. All are exposed via a consistent API, so it is no longer necessary in .NET to learn a variety of APIs for cross-process or cross-machine interaction.

Microsoft’s intent with WCF is to provide a platform for creating applications with a Service-Oriented Architecture (SOA). Such an architecture does interprocess communication using messages, rather than function calls or their equivalent. The messages must satisfy a contract that specifies the format of the message and all the information in it. As long as each side of the communication understands how to use the contract, the way each side actually stores the data is irrelevant to the other side.

This type of architecture allows loose coupling between parts of the application. The parts don’t have to know much about each other - they just need to understand the contract. That makes it much easier to replace a part of the application with similar functionality without significant modification to the rest of the application.

Chapter 30 covers the basics of WCF.

.NET Remoting is the remaining technology for interprocess communication. It is not intended for a Service-Oriented Architecture - instead, it allows actual object calls between different .NET processes. The advantage of .NET Remoting is speed on local area networks.

However, WCF has comparable performance capabilities on LANs, and is expected to be the basis for future innovation in interprocess communication. While .NET Remoting will continue to be supported in .NET indefinitely, it is no longer being enhanced. For new applications, WCF is usually preferred.

Chapter 27 covers .NET Remoting.




Professional VB 2005 with. NET 3. 0
Professional VB 2005 with .NET 3.0 (Programmer to Programmer)
ISBN: 0470124709
EAN: 2147483647
Year: 2004
Pages: 267

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net