Tom Hollander Solution Architect Microsoft Australia Session Code: ARC302
Session Objectives And Takeaways Session Objectives: Explain Enterprise Library 5.0 design Demonstrate key improvements Key Takeaways: User experience matters We hear your pain! Simplicity for the win! DI Containers everywhere Better modularity, testability and maintainability
Before the Beginning....NET Framework 1.0 is released Some written guidance and sample code Not normally production ready Many organisations invested in their own “frameworks” 2002
Genesis First patterns & practices Application Blocks Data Access Application Block Exception Management Application Block Configuration Management Application Block Caching Application Block Enterprise Instrumentation Framework Emergence of partner and open source frameworks ACA.NET, CSLA,
Enterprise Library 1.0 / 1.1 Themes: Consistency, Extensibility, Ease of Use, Integration Target Platform:.NET Framework 1.1 Blocks: Caching, Configuration, Cryptography, Data Access, Exception Handling, Logging & Instrumentation, Security Tools: Standalone configuration editor 2005
Enterprise Library 2.0 Themes:.NET Framework 2.0 platform alignment Target Platform:.NET Framework 2.0 Blocks: Caching, Cryptography, Data Access, Exception Handling, Logging, Security Tools: Standalone configuration editor 2006
Enterprise Library 3.0 / 3.1 Themes: New application blocks, Visual Studio integration Target Platform:.NET Framework 2.0 & 3.0 Blocks: Caching, Cryptography, Data Access, Exception Handling, Logging, Security, Validation, Policy Injection Tools: Standalone + VS integrated configuration editor, Application Block Software Factory 2007
Enterprise Library 4.0 / 4.1 Themes: Dependency Injection, WMI 2.0 Target Platform:.NET Framework 3.5 Blocks: Caching, Cryptography, Data Access, Exception Handling, Logging, Security, Validation, Policy Injection, Unity Tools: Standalone + VS integrated configuration editor 2008
Enterprise Library 5.0: Themes Enhanced User Experience, Simplicity for the Win! Learnability & Discoverability Accelerate Your Development!
Functional blocksInfrastructure Structural/wiring blocks SecuritySecurity DataAccessDataAccess CryptographyCryptography ValidationValidation LoggingLogging CachingCachingExceptionHandlingExceptionHandling UnityUnity ConfigConfig Instrumen- tation Policy Injection Enterprise Library 5.0: Blocks
Alignment Target binaries for.NET Framework 3.5 SP1 Target source projects for VS2008 Target config tool for both VS2008 and VS2010
We hear your pain!
When Something Goes Wrong Debugging
Improved error messaging
Object Graph DriveControllerDriveController EngineMonitorEngineMonitor EngineData Repository EngineSensorEngineSensor ILoggerILogger ConsoleLoggerConsoleLogger Authorization Provider IAuthorization Token DefaultAuthorization Token P P
Logging Performance Originally, planned to implement async logging Perf analysis of the lower level operations of the logging block (v4.1) showed: The formatter took 54% of the total time Of this, the most expensive operations are: Getting the machine name 9.63 Computing Severity textual representation 5.70 Undetermined mscorwks.dll work 5.17 Computing DateTime textual representation 4.46 StringBuilder.Append 4.10 Getting the process name
Logging Performance Optimisation Added predefined timestamp patterns mapped to high-speed formatting implementations. FixedFormatISOInternationalDate: yyyy-MM-dd FixedFormatTime: HH:mm:ss.fff Added 4 new "local" tokens for context info localAppDomain localMachine localProcessName localProcessId Modified default template to take advantage the above
Logging Performance Optimisation Preliminary Results Formatter responsible for ~50% of the execution time Improvements 45% local improvement 53% local improvement
Processing Results from Sprocs Data Access Application Block traditionally made it easier to call sprocs Processing the results still means dropping back into classic ADO.NET code Issue: how could we make it easier to consume the results of a sproc?
DAAB Accessors
LINQ Style Result Processing Basic idea: Instead of a DataReader from a query, get back an IEnumerable Now we can do LINQ to Objects Introduced Accessors Provide a higher level abstraction that combines input mapping, output mapping, and result set management into a single object. Accessors are easily injectable
Config Experience Programmatic config support Intellisense in XML editor Default config out of the box Improved config tool
Fluent Configuration Interface Motivation: Customers requested a better way to configure EntLib programmatically Make our own test cases more readable Fluent interface More succinct, more readable programmatic configuration
Fluent Interfaces
Tackling External Complexity Single entry point EnterpriseLibraryContainer.Current Supporting testability in your code that uses EntLib Using DI style with instances Container independence Not tied to Unity Can build your own adapters Preliminary perf is equivalent to v4.1 or better Importantly: All existing user code still works
Tackling Internal Complexity Cleanup got rid of ~200 classes! removed layers of indirection added ~120 classes, but less complicated reduced # assemblies (incl. OB2 – RIP!!!!!) Changed internals significantly custom blocks would need to be re-written but this should be easier now
Getting EntLib objects
Config Tool: UX Matters! Config tool has not evolved significantly since v1 New and occasional users fared poorly in usability studies Is it time for a paradigm shift? Important : The following mock-ups are experimental and may never see the light of day But improving config UX is a core goal of v5
Config Tool Ux
Learnability Hands-On Labs New Guides Your feedback is invited entlib.codeplex.com
But Wait... There’s More! Highlights DAAB Async overloads Unity config tool support Unity/MEF integration Validation WPF integration Purge old rolling log files Multiple config file support Full product backlog on
Key Takeaways Improving user experience Simpler, more consistent code base Simpler to use Better support for DI-style of development Existing public API not broken
Sessions On-Demand & Community Resources for IT Professionals Resources for Developers Microsoft Certification & Training Resources Resources
Enterprise Library Resources All EntLib5 current bits: entlib.codeplex.com unity.codeplex.com Released Enterprise Library and related resources: msdn.microsoft.com/practices msdn.microsoft.com/entlib Enterprise Library Community: entlib.codeplex.com Blogs: Tom Hollander:blogs.msdn.com/tomholl Grigori Melnik: blogs.msdn.com/agile Bob Brumfield:blogs.msdn.com/bobbrum Chris Tavares: tavaresstudios.com/Blog
COMPLETE YOUR EVALUATION FORMS IN COMMNET AND BE IN TO WIN ONE OF THE 150 DAILY PRIZES* GIVE US YOUR FEEDBACK & WIN INSTANTLY! *For full terms & conditions and more information, please visit the CommNet Portal.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.