Exploring New Features in WCF

To a distributed object veteran, WCF might look like yet another distributed technology. WCF has taken a lot of features from the existing distributed stack but also extends the existing features and defines new boundaries. We'll now discuss some of the new features in WCF.

Developer Productivity

WCF increases a developer's productivity in several ways by simplifying the development of service-oriented applications. Previously, developers were forced to learn different APIs for building distributed components. It cannot be denied that developers who are good at building service components might not be as efficient at building remote components using .NET Remoting. Creating custom solutions that require the functionality of two or more distributed technologies has always raised butterflies in the bellies of developers and architects.

WCF has a simple and unified programming model that has the potential to create applications with diverse requirements. WCF is built from the ground up to support the features of service orientation. One of the best aspects of WCF is that developers using existing technologies will find their favorite features in it, and all developers will benefit from the consistent architecture. The WCF support of the declarative and imperative programming model will make you write less code, which offers the likelihood of fewer errors. An application requiring hundreds to thousands lines of code prior to WCF can now be accomplished in few lines of code.

Attribute-Based Development

WCF is a message-plumbing engine and has a simple, clear, and flexible programming model that sits at the top of this message engine. The programming model provides different ways to leverage the message engine. You can use the classes to directly write code similar to other distributed applications such as DCOM. You also get the opportunity to use configuration files that can be changed at runtime. The simplest and easiest way is WCF's support for the attribute-based programming model. One of the main intentions of the SOA is to separate the application code from the messaging infrastructure. The developer specifies infrastructure requirements declaratively by decorating the service class with custom attributes but does not actually write any infrastructure code.

In simple terms, you can think of an attribute as a simple string or annotation. Attributes are just declarative tags that, when applied to classes, methods, properties, and so on, provide viable information about behavior to the CLR and are the way to add metadata to the runtime. You can view metadata through any of the metadata-reading tools such as ILDASM. Attributes have been part of .NET since its beta releases, but the power of attributes has never been exploded in the wild jargon of the enterprise world. In WCF, attributes are central to the programming model and are treated as first-class citizens. This attribute-based model is not a new concept in WCF but has its roots in Enterprise Services and web services. Microsoft used the attribute-based programming model in Microsoft Transaction Server (MTS). If you have created a web service using .NET, you are already familiar with the [WebMethods] attribute. WCF has extended the immense support of declarative programming in the message engine. So, whenever you need transactional support or some security, you just need to decorate the service class with the specific attributes, and the messaging engine will provide you with the necessary infrastructure to achieve your desired result. This offers a real advantage to developers who can now concentrate on the real logic and then decorate the class and methods with the appropriate attribute to get the necessary infrastructure.

Attribute-based programming is simply the best way to get things done with the WCF engine, but you should also not forget the power of the object model of WCF. Depending on your application requirements, you can fulfill different application needs through minor configuration file changes. You can use an extensible API programming model for instances where you need finer-grained control. Actually, most of the attributes in WCF are shortcuts for imperative tasks you can do via APIs. Which method you use depends on your requirements.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset