Last week, Donald Belcham joined Gael Fraiteur on the PostSharp Live Webinar to talk about one of the largest challenges faced on Brownfield projects: adding project-wide functionality to a codebase.

Attendees learned:

  • Options for adding non-functional requirements
  • Areas of risk when adding non-functional requirements
  • Use of IL Weaving to add non-functional requirements
  • IL Weaving granularity

Watch the recording and learn the techniques and tools you can use to add functionality to brownfield codebases.

Q&A

Q: In a greenfield development scenario that is already using IoC, are there any advantages to using the existing container to implement AOP features vs. using IL weaving?

A: The primary benefit of IL weaving is the types of aspects you can create. With Interception you can only wrap public virtual methods. IL weaving allows you to add aspects to events, field variables, property getters/setters, methods, etc.

Q: I have a brownfield project that's 20 years old and was developed using ASP, VB6.0, Windows Services and JavaScript. How do I migrate it to green field?

A: A good place to start is the case study we wrote with the team at Mitchell International, who faced a similar scenario. It demonstrates how they used PostSharp to build several aspects to facilitate integration between their new and old applications. The project was daunting but by adding Activity Logging, Exception Handling, Performance Counters, Thread Dispatching and Data Sync functionality project-wide the team saved from having to write thousands of lines of code.

Q: I used PostSharp OnMethodBoundaryAspect and TransactionScope to replace transaction management in a very large brownfield data access project (SQL transactions). There was a lot of duplicate code removed and all done successfully now - it's much cleaner. The only issue was around code where a rollback transaction was forced (not rolled back implicitly as the result of an exception). Is there a more comprehensive example (beyond the basic TransactionScope enter, exit, dispose, complete) of how other people have gone about this?

A: You could have a static method InvalidateTransaction that would set a thread-static boolean field. In the OnEntry advice, check that field to decide whether the transaction should be committed or rolled back.

Q: How will Roslyn change the AOP landscape in .NET languages like C# and VB?

A: Good things would happen if the compilation pipeline could be made customizable. It could improve Intellisense and compiler support for aspects that introduce new interface implementations, methods, or even full types. Unfortunately, there's no indication this will happen any time soon. Except for these possibilities, Roslyn is not going to be a game changer.

The 'Week of PostSharp' is a joint promotion with Manning Publications where we highlight important books from their catalog each day and show how they connect to what our team is doing.

If you came late to our posts this week and missed your chance at a deep discount on one of the featured books, today is your lucky day!

To wrap up the week, we're offering a discount on every book title mentioned during the Week of Postsharp. Purchase any of the books highlighted in this post with a 50% discount - but hurry, the offering is valid only until August 26th, 12 midnight EST.

Enjoy the deals!

Windows Store App Development introduces the Windows 8.x app model to readers familiar with traditional desktop development. You'll explore dozens of carefully crafted examples as you master Windows features, the Windows Runtime, and the best practices of app design. Along the way, you'll pick up tips for deploying apps, including selling through the Windows Store.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the following code: pswkd7

 

Windows 8 Apps with HTML5 and JavaScript provides a comprehensive tutorial for web developers who want to build Windows 8 apps using development tools familiar to them. It's also a great way for a C#/XAML developer to add a few new tools to his or her belt. This practical book provides expert guidance on application design, so you'll learn the emerging patterns and practices for making apps that will work equally well on phones, tablets, and standard screens. Along the way you'll pick up tips for monetizing your apps and deploying to the Windows Store.

Download Free Chapter (PDF)   |  Purchase with 50% discount using the following code: pswkd7

 

Brownfield Application Development in .NET starts by laying out the unique characteristics of brownfield apps—both negative and positive. It then systematically explores how you can employ well-established techniques like continuous integration, version control, and automated testing, even if they weren't part of the original dev process. You'll learn techniques to identify logical layers and tease apart dependencies to effectively separate concerns for improved flexibility. This practical book will help you improve not only your application's maintainability, but also the team's confidence in the project.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the following code: pswkd7

 

Continuous Integration in .NET shows you how to reimagine your development strategies by creating a consistent continuous integration process. You'll use Visual Studio along with tools like Subversion, MSBuild, TFS, TeamCity, NUnit, and Selenium. And because CI is as much about the culture of your shop as the tooling, this book provides clear guidelines for starting and maintaining projects, along with metrics for measuring project success.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the following code: pswkd7

 

DSLs in Boo shows you how to design, extend, and evolve DSLs for .NET by focusing on approaches and patterns. You learn to define an app in terms that match the domain, and to use Boo to build DSLs that generate efficient executables. And you won't deal with the awkward XML-laden syntax many DSLs require. The book concentrates on writing internal (textual) DSLs that allow easy extensibility of the application and framework. And if you don't know Boo, don't worry—you'll learn right here all the techniques you need.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the code pswkd7

 

ASP.NET MVC 4 in Action is a hands-on guide that shows you how to apply ASP.NET MVC effectively. After a high-speed ramp up, this thoroughly revised new edition explores each key topic with a self-contained example so you can jump right to the parts you need. Based on thousands of hours of real-world experience, the authors show you valuable high-end techniques you won't find anywhere else. Written for developers, the book arms you with the next-level skills and practical guidance to create compelling web applications. You need some knowledge of ASP.NET and C#, but no prior ASP.NET MVC experience is assumed.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the following discount code: pswkd7

 

ASP.NET in Practice distills over 100 practical ASP.NET techniques from the experience of a team of MVPs, and puts them right at your fingertips. The techniques are tested and selected for their usefulness, and they are all presented in a simple problem-solution-discussion format. You'll discover methods for key new subjects like data integration with Entity Framework and ASP.NET MVC. Along the way, you'll also find ways to make your applications fast and secure.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the following discount code: pswkd7

 

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.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the discount code pswkd7

 

AspectJ in Action, Second Edition is a fully updated, major revision of Ramnivas Laddad's best-selling first edition. It's a hands-on guide for Java developers. After introducing the core principles of AOP, it shows you how to create reusable solutions using AspectJ 6 and Spring 3. You'll master key features including annotation-based syntax, load-time weaver, annotation-based crosscutting, and Spring-AspectJ integration. Building on familiar technologies such as JDBC, Hibernate, JPA, Spring Security, Spring MVC, and Swing, you'll apply AOP to common problems encountered in enterprise applications.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the code pswkd7

 

C# in Depth, Third Edition updates the best selling second edition to cover the new features of C# 5, including the challenges of writing maintainable asynchronous code. It preserves the uniquely-insightful look into the tricky areas and dusty corners of C# that only expert Jon Skeet can provide. In this third edition, you'll see the subtleties of C# programming in action, learning how to work with high-value features that you'll be glad to have in your toolkit. The book helps readers avoid hidden pitfalls of C# programming by providing crystal-clear explanations of "behind the scenes" issues.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the following code: pswkd7

 

The book Real-World Functional Programming teaches the ideas and techniques of functional programming applied to real-world problems. You'll see how the functional way of thinking changes the game for .NET developers. Then, you'll tackle common issues using a functional approach. The book will also teach you the basics of the F# language and extend your C# skills into the functional domain. No prior experience with functional programming or F# is required.

Download Free Chapter (PDF)   |   Purchase with 50% discount using the following code: pswkd7

 

 

 

Next week’s guest on the PostSharp Live Webinar is Donald Belcham, a senior software developer, independent contractor, trainer, speaker and PostSharp MVP.

On Thursday, August 29th (09:00 PT, 12:00 ET, 16:00 GMT) Donald will speak about one of the largest challenges faced on Brownfield projects: adding project-wide functionality to a codebase.

The difficulty comes from the tangled nature of Brownfield codebases. Finding all the locations where the functionality is needed is one thing. The bigger issue is, how do you add the new functionality without altering existing APIs or, worse, introducing defects?

This webinar will look at the techniques and tools that you can use to add functionality to less than inviting codebases.

Attendees will learn:

  • Options for adding non-functional requirements
  • Areas of risk when adding non-functional requirements
  • Use of IL Weaving to add non-functional requirements
  • IL Weaving granularity

If you’ve ever wanted to learn how to better tame brownfield codebases using AOP be sure to sign-up for the next PostSharp live webinar.

Seats are limited so reserve your spot today

See you there!

-Britt

p.s. – Donald and Kyle Baley’s excellent Brownfield Application Development in .NET book can be purchased with a 50% discount until August 24th, 12 midnight EST, using the code: pswkd5