Developers Guide to Microsoft Enterprise Library
Solutions for Enterprise Development
Alex Homer
Nicolas Botto
Bob Brumfield
Grigori Melnik
Erik Renaud
Fernando Simonazzi
Chris Tavares
Copyright 2010
This document is provided as-is. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it.
Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred.
This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes.
Microsoft, Windows, Windows Server, Windows Vista, Visual C#, SQL Server, Active Directory, IntelliSense, Silverlight, MSDN, Internet Explorer, and Visual Studio are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners.
Microsoft Press
Foreword
You are holding in your hands a book that will make your life as an enterprise developer a whole lot easier.
Its a guide on Microsoft Enterprise Library and its meant to guide you through how to apply .NET for enterprise development. Enterprise Library, developed by the patterns & practices group, is a collection of reusable components, each addressing a specific cross cutting concernbe it system logging, or data validation, or exception management. Many of these can be taken advantage of easily. These components are architecture agnostic and can be applied in a multitude of different contexts.
The book walks you through functional blocks of the Enterprise Library, which include data access, caching, cryptography, exception handling, logging, security, and validation. It contains a large collection of exercises, tricks and tips.
Developing robust, reusable, and maintainable application requires knowledge of design patterns, software architectures and solid coding skills. We can help you develop those skills with Enterprise Library since it encapsulates proven and recommended practices of developing enterprise applications on the .NET platform. Though this guide does not go into the depth of discussions of architecture and patterns, it provides a solid basis for you to discover and implement these patterns from a reusable set of components. Thats why I also encourage you to check out the Enterprise Library source code and read it.
This guide is not meant to be a complete reference on Enterprise Library. For that, you should go to MSDN. Instead, the guide covers most commonly used scenarios and illustrates how Enterprise Library can be applied in implementing those. The powerful message manifesting from the guide is the importance of code reuse. In todays world of complex large software systems, high-quality pluggable components are a must. After all, who can afford to write and then maintain dozens of different frameworks in a system all to accomplish the same thing? Enterprise Library allows you to take advantage of the proven code complements to manage a wide range of task and leaves you free to concentrate on the core business logic and other working parts of your application.
Another important emphasis that the guide makes is on software designs, which are easy to configure, testable and maintainable. Enterprise Library has a flexible configuration subsystem driven from either external config files, or programmatically, or both. Leading by example, Enterprise Library itself is designed in a loosely-coupled manner. It promotes key design principles of the separation of concerns, single responsibility principle, principle of least knowledge and the DRY principle (Dont Repeat Yourself). Having said this, dont expect this particular guide to be a comprehensive reference on design patterns. It is not. It provides just enough to demonstrate how key patterns are used with Enterprise Library. Once you see and understand them, try to extrapolate them to other problems, contexts, scenarios.
The authors succeeded in writing a book that is targeted at both those who are seasoned Enterprise Library developers and who would like to learn about the improvements in version 5.0, and those, who are brand new to Enterprise Library. Hopefully, for the first group, it will help orientate you and also get a quick refresher of some of the key concepts. For the second group, the book may lower your learning curve and get you going with Enterprise Library quickly.
Lastly, dont just read this book. It is meant to be a practical tutorial. And learning comes only through practice. Experience Enterprise Library. Build something with it. Apply the concepts learnt in practice. And dont forget to share your experience.
In conclusion, I am excited about both the release of Enterprise Library 5.0 and this book. Especially, since they ship and support some of our great new releasesVisual Studio 2010, .NET Framework 4.0 and Silverlight 4, which together will make you, the developer, ever more productive.
Scott Guthrie
Corporate Vice-President
Microsoft .NET Developer Platform
Redmond, Washington
Preface
About This Guide
When you casually pick up a book in your local bookstore or select one from the endless collection available on your favorite Web site, youre probably wondering what the book actually covers, what youll learn from it, whether the content is likely to be interesting and useful, andof coursewhether it is actually any good. Well have a go at answering the first three of these questions here. The final question is one only you can answer. Of course, we would be pleased to hear your opinion through our community Web site at http://entlib.codeplex.com/.
What Does This Guide Cover?
As you can probably tell from the title, this guide concentrates on how you can get started with Enterprise Library. It will help you learn how to use Enterprise Library in your applications to manage your crosscutting concerns, simplify and accelerate your development cycle, and take advantage of proven practices. Enterprise Library is a collection of prewritten code components that have been developed and fine-tuned over many years. You can use them out of the box, modify them as required, and distribute them with your applications. You can even use Enterprise Library as a learning resource. It includes the source code that demonstrates Microsoft.NET programming techniques and the use of common design patterns that can improve the design and maintainability of your applications. By the way, if you are not familiar with the term crosscutting concerns, dont worry; well explain it as we go along.
Enterprise Library is an extensive collection, with a great many moving parts. To the beginner knowing how to best take advantage of it is not completely intuitive. Therefore, in this guide well help you to quickly understand what Enterprise Library is, what it contains, how you can select and use just the specific features you require, and how easy it is to get started using them. You will see how you can quickly and simply add Enterprise Library to your applications, configure it to do exactly what you need, and then benefit from the simple-to-use, yet extremely compelling opportunities it provides for writing less code that achieves more.
The first chapter of this guide discusses Enterprise Library in general, and provides details of the individual parts so that you become familiar with the framework as a whole.
The aim is for you to understand the basic principles of each of the application blocks in Enterprise Library, and how you can choose exactly which blocks and features you require. also discusses the fundamentals of using the blocks, such as how to configure them, how to instantiate the components, and how to use these components in your code.