The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

jameswiseman (13) [Avatar] Offline
#1
Towards the end of the PDF 'What is Aspect-Oriented Programming?' you touch very briefly on aternatives to AOP for implementing cross-cutting concerns. With specific reference to
- Functional programming techniques in C#
- Use of decorator/proxy pattern by hand
- T4 Templating

Although the book is principally about AOP, the subject of cross-cutting concerns is integral to it.

I think it would be good to expand on these a little in the book, and even mention scenarios where they might be relevant. A valuable part of the education of AOP would be about when to use it, and when to favour alternatives.
matthew.groves (46) [Avatar] Offline
#2
Re: Alternatives to AOP for implementing cross-cutting concerns
James,

I think you raise an interesting question, and since I've come up with a mini blog post here to discuss it, I'll keep your feedback in mind and try to revisit code generation and/or functional programming techniques. But here's my mini blog post:



The book definitely explores the use of the decorator/proxy pattern in later chapters. The pattern is not strictly AOP: it's a general purpose design pattern that can be used to implement cross-cutting concerns in a loosely coupled way, albeit in a manual and repetitive way; however I do think it merits consideration, and it's certainly a good starting point to understanding AOP.



For code generation, T4 templating is only one type of code generation: there are many others that work in different ways, and I doubt I could do them all justice while only focusing on cross-cutting concerns.



And finally, functional programming techniques: one technique I've seen that approximates AOP is to put the body of a method into a Func/Action and pass it to another object that performs the cross-cutting concerns. This can be a useful technique, but for multiple and wide-spread cross-cutting concerns, I don't think it provides much of an advantage as compared to, say, using normal dependency injection (without interceptors) for cross-cutting concerns: it's less powerful, and tangling and scattering still occurs.



In any case, there are a couple good books from Manning that touch on these topics that I would recommend: Metaprogramming in .NET by Kevin Hazzard and Jason Bock, and Real-World Functional Programming by Jon Skeet and Tomas Petricek (which talks about both C# and F#).



Thanks,



Matt