Introduction
The .NET revolution is in full swing, and the confusion that has surrounded it for the last year is finally lifting. Developers are no longer wondering whether .NET is designed for web services, distributed applications, object-oriented development, cross-language interoperability, painless deployment, or a new way to access data. Instead, we now realize that .NET is built for all of that, and much more. With .NET, Microsoft has bundled almost a dozen miniature revolutions into one marketing term, along with a class library stocked with hundreds of pieces of prebuilt functionality.
Unfortunately, you can''t come to terms with the amazing breadth of the .NET Framework by reading a single book. To become an expert .NET programmer, you need an in-depth exploration of the areas of development that interest you the most. In other words, it''s time to forget about the broadly sweeping goals of .NET for a moment, and focus on the nuts and bolts of how to design the next-generation of software applications.
This book explains how to program user interfaces applying the tools and techniques of the .NET world. You may already be familiar with some of the concepts that carry over from traditional development (like multiple-document interfaces, and the standard Windows controls and conventions). Other features are entirely new and will be unlike anything you have ever worked with before. But no matter what aspect of user interface design you''re exploring, it all works through the .NET class library, which provides a new set of capabilities, subtleties, and quirks that every .NET programmer needs to master.
About This Book
User interface design deals with several aspects of programming. The tendency in a book about a topic like this is to pursue one of these themes exclusively. With .NET, however, the programming framework is entirely new. A reference that only explains controls and commands is dangerous, and without a proper discussion of best practices and design tips, programmers are likely to wind up in a great deal of trouble-with applications that are difficult to enhance, debug, or scale up. For that reason, I''ve made the decision in this book to focus on three distinct themes.
What This Book Teaches You
This book fills three roles. It provides the following:
An overview of how to design elegant user interfaces the average user can understand. This is addressed directly in the first chapter, and indirectly in Tips and Notes throughout the book.
A comprehensive examination of the user interface controls and classes in .NET. Although this book is not a reference, it contains an exhaustive tour of almost every user interface element you''ll want to use, including providers, components, and custom controls.
A tutorial with best practices and design tips for coding user interfaces and integrating help. As a developer, you need to know more than how to add a control to a window. You also need to know how to create an entire user interface framework that''s scalable, flexible, and reusable.
What This Book Doesn''t Teach You
Of course, it''s just as important to point out what this book doesn''t contain:
A description of core .NET concepts like namespaces, assemblies, exception handling and types. These fundamentals are an important basis for .NET design, and they are already explained well in several works, including a number of excellent C# and VB .NET books from Apress.
A primer on object-oriented design. No .NET programmer can progress very far without a solid understanding of classes, interfaces, and other .NET types. In this book, many examples rely on these basics, using objects to encapsulate, organize, and transfer information.
A reference for Visual Studio .NET. The new integrated design environment provides powerful customization, automation, and productivity features that deserve a book of their own. Though this book describes a few control designers, for the most part it assumes that you already know how to use IDE to create controls and set properties.
A comparison between .NET and its predecessors (including Visual Basic, C++, and even Java). Examining the evolution of the .NET language is largely a historical interest and while fascinating, it won''t help you master modern .NET development any faster. The best approach is to leave your past language allegiances behind.
If you haven''t learned the .NET fundamentals, you will probably still be able to work through this book. You will probably need to do so at a slower pace, and you may also need to refer to the MSDN help files to clear up a few issues along the way. On the other hand, if you have already read another, more general .NET book, you will benefit the most.
Note
This book is targeted at experienced developers. If you have never programmed with a language like Visual Basic, C++/C#, or Java before, this isn''t the place to start. Instead, start with an introductory book on object-oriented design or programming fundamentals.
Code Samples
It''s a good idea to check the online site to download the most recent, up-to-date code samples. You''ll need to do this to test most of the more sophisticated code examples described in this book, because the full code listing is often left out. Instead, I focus on the most important conceptual sections so that you don''t need to wade through needless extra pages to understand an important concept.
To download the source code, surf to http://www.prosetech.com or http://www.apress.com
Variable Naming
It seems that variable naming is about to become another religious issue where there is no clear standard, but developers take heated, uncompromising attitudes. Hungarian notation, which was the preferred standard for C++ and Visual Basic (in a slightly modified form), is showing its age. In the world of .NET, where memory management is handled automatically, it seems a little backward to refer to a variable by its data type, especially when the data type may change without any serious consequences, and the majority of variables are storing references to full-fledged objects.
To complicate matters, Microsoft recommends that objects use simple names for properties and methods, like COM components and controls. This system makes a good deal of sense, as data type considerations are becoming more and more transparent. Visual Studio .NET now takes care of some of the work of spotting the invalid use of data types, and its built-in IntelliSense automatically displays information about the data types used by a method.
In this book, data type prefixes are not used for variables. The only significant exception is with control variables, where it is still a useful trick to distinguish between types of controls (like txtUserName and lstUserCountry), and with some data objects. Of course, when you create your programs you are free to follow whatever variable naming convention you prefer, provided you make the effort to adopt complete consistency across all your projects (and ideally across all the projects in your organization).
Feedback
This book has the ambitious goal of being the best tutorial and reference for .NET user interface design. Toward that end, your comments and suggestions are extremely helpful. You can send complaints, adulation, and everything in between directly to