Available:*
Library | Item Barcode | Call Number | Material Type | Item Category 1 | Status |
---|---|---|---|---|---|
Searching... | 30000010319104 | QA76.64 G845 2013 | Open Access Book | Book | Searching... |
On Order
Summary
Summary
Summary
AOP in .NET introduces aspect-oriented programming to .NET developers and provides practical guidance on how to get the most benefit from this technique in your everyday coding. The book's many examples concentrate on modularizing non-functional requirements that often sprawl throughout object-oriented projects. Even if you've never tried AOP before, you'll appreciate the straightforward introduction using familiar C#-based examples. AOP tools for .NET have now reached the level of practical maturity Java developers have relied on for many years, and you'll explore the leading options, PostSharp, and Castle DynamicProxy.
About the Technology
Core concerns that cut across all parts of your application, such as logging or authorization, are difficult to maintain independently. In aspect-oriented programming (AOP) you isolate these cross-cutting concerns into their own classes, disentangling them from business logic. Mature AOP tools like PostSharp and Castle DynamicProxy now offer .NET developers the level of support Java coders have relied on for years.
About this Book
AOP in .NET introduces aspect-oriented programming and provides guidance on how to get the most practical benefit from this technique. The book's many examples concentrate on modularizing non-functional requirements that often sprawl throughout object-oriented projects. You'll appreciate its straightforward introduction using familiar C#-based examples.
This book requires no prior experience with AOP. Readers should know C# or another OO language.
What's Inside
Clear and simple introduction to AOP Maximum benefit with minimal theory PostSharp and Castle DynamicProxyPurchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.
About the Author
Matthew D. Groves is a developer with over ten years of professional experience working with C#, ASP.NET, JavaScript, and PHP.
Table of Contents
PART 1 GETTING STARTED WITH AOP Introducing AOP Acme Car Rental PART 2 THE FUNDAMENTALSOF AOP Call this instead: intercepting methods Before and after: boundary aspects Get this instead: intercepting locations Unit testing aspects PART 3 ADVANCED AOP CONCEPTS AOP implementation types Using AOP as an architectural tool Aspect composition: example and executionAuthor Notes
Matthew D. Groves is a developer with over ten years of professional experience working with C#, ASP.NET, JavaScript, and PHP.
Table of Contents
Foreword | p. xiii |
Preface | p. xv |
Acknowledgments | p. xvii |
About this book | p. xix |
Part 1 Getting Started With AOP | p. 1 |
1 Introducing AOP | p. 3 |
1.1 What is AOP? | p. 4 |
Features | p. 4 |
Benefits | p. 8 |
AOP in your daily life | p. 13 |
1.2 Hello, World | p. 14 |
1.3 Summary | p. 19 |
2 Acme Car Rental | p. 21 |
2.1 Start a new project | p. 22 |
Business requirements | p. 23 |
Necessary nonfunctional requirements | p. 24 |
2.2 Life without AOP | p. 24 |
Write the business logic | p. 25 |
Testing the business logic | p. 28 |
Add logging | p. 29 |
Introducing defensive programming | p. 31 |
Working with transactions and retries | p. 32 |
Handling exceptions | p. 35 |
Refactor without AOP | p. 38 |
2.3 The cost of change | p. 43 |
Requirements will change | p. 43 |
Small versus large projects | p. 43 |
Signature changes | p. 44 |
Working on a learn | p. 45 |
2.4 Refactor with AOP | p. 45 |
Start simple and isolate the logging | p. 45 |
Refactor defensive programming | p. 47 |
Creating an aspect for transactions and retries | p. 49 |
Put exception handling into its own class | p. 50 |
2.5 Summary | p. 52 |
Part 2 The Fundamentals of AOP | p. 53 |
3 Call this instead: intercepting methods | p. 55 |
3.1 Method interception | p. 56 |
PostSharp method interception | p. 57 |
Castle DynamicProxy method interception | p. 60 |
3.2 Real-world example: data transactions | p. 63 |
Ensuring data integrity with begin and commit | p. 63 |
When transactions go bad: rollback | p. 67 |
When all else fails, retry | p. 67 |
3.3 Real-world example: threading | p. 70 |
The basics of.NET threading | p. 70 |
UI threads and worker threads | p. 71 |
Declarative threading with AOP | p. 74 |
3.4 Summary | p. 77 |
4 A Before and after: boundary aspects | p. 79 |
4.1 Boundary aspects | p. 80 |
PostSharp method bounding | p. 80 |
Method boundaries versus method interception | p. 83 |
ASP.NET HttpModule bounding | p. 88 |
4.2 Real-world example: detecting mobile users | p. 92 |
Offer a link to an application | p. 93 |
Don't be a pest | p. 99 |
4.3 Real-world example: caching | p. 100 |
ASP.NET Cache | p. 102 |
An application that could benefit from caching | p. 103 |
Caching a result | p. 108 |
Retrieving from the cache | p. 110 |
A more robust cache key | p. 113 |
4.4 Summary | p. 114 |
5 Get this instead: intercepting locations | p. 115 |
5.1 Location interception | p. 116 |
Fields and properties in .NET | p. 116 |
PostSharp location interception | p. 118 |
5.2 Real-world example: lazy loading | p. 119 |
Lazy loading approaches in .NET | p. 120 |
Implementing lazy loading with AOP | p. 121 |
What about lazy-loading fields? | p. 124 |
5.3 Real-world example: INotifyPropertyChanged | p. 128 |
Using INotifyPropertyChanged in a desktop application | p. 128 |
Problems and constraints with INotifyPiopertyChanged | p. 132 |
Reducing boilerplate with AOP | p. 134 |
5.4 Summary | p. 138 |
6 Unit testing aspects | p. 141 |
6.1 Writing tests with NUnit | p. 142 |
Writing and running NUnit tests | p. 142 |
Testing strategies for aspects | p. 145 |
6.2 Castle DynamicProxy testing | p. 147 |
Testing an interceptor | p. 147 |
Injecting dependencies | p. 149 |
6.3 PostSharp testing | p. 156 |
Unit testing a PostSharp aspect | p. 157 |
Injecting dependencies | p. 158 |
Problems with PostSharp and testing | p. 162 |
6.4 Summary | p. 168 |
Part 3 Advanced AOP Concepts | p. 169 |
7 AOP implementation types | p. 171 |
7.1 How does AOP work? | p. 172 |
7.2 Runtime weaving | p. 172 |
Proxy pattern revisited | p. 173 |
Dynamic proxies | p. 176 |
7.3 Compile-time weaving | p. 183 |
Postcompiling | p. 184 |
Before and after | p. 184 |
7.4 Runtime versus compile-time weaving | p. 188 |
Pros of runtime weaving | p. 189 |
Pros of compile-time weaving | p. 189 |
7.5 Summary | p. 190 |
8 Using AOP as an architectural tool | p. 191 |
8.1 Compile-time initialization and validation | p. 192 |
Initializing at compile lime | p. 193 |
Validating the correct use of an aspect | p. 195 |
Real-world example: Threading revisited | p. 197 |
8.2 Architectural constraints | p. 199 |
Enforcing architecture | p. 200 |
Real-world example: NHibernate and virtual | p. 203 |
8.3 Multicasting | p. 205 |
At the class level | p. 206 |
At the assembly level | p. 210 |
8.4 Summary | p. 211 |
9 Aspect composition: example and execution | p. 213 |
9.1 Using multiple aspects | p. 214 |
9.2 Aspect roles with PostSharp | p. 215 |
PostSharp aspect roles | p. 217 |
Role dependencies | p. 217 |
9.3 Composing aspects with DynamicProxy | p. 219 |
Ordering aspects | p. 219 |
Reducing repetition with custom conventions | p. 222 |
9.4 Real-world example: caching and authorization | p. 224 |
Application architecture | p. 225 |
PostSharp | p. 232 |
Castle DynamicProxy | p. 236 |
9.5 Summary | p. 241 |
Appendix A Ecosystem of .NETAOP tools | p. 243 |
Appendix B NuGet basics | p. 257 |
Index | p. 265 |