Table Of ContentPractical Aspect-Oriented Programming
Matthew D. Groves
FOREWORD BY Phil Haack
M A N N I N G
www.it-ebooks.info
AOP in .NET
www.it-ebooks.info
www.it-ebooks.info
AOP in .NET
PRACTICAL ASPECT-ORIENTED
PROGRAMMING
MATTHEW D. GROVES
MANNING
SHELTER ISLAND
www.it-ebooks.info
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 261
Shelter Island, NY 11964
Email: orders@manning.com
©2013 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.
Manning Publications Co. Development editors: Frank Pohlmann, Cynthia Kane
20 Baldwin Road Technical proofreader: Javier Lozano
PO Box 261 Copyeditor: Nancy Kotary
Shelter Island, NY 11964 Proofreader: Elizabeth Martin
Typesetter: Dottie Marsico
Cover designer: Marija Tudor
ISBN 9781617291142
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 18 17 16 15 14 13
www.it-ebooks.info
To my children Matthew and Emma
I will never grow tired of your yelling, “Daddy, Daddy!”
and tackling me when you hear the creak of my office door.
www.it-ebooks.info
www.it-ebooks.info
brief contents
PART 1 GETTING STARTED WITH AOP.......................................1
1 ■ Introducing AOP 3
2 ■ Acme Car Rental 21
PART 2 THE FUNDAMENTALSOF AOP ......................................53
3 ■ Call this instead: intercepting methods 55
4 ■ Before and after: boundary aspects 79
5 ■ Get this instead: intercepting locations 115
6 ■ Unit testing aspects 141
PART 3 ADVANCED AOP CONCEPTS.......................................169
7 ■ AOP implementation types 171
8 ■ Using AOP as an architectural tool 191
9 ■ Aspect composition: example and execution 213
vii
www.it-ebooks.info
www.it-ebooks.info
contents
foreword xiii
preface xv
acknowledgments xvii
about this book xix
PART 1 GETTING STARTED WITH AOP .......................... 1
1 Introducing AOP 3
1.1 What is AOP? 4
Features 4 ■ Benefits 8 ■ AOP in your daily life 13
1.2 Hello, World 14
1.3 Summary 19
2 Acme Car Rental 21
2.1 Start a new project 22
Business requirements 23 ■ Necessary nonfunctional
requirements 24
2.2 Life without AOP 24
Write the business logic 25 ■ Testing the business logic 28
Add logging 29 ■ Introducing defensive programming 31
Working with transactions and retries 32 ■ Handling
exceptions 35 ■ Refactor without AOP 38
ix
www.it-ebooks.info
Description: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 straigh