Archive

The 'Week of PostSharp' is a joint promotion with Manning Publications where we highlight a new book each day that is special to us and hand-picked by the PostSharp team – with a small introduction about how it connects to what we are doing. We also collaborated with Manning to select a second book for each day of the week, and will be offering our choices at a 50% discount on their site! You can even read excerpts from some of the books online for free by clicking on the links below.

We hope you enjoy the deals! We’ll be adding new posts with the daily discount code throughout the week, so stay tuned.

There are times when OOP won’t let us achieve a nice separation of concerns (assembly > namespace > class > method). Think of INotifyPropertyChanged, logging, performance monitoring, transaction handling, undo/redo, caching… Way too often, we have to duplicate tons of infrastructure code. This is why aspect-oriented programming (AOP) has been engineered. With AOP, you can encapsulate cross-cutting features into a special class called an aspect, and apply the aspect to a large number of classes or methods without actually modifying your business source code. As a result, you get rid of most of your boilerplate.

PostSharp has long been the most complete and the most popular AOP framework for .NET but PostSharp is not limited to AOP, and AOP is not limited to .NET. Today we’re recommending two books: AOP in .NET, which gives you an excellent introduction to AOP not only using PostSharp, and AspectJ in Action, whose outstanding quality makes it a must-read for anyone interested in aspect-oriented programming and offers deep insights that are directly applicable to PostSharp. You can now purchase these books with a 50% discount using the discount code pswkd2! But hurry, the offering is only valid until August 21st 12 midnight EST!

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 pswkd2

 

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 pswkd2

 

The 'Week of PostSharp' is a joint promotion with Manning Publications where we highlight a new book each day that is special to us and hand-picked by the PostSharp team – with a small introduction about how it connects to what we are doing. We also collaborated with Manning to select a second book for each day of the week, and will be offering our choices at a 50% discount on their site! You can even read excerpts from some of the books online for free by clicking on the links below.

We hope you enjoy the deals! We’ll be adding new posts with the daily discount code throughout the week, so stay tuned.

Back in the 50s, programmers had a very hard time delivering even the simplest features because they had to work at a very low level of abstraction. There was nothing as a variable, field or parameter – just registry or memory cells. After decades of advances in compiler and runtime technologies, people barely think about memory management anymore.

Today, the industry is facing the same issue with multithreading. It is the use of low-level synchronization mechanisms that causes the notorious complexity of multithreaded applications. As in the 50s, we need to raise the level of abstraction to get back into productivity. At PostSharp, we believe design patterns, such as READER-WRITER SYNCHRONIZED OBJECT or ACTOR, can give us a better model for multi-core development. That’s why we build PostSharp Threading Pattern Library: a library of ready-made implementations of multithreading design patterns that you can use in your applications, today.

Obviously, we aren’t the only one trying to improve multithreading programming. The async/await feature of C# 5.0 makes it incredibly easier to write asynchronous code, but it does not address the issue of thread safety. Functional programming does address the thread safety issue at the cost of a paradigm shift.

Learn more about these technologies in today’s books which you can now purchase with 50% discount - but hurry, the offering is valid only until August 20th, 12 midnight EST:

 

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: pswkd1

 

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: pswkd1

 

 

 

Last week, Alex Papadimoulis joined Gael Fraiteur on the PostSharp Live Webinar to talk about NuGet, the popular open-source library package manager for .NET, and show how it helps developers escape from "dependency hell" while discovering new third-party libraries.

Attendees learned:

  • how developers are successfully using NuGet;
  • why PostSharp chose NuGet for deployment management;
  • what deployment management pitfalls to watch out for; and
  • when to consider solutions like private repositories.

Watch the recording and learn how to leverage NuGet and private repositories to improve your enterprise architecture.

Q&A

Q: How do you specify dependency on a version range?

A: NuGet documentation shows how to do that: http://docs.nuget.org/docs/Reference/Versioning

Q: When you install the NuGet plugin by default it is configured to pull from the public repository. How do you prevent users from pulling packages from this public NuGet repository? Is this a specific configuration change?

A: What you have to do from a training standpoint is instruct developers to add a package source. Go to package management settings, uninclude the official package source, and add in your own corporate library. There is no good way to prevent developers from doing it themselves, so it's important to monitor your packages.config file for changes to it to ensure a bad package isn't added.

Q: How do you deal with scenarios where two packages depend on the same third package, but they depend on different versions of that third package? Visual Studio will only include one of the versions, and you will get a runtime failure.

A:This becomes tricky. NuGet attempts to add a binding redirect to mitigate the problem, but it can cause more problems than benefits. My advice is to monitor the versions that are added and that you're redirecting appropriately.

Q: Is it possible to configure NuGet for projects independently of Visual Studio solutions? What if projects appear in multiple solutions?

A: NuGet works fine if you keep your configs simple but can complex things can get a little hairy depending on your configuration. has a packages.config file, and some of the default locations for the packages file

Q: Can standard MS packages (e.g. MVC 4 bits) required by the new project dialog be routed via a private NuGet repository to make the selection / deselection of the public NuGet repository in the developer machine?

A: Yes. Select the Package Manager option in Visual Studio, where the available Package Sources are displayed, and select the source you want to use. NuGet will use whatever package source you select rather than the public source.

Q: What's the best way to enable package restore on a bulid server?

A: Package restore adds a folder to your Visual Studio solution and does all sorts of weird things with it. We recommend users not use NuGet package restore and instead have a NuGet install as part of your build server plan. We recommend this to our customers since NuGet package restore doesn't work with PostSharp. Create a build step that includes calling NuGet install before calling MS build for every file package.config you find in your source tree. It's much more reliable.