This book covers the topics and teaches you the skills you need to design and develop component-based .NET applications. However, to make the most of .NET, it helps to know its origins and how it improves on the shortcomings of past technologies. In addition to showing you how to perform certain tasks, the book often explains the rationale behind them in terms of the principles of component-oriented programming. Armed with such insights, you can optimize your application design for maintainability, extensibility, reusability, and productivity. While the book can be read without prior knowledge of COM, I occasionally use COM as a point of reference when it helps explain why .NET operates the way it does.
In this book, you’ll learn not only about .NET component programming and the related system issues, but also about relevant design options, tips, best practices, and pitfalls. The book avoids many implementation details of .NET and largely confines its coverage to the possibilities and the practical aspects of using .NET as a component technology: how to apply the technology and how to choose among the available design and programming models. In addition, the book contains many useful utilities, tools, and helper classes I’ve developed since .NET was introduced five years ago. These are aimed at increasing your productivity and the quality of your .NET components. After reading this book, you will be able to start developing .NET components immediately, taking full advantage of the .NET development infrastructure and application frameworks. The book makes the most of what both .NET 1.1 and .NET 2.0 have to offer.
Here is a brief summary of the chapters and appendixes in this book:
- Chapter 1, Introducing Component-Oriented Programming
Provides the basic terminology used throughout the book. This chapter contrasts object-oriented programming with component-oriented programming and then enumerates the principles of component-oriented programming. These principles are the “why” behind the “how” of .NET, and understanding them is a prerequisite to correctly building component-based applications.
- Chapter 2, .NET Component-Oriented Programming Essentials
Describes the elements of .NET, such as the Common Language Runtime (CLR), .NET programming languages, the code-generation process, assemblies, and building and composing those assemblies. This chapter ends by explaining how .NET maintains binary compatibility between clients and components and discussing the implications of this solution for the programming model. If you are already familiar with the fundamentals of the .NET Framework, both in version 1.1 and version 2.0, feel free to skim over or entirely skip this chapter.
- Chapter 3, Interface-Based Programming
Examines working with interfaces. This chapter explains how to separate an interface from its implementation in .NET, how to implement interfaces, and how to design and factor interfaces that cater to reusability, maintainability, and extensibility.
- Chapter 4, Lifecycle Management
Deals with the way .NET manages objects, and the good and bad implications this has for the overall .NET programming model. This chapter explains the underlying .NET garbage-collection mechanism and shows component developers how to dispose of resources held by instances of a component.
- Chapter 5, Versioning
Begins by describing the .NET version-control policy and the ways you can deploy and share its components. After dealing with the default policy, this chapter shows how to provide custom version binding and resolution policies to address application- or even machine-specific needs. The chapter also discusses how to develop applications that support multiple versions of .NET itself.
- Chapter 6, Events
Shows how to publish and subscribe to events in a component-based application. After discussing the built-in support provided by .NET, this chapter presents a number of best practices and utilities that are designed to make the most of the basic event support and to improve it.
- Chapter 7, Asynchronous Calls
Describes .NET’s built-in support for invoking asynchronous calls on components, the available programming models, their trade-offs, when to use them, and their pitfalls.
- Chapter 8, Multithreading and Concurrency Management
Explains in depth how to build multithreaded components. No modern application is complete without multiple threads, but multithreading comes with a hefty price—the need to synchronize access to your components. This chapter shows how to create and manage threads and how to synchronize access to objects, using both the little-known synchronization domains and the manual synchronization locks. The chapter ends with a rundown of various multithreading services in .NET, such as the thread pool and timers.
- Chapter 9, Serialization and Persistence
Shows how to persist and serialize an object’s state. Serialization is useful when saving the state of an application to a file and in remote calls. This chapter demonstrates the use of automatic and custom serialization and shows how to combine serialization with a class hierarchy. You will also see how to improve on the basic serialization offering using generics.
- Chapter 10, Remoting
Demystifies .NET support for remote calls. This chapter starts by explaining application domains and the available remote object types and activation modes. After a discussion of the remoting architecture, it shows how to set up a distributed component-based .NET application, both programmatically and administratively. The chapter concludes by explaining how to manage the lifecycle of remote objects using leasing and sponsorship. Even if you do not intend to use remoting, this chapter provides a lot of details on the inner workings of .NET and its object activation mechanism, as well as scalability strategies.
- Chapter 11, Context and Interception
Describes a powerful and useful (but undocumented) facet of .NET: its ability to provide ways to define custom services via contexts and call interception. This chapter explains contexts and how they are used to implement component services, as well as the interception architecture and how to extend it. It ends with a walk-through of two real-life productivity-oriented custom services.
- Chapter 12, Security
Addresses the rich topic of .NET code-access security. Unlike Windows security, .NET security is component-based, not user-based. As such, it opens new possibilities for component developers. This chapter shows how to administer security using the .NET configuration tool and how to provide additional security programmatically. It also covers how to use .NET role-based security and how to install a custom authorization mechanism.
- Appendix A, Interface-Based Web Services
Shows how to enforce a core principle of component-oriented programming—separation of interface from implementation—when using .NET web services, both on the service side and the client side.
- Appendix B, Unifying Windows Forms and ASP.NET Security
Presents a set of interacting helper classes and controls that enable a Windows Forms application to use the ASP.NET 2.0 credential-management infrastructure with the same ease as if it were an ASP.NET application. This provides the productivity benefits of ASP.NET as well as a unified credentials store, regardless of the application user interface.
- Appendix C, Reflection and Attributes
Explains .NET reflection and how to develop and reflect custom attributes. If you aren’t familiar with reflection, I recommend reading this appendix before the rest of the chapters.
- Appendix D, Generics
Briefly explains generics, which are some of the most powerful and useful features of .NET 2.0. This book makes extensive use of generics in almost every chapter. If you are unfamiliar with generics, I recommend that you read this appendix before the rest of the chapters. More advanced aspects of generics are covered in the chapters themselves.
- Appendix E, C# Coding Standard
Presents a consolidated list of all the best practices and dos and don’ts mentioned thought the book. The standard is all about the “how” and the “what,” not the “why”; the rationale behind it is found in the rest of the book. The standard is based on the IDesign Coding Standard, which has become the de facto industry coding standard for .NET development. The IDesign standard in turn was based on the first edition of this book.
Get Programming .NET Components, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.