Never over Architected

Day and life of Software Architect Edward Chan

03
Dec 2009

WCF 4.0 - Two Features I'm excited about!

Message Pump as a Service – Routing Service

Since WCF 3.0 many developers (including Sasha and myself) needed to implement a message pump (or message router) which basically takes messages from an input channel and puts them on an output channel. This is useful for various scenarios which include:

  • Basic Message Routing
  • Protocol Bridging
  • Service Aggregation
  • Versioning

WCF 4.0 now ships with a Routing Service which fully supports message routing, thus decoupling the client from the server. This service supports:

  • Basic message routing based on a configured filter table.
  • Protocol bridging including transport conversion, SOAP version conversion etc.
  • Security decoupling and impersonation.
  • Error handling – configure alternate service endpoints in case of failure.
  • Transactions – flow transactions and control of transactional queue reads (as opposed to the destructive reads done in WCF 3.0 and 3.5 which delete the message when it is read).

Service Discovery

Discovery is the ability to publish a service’s endpoint metadata and discover services using well defined criteria. This is very useful both during design time to find available service and during runtime to allow reduced configurations, location agility and dynamic/self-healing applications. This service is an implementation of WS-Discovery and is standard interoperable.

Discovery comes in a couple of modes:

  • Ad-hoc Discovery – No central discovery server, and discovery is performed via multicast messages.
  • Managed Discovery – A discovery proxy is used to facilitate discovery. This suppresses the use for multicasting, and it also allows us to expose our own service repository to all clients in a standard way.

WCF 4.0 provides a full implementation for the ad-hoc mode and all of tools and contracts for building your own custom managed discovery mechanism. “DiscoveryProxy” is the base class required for creating a discovery service.

Making a service discoverable is very simple – just add a “ServiceDescoveryBehavior” and a discovery endpoint (such as “UdpDiscoveryEndpoint”) and you’re good to go. On the client side all you have to do is use a “DynamicEndpoint” instance, use it to create an instance of your service and you’re done!

Adding announcements to services is just an easy – all you have to do is add an announcement endpoint and that’s it. This gives you a very impressive ability for the client to respond to service availability on the network.

These are the two main features in WCF 4.0 I'm super excited about. Back in the day (last year) I had to hand build my routing service myself, and anybody who did what I did knows how much of a pain it can be.

Then adding a discovery service on top of your routing service can make for a pretty mean and lean pub/sub system.

Excited to try out these new features...

Filed under  //   .NET  
24
Sep 2009

AutoMapper - Object to Object Mapping

A convention-based object-object mapper.

AutoMapper uses a fluent configuration API to define an object-object mapping strategy. AutoMapper uses a convention-based matching algorithm to match up source to destination values. Currently, AutoMapper is geared towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is better suited for serialization, communication, messaging, or simply an anti-corruption layer between the domain and application layer.

New to AutoMapper? Check out the Getting Started page first.

Check out the Roadmap to see what I'm looking at for future releases.

General Features

Flattening
Projection
Configuration Validation
Lists and Arrays
Nested Mappings
Custom Type Converters
Custom Value Resolvers
Custom Value Formatters
Null Substitution

Thanks James (@bakasan) for the tip!

Filed under  //   .NET  
24
Sep 2009

Microsoft Launch WebsiteSpark: Free Software For Web Developers

Picture 13

Moments ago Microsoft launched WebsiteSpark, a new program to provide web developers and designers free copies of Microsoft development tools, applications and server licenses for a period of three years. The program is the third and latest launch as part of the ’spark’ series of outreach and support programs designed to engage communities with new Microsoft products. The initial programs to launch were BizSpark, for startups, and DreamSpark, for students.

The WebsiteSpark program announced today provides eligible individuals or organizations with 3-year licenses of Visual Studio 2008, Expression Studio, Expression Web (also part of studio), Windows Web Server, SQL Server and DotNetPanel. To be eligible, an organization or individual developer must be in the business of building web applications or websites for others (ie. clients) and also have no more than 10 employees.

I recall as a young developer constantly bitching about the cost of development tools, which was a real barrier of entry. Microsoft bundled QBASIC with DOS, which spawned a whole generation of developers, but for those who were looking to learn further there was a real commercial barrier because of the price of good compilers and tools. Most of us ended up ripping these tools off by downloading them – which meant that we all became familiar with certain tools (like the old VC++) and then ended up getting real jobs where we would use them. Microsoft have obviously caught on and have realized that they need to lower the barrier for some parts of the market (as with academic discounts) in order to bring Microsoft tools, and in-turn platforms/servers (and services!), into development shops and to developers.

There is a broader motive here – Microsoft want to eventually sell you on the entire platform. But who cares, because frankly, their developer tools have long been the best available (queue flame war). I could never have imagined such programs coming out of Microsoft all that long ago, especially combined with support for more open source (PHP), supporting an open implementation of the entire .NET platform and executives like Scott Guthrie who are not only blogging, put publishing their email addresses so that anybody who has a problem signing up with the program can email him (it is scottgu@microsoft.com, btw).

 

Filed under  //   .NET   development  
23
Sep 2009

Web Deployment: Web.Config Transformation - An idea borrowed from SR

Over a year ago, Craig and I were up in Redmond explaining our deployment strategies to the TFS guys at Microsoft. One trick we had up our sleeves was a Web.config transformation per environment. Looks like the guys liked the idea and integrated it into Visual Studio 2010. :)

http://vishaljoshi.blogspot.com/2009/03/web-deployment-webconfig-transformation_23.html

Filed under  //   .NET   development  
23
Sep 2009
17
Sep 2009

MonoTouch: Native iPhone Apps In C#

Novell and the Mono team — the folks behind the popular OSS/alternate platform .NET and Silverlight implementations — have released MonoTouch. Using MonoTouch, programmers can write native iPhone applications using C#.

I spoke with Mono Project founder Miguel de Icaza and Joseph Hill, Mono’s product manager, about the project, the audience, the programming model and the implementation:

MonoTouch, says Hill, provides a “static compiler that turns .NET executables and libraries into native applications.” According to Icaza, this straying from the Mono norm — which relies heavily on dynamic code generation — is necessary because “the [iPhone] kernel prevents JIT compilation.”

Using C# with MonoTouch gets you garbage collection, multi-threading, and features of the 3.0 edition of the language. It’s paired with a hybrid of the .NET 2.0 and Silverlight 2.0 feature sets.

MonoTouch’s programming paradigm will feel familiar to C#/.NET developers. They’ve done the heavy lifting of creating a bridging layer that handles the translation of e.g., .NET style event handling to the CocoaTouch model. MacRuby’s HotCocoa is an analog: a thin idiomatic language layer that hides the verbosity of directly translating Objective-C methods.

In practice, this means that you can write code that looks like this:

button.touchUp += delegate {
  label.Text = "You have tapped the button";
};

A low-level programming model that let’s you direct implement the CocoaTouch APIs is available too.

One of the nifty things about MonoTouch is it’s integration with Interface Builder. You can create and use NIB files more or less as you normally would. Any outlets you create in IB will automatically be fleshed out by the SDK and available for you to use in C#.

The project supports adding MonoTouch to existing Objective-C apps. That said, of the 600 beta customers only one followed that route. This supports my hunch is that most MonoTouch developers will be .NET developers wanting to reuse their skills here.

Debugging is limited to stack traces and console write-line style logging because Apple’s debugging APIs aren’t published. That said, the stack traces include line-number granularity — sounds more usable than many of the Objective-C stack traces I’ve debugged.

MonoTouch is a paid license product. A free, try-first version should be out this week.

I’ll get my hands dirty with MonoTouch and write about the experience here.

 

Filed under  //   .NET   iphone