Why PostSharp

The #1 pattern-aware extension for C# and VB

The problem: existing compilers don't support patterns

Conventional programming languages miss a concept of pattern, therefore patterns are hand-coded and result in boilerplate code, with the following impact:

  1. High development effort
  2. Poor quality software
  3. Difficulty to add/modify functionality
  4. Slow ramp-up of new team members
1

High development effort

Large codebases. Some application features require a large amount of repetitive code (boilerplate) when implemented with existing mainstream compiler technologies.

Reinventing the wheel. Solutions to problems like INotifyPropertyChanged are always being reinvented because there is no reusable options within conventional programming languages.

3

Difficulty to add/modify functionality

Unreadable code that’s difficult to maintain. Business code is often littered with low-level non-functional requirements and is more difficult to understand and maintain, especially when the initial developer left.

Strong coupling. Poor problem decomposition results in duplicate code and strong coupling making it very difficult to change the implementation of features like logging, exception handling or INotifyPropertyChanged because it is often scattered among thousands of files.

2

Poor quality software

High number of defects. Every line of code has a possibility of defect, but code that stems from copy-paste programming is more likely than other to be buggy because subtle differences are often overlooked.

Multi-threading issues. Object-oriented programming does not deliver much value when it comes to developing multi-threaded applications since it addresses issues at a low level of abstraction with locks, events or interlocked accesses that can easily result in deadlocks or random data races.

Lack of robustness. Enterprise-grade features such as exception handling or caching are often deliberately omitted because of the high amount of source code they imply, unintentionally forbidden in some parts of the applications, simply left untested and unreliable.

4

Slow ramp-up of new team members

Too much knowledge required. When new team members come to work on a specific feature, they often must first learn about caching, threading and other highly technical issues before being able to contribute to the business value: an example of bad division of labor.

Long feedback loops. Even with small development teams, common patterns like diagnostics, logging, threading, INotifyPropertyChanged and undo/redo can be handled differently by each developer. Architects need to make sure new team members understand and follow the internal design standards and have to spend more time on manual code reviews--delaying progress while new team members wait to get feedback from code review.

The solution: pattern-aware compiler extensions

Pattern-aware programming extends conventional object-oriented programming with a concept of pattern, which becomes a first-class element of the programming language.

Most mainstream programming languages can be extended with a concept of pattern, avoiding the cost of rewriting applications in a new language.

Because patterns are supported by the compiler extension (100% compatible with your existing compiler), they do not need to be manually implemented as boilerplate code. Features such as INotifyPropertyChanged, logging, transactions are implemented in a cleaner, more concise way, making development and maintenance much easier.

1

Helps you stop writing boilerplate code and deliver faster

Fewer lines of code means fewer hours of work. Patterns are repetitive, with little or no decision left to the developer. However, repetition is exactly what computers are good at. Let the compiler do the repetitive work and save development time and costs immediately.

3

Makes it easier to add/modify functionality after the first release

Cleaner and shorter code is easier to understand. After the initial release, too much development time is spent reading and analyzing source code, especially if the initial developer left. With minimized boilerplate code, developers can easily focus on business logic and spend much less time trying to understanding the code.

Better architecture is future-proof. Using a pattern-aware compiler, features like logging, exception handling or transactions are no longer scattered among thousands of files but they are defined in one place, making it much easier and fast to modify when necessary.

2

Helps you build more reliable software

Cleaner code means fewer defects. With a pattern-aware compiler eliminating the boilerplate, your code becomes easier to read, understand and modify, and contains fewer defects.

Reliability becomes much more affordable. Because they no longer require so much manual coding, reliability features such as caching or exception handling are much easier and cheaper to implement, so you can spend your extra time building a more robust app.

4

Helps new members contribute quicker

Achieve a better division of labor. Using a pattern-aware compiler makes the introduction of new or junior team members less onerous since they can focus on simpler, more business logic-oriented tasks rather than having to waste so much time learning complex architectural structures.

Implement a tighter feedback loop. A pattern-aware compiler can validate that hand-written code respects a pattern or a model, and it can detect bugs at build time instead of during code reviews, testing, or in production.

PostSharp: the #1 pattern-aware extension for C# and VB

PostSharp is the #1 best-selling pattern-aware extension to C#/VB. It adds a concept of pattern to the languages, resulting in a dramatic reduction of boilerplate code, lower development and maintenance costs and fewer errors.

With PostSharp you can:

  1. Get more productive in minutes with ready-made pattern implementations
  2. Automate more complex patterns and remove more boilerplate
  3. Build thread-safe apps - without a PhD
  4. Maintain your existing codebase in C# or Visual Basic
  5. Benefit from much better run-time performance
1

Get more productive in minutes with ready-made pattern implementations

INotifyPropertyChanged Pattern. Automates the implementation of INotifyPropertyChanged and automatically raises notifications for you. Eliminates all the repetition and lets you go from three lines of code per property to one attribute per base class... so you will never forget to raise a property change notification again.

Undo/Redo Pattern. Makes the implementation of the end-users most-wanted features easy and affordable by recording changes at model level. You can deliver the familiar Undo/Redo experience to your users without getting stuck writing large amounts of code.

Code Contracts. Provides custom-attribute-based validation for valid URLs, email addresses, positive numbers or not-null values and many more, right out of the box. This enables you to protect your code from invalid inputs with custom attributes.

Logging. Adds comprehensive logging in a few clicks – without impact on your source code – and lets you remove it just as quickly. Supports most popular back-ends, including log4net, NLog, Enterprise Library, System Console, System Diagnostics. You can trace everything you need in minutes without cluttering your code.

4

Maintain your existing codebase in C# and VB

Despite the hype around functional programming languages, C#/VB and .NET remain an excellent platform for enterprise development. PostSharp respects your technology assets and will work incrementally with your existing code base – there is NO need for a full rewrite or redesign.

Design neutrality. Unlike alternatives, PostSharp takes minimal assumptions on your code. It does not force you to adopt any specific architecture or threading model. You can add aspects to anything, not just interface/virtual methods. Plus, it is fully orthogonal from dependency injection. You don’t have to dissect your application into components and interfaces in order to use PostSharp.

Plain C# and VB. PostSharp provides advanced features present in F#, Scala, Nemerle, Python, Ruby or JavaScript, but your code is still 100% C# and VB, and it is still compiled by the proved Microsoft compilers.

Cross-platform. PostSharp supports the .NET Framework, Windows Phone, WinRT, Xamarin and Portable Class Libraries.

Standard skillset. No complex API. Reuse what you already know from C# and System.Reflection.

2

Automate more complex patterns and remove more boilerplate

PostSharp Aspect Framework. Hands down the most robust and exhaustive implementation of aspect-oriented programming for .NET. It is the most powerful toolset available to automate your own patterns.

Largest choice of possible transformations. Includes decoration of methods, iterators and async state machines, interception of methods, events or properties, introduction of interfaces, methods, events, properties, custom attributes or resources, and more.

Dynamic aspect/advice providers. Automatically add aspects to code according to rules written programmatically in C# or VB so your codebase is not cluttered with custom attributes.

Aspect inheritance. Apply an aspect to a base class and have it automatically applied to all derived classes. Ensures that all derived classes using this aspect's logic is correct.

Architecture framework. Validates hand-written source code against your own custom pattern guidelines. It then express the rules in C# using the familiar System.Reflection API, extended with features commonly found in decompilers, such as “find usage”, and more.

5

Benefit from much better run-time performance

Start-up latency, execution speed and memory consumption matter. Whether you’re building a mobile app or a back-end server, PostSharp delivers exceptional run-time performance.

Build-time code generation. Unlike proxy-based solutions, PostSharp modifies your code at build time. It also allows for much more powerful enhancements that produces dramatically faster applications.

No reflection. PostSharp does not rely on reflection at run-time. The only code that is executed is what you can see with a decompiler.

Build-time initialization. Many patterns make decisions based on the shape of the code which they are applied. With PostSharp, you can analyze the target code at build-time and store the decisions into serializable fields. At runtime, the aspects will be deserialized and you won’t need to analyze the code at run-time using reflection.

3

Build thread-safe apps – without a PhD

Starting new threads and tasks in .NET languages is simple, but ensuring that objects are thread-safe is not with mainstream programming languages. That’s why PostSharp extends C# and VB with thread-safety features.

Threading models. Threading models are design patterns that guarantee your code executes safely even when used from multiple threads. Unlike working directly with locks and other low-level threading primitives, threading models simplifies your code and reduces the number of defects and development and maintenance costs – without having to have expertise in multi-threading.

Model validation. When your code uses threading models, PostSharp catches most defects during build or during single-threaded test coverage.

Thread dispatching. Causes the execution of a method to be dispatched to the UI thread or to a background thread. Much easier than using nested anonymous methods.

Deadlock detection. Causes an easy-to-diagnose exception in case of deadlock instead of allowing the application to freeze and create user’s frustration.

Give yourself the tools to win over boilerplate.

Download PostSharp

When installing PostSharp, you can choose between a 45-day trial of PostSharp Ultimate or the free but feature-limited PostSharp Express.

Understand how it works

Wondering how it is possible to customize the C# and VB languages? There's no magic, just smart use of fully-supported standards.

Watch case studies

See how long-term customers achieve cut development and maintenance costs thanks to PostSharp.