Not Another Language”Please Stop!
Back when Microsoft first announced one of the new languages that would fit into its new .NET framework, I was very skeptical. That language was C# (pronounced C-Sharp ) and is the primary language that this book uses for its examples. This doesn't mean that those developers choosing other .NET-supported languages (e.g., VB.NET, J#, Managed C++, etc.) cannot use this material. In fact, the primary goal of this book is to provide, as much as possible, a language- agnostic viewpoint of .NET practices. This approach is the very same approach Microsoft has implemented in .NET with its runtime and its language specifications. The focus is on the framework, its design elements, and what best practices and patterns can be extracted from it. The samples happen to be written in C# because that is my personal preference, but each of these ideas can be implemented in VB.NET, J#, or any other supported .NET language. This has to do with the way Microsoft has architected its framework. This is truly one of the most powerful and unique features of this product. The developer now gets to choose his or her own syntax of choice while still learning all of the common elements from the .NET libraries, along with common design philosophies taught in this book. Using .NET, more common design patterns such as the "strategy" pattern can now be implemented using a multitude of languages. Figure 1.1 uses stereotypes to designate what language each entity of the strategy pattern is implemented in. This is only a simple demonstration of the flexibility cross-language inheritance provides the designer. Even commonly implemented patterns such as the Strategy can be given a new twist with the help of .NET.
Figure 1.1. Shows how a classic design pattern such as Strategy can be implemented in .NET.
If you happen to be at the crossroads of which .NET language to select, I would select C#. This may come as a shock to those Visual Basic programmers who feel that learning VB.NET would be less of a technology leap. Because this framework is so different, the learning curve is not in the syntax but in the environment. For those new to object-oriented technologies, even VB.NET will be quite a leap from the Visual Basic 6.0 world. If you were to learn such a new system, I would suggest picking a language where the most examples could be found. Again, I believe that is C#, although Microsoft has made an incredible effort to show both VB.NET and C# in its documentation and online content. Even though .NET will support any language conforming to the common language infrastructure (CLI), C# is the language of .NET, similar to the way that C is the language of Windows (Dr. GUI, November 20, MSDN Magazine ). C# was built with .NET in mind from the ground up. Even much of the framework itself was built using this language.
The runtime I keep referring to is called the common language runtime (CLR). The type system used by the CLR is referred to as the common type system (CTS), and the specification of .NET is called the common language specification (CLS)”a mouthful of acronyms, to say the least. Although I assume most readers will have worked with .NET or are familiar with its environment, you will not require any significant .NET design experience to understand the principles in this book. I also assume a familiarity with object orientation, but only a cursory knowledge is required. Understanding the basics of inheritance, abstraction, association, and polymorphism will help you decipher the benefits of the ensuing material. However these patterns are aimed at those new to object orientation, service-orientation, and specifically object-oriented best practices. One of my primary goals is to bridge the gap between service-oriented and object-oriented architectures and not just provide the reader with yet another rehash of common design patterns and practices. Unfortunately, I will not be going deep into the plumbing of the CLR, CTS, CLI, or CLS. However, throughout the book, I will be providing "technology backgrounders" on some of the more specific shared library implementations for those just learning some of .NET's more advanced features. I hope to provide everyone, including those new to this framework, a chance to improve their designs using these patterns and principles. I also hope to provide you with a reference-like resource so that this book does not have to absorbed in its entirety or be "shelved" once it is read. Hopefully, this will serve as a quasi-library of information and a catalog of "named ideas" that can be used again and again.