welcome to grigori melnik’s talk on microsoft enterprise library 5.0 @ patterns & practices...
TRANSCRIPT
Welcome to Grigori Melnik’s talk onMicrosoft Enterprise Library 5.0@ patterns & practices symposium 2010
Please wait while the Setup Wizard preparesto guide you through the installation
Context
Reusable components are important− Address common enterprise development
challenges consistently across applications Application Blocks are a form factor for reusable components
− Reusable, testable, extensible and modifiable source code− + docs, hands-on labs
Enterprise Library is a set of general purpose application blocks− Not specific to any one application type or architectural style
Can be used as-is or as a starting point for your own libraries or frameworks
2
YOU SIMPLY CANNOT AFFORD NOT TO REUSE!
WHEN IT COMES TO CODE WRITING, LESS IS MORE!
EntLib Design Goals
Consistency (Логическая последовательность)− Blocks are written with and used in common patterns
Extensibility (Расширяемость)− Pluggable extension points
Ease of use (Простота эксплуатации)− Config tool, tons of docs, simple interfaces, labs, webcasts
Integration (Интеграционная слаженность)− Work well together or separately
EntLib 4.x
Caching
Security
Data Access
Logging
Exception
Handling
Plug-in
Config
Helpers
& Design
Instrumen-
tation
Object
Builder2
Cryptography
CorePolicy
Injecti
on
Validation
Unity DI
Unity Exte
nsions
Client A
pp
Functional blocks Common Infrastructure
Structural/wiring blocks
Security
Data Access
Cryptography
Validation
Logging
Caching ExceptionHandling
Unity
Config Instrumen-tation
PolicyInjection
Enterprise Library – Conceptual Architecture
.NET 4.0 / VS 2010
Binaries– Signed– Target .NET 3.5 SP1– Work unchanged in .NET 4.0 projects
Source– VS 2008 sln/proj targeting 3.5 SP1– VS 2010 sln/proj targeting 4.0
Config tool– Fully integrated editor in VS 2008– Launcher from VS 2010 (like WCF config tool)
Config Experience
New config tool IntelliSense in XML editor Programmatic config support New configuration sources
Config Tool Stories
Usability: Improve intuitiveness & learnability
Simplicity: Reduce the number of design time assemblies
Extensibility: Simplify the way config for custom handlers/providers/blocks can be plugged into the config tool
Fluent Configuration Interface
Motivation:– Customer requested a better way to configure EntLib
programmatically– Make our own test cases more readable
Ref: Martin Fowler, Eric Evans. http://martinfowler.com/bliki/FluentInterface.html
Hierarchical / Redirected config
Use a non-default config store Split config into multiple physical files Combine them at runtime Allows master + override style of config
– Runtime version of environmental overrides
Logging Block 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:
11.76 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
upto 20%global
improvement
Higher Performing Logging – Preliminary Results
Formatter responsible for ~50% of the execution time Improvements
45% local improvement
53% local improvement
N=1M
Processing Results Data Access 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?
Introducing Data Accessors
Basic idea:– Instead of operating on data readers and data records that you get from
a query, get back an IEnumerable<T>– Now we can do LINQ to Objects magic
Accessors– provide a higher level abstraction that combines the command,
input mapping, output mapping, and result set management into a single object.
Note: Accessors are easily injectable
Async DAAB
− Database API addition− Follows classic Begin/End async pattern
NonQuery Scalar Reader XmlReader (SQL Server only)
− Not supported on all databases
Async Data Access
var db =
EnterpriseLibraryContainer.Current.GetInstance<Database>();
if(db.SupportsAsync) { db.BeginExecuteScalar("Get Top Ten Products", CompletionMethod);}
public void CompletionMethod(IAsyncResult async){ int count = (int)db.EndExecuteScalar(async); ...}
Policy Injection Application Block Goals
Separate cross-cutting concerns from business logic− Use interception and injection to apply policies at runtime− Provide a declarative way of specifying which policies are applied where− Define policies using configuration or attributes
Leverage other application blocks to implement common cross-cutting concerns − Validation, Logging, Authorization, Exception Handling, Caching,
Performance Counters Provide flexibility in interception mechanisms Aspect-Oriented Programming (AOP )
Learnability
With contributions by Nicolas Botto, Bob Brumfield, Grigori Melnik,Erik Renaud, Fernando Simonazzi, Chris Tavares
Key Takeaways
Reuse for the win! Improving user experience Simpler, more consistent code base Simpler to configure and use Better support for DI-style of development Focus on testability and maintainability
Engage with us!
Call for Action1. New to EntLib:
1. Start with reading the Dev Guide
2. Download Hands-on labs (5.0)
3. Play!
2. Seasoned EntLib user:1. Evaluate v5.02. Read Migration guide3. Experiment with migration4. Provide feedback!5. Tell your story
Resources Released Enterprise Library and related resources:
− msdn.microsoft.com/entlib Discussions, learning resources and support:
− entlib.codeplex.com− unity.codeplex.com
Enterprise Library Community Extensions:− entlibcontrib.codeplex.com
patterns & practices dev center− msdn.microsoft.com/practices
Grigori’s contacts:− [email protected]
− blogs.msdn.com/agile− @gmelnik