The Zen of Volta

Tier Splitting

This article was originally published by developmentor
DevelopMentor

TierSplitting is a far more radical refactor than the Async one. In this case you annotate types and the Volta compiler rewrites the IL to distribute the assemblies into multiple tiers. This allows you to concentrate on developing the functionality of the application and decide about where things are deployed later in the development cycle.

With Volta, the developer determines which classes run on the server and which ones will run on the client through a new option in the Refactor menu:

Refactor by Tier splitting

This adds the [RunAt(“someName”)] attribute and sets up the project to run a test web server to host the server part of the application:

[RunAt("Server")]
class QuoteServer {
    //...
}
Here "Server" is a reference to a URL in the app.config file that corresponds to the location where this code will live. You can also use the [RunAtOrigin] attribute in web applications to indicate that the code should run on the web server hosting the application. With client/server applications, this option is not available since there isn’t a defined “origin” server.

How does Volta pull off this tier splitting magic? First, Volta rewrites the class into two separate implementations. The client-side implementation becomes a proxy – it looks and acts like the real QuoteServer, but in reality is going to send a request to the server to perform the work. The server side ends up with the basic QuoteServer class with some additions to manage state.
The Volta compiler also creates a __TierSplit.aspx web page that is used as the endpoint for the server code. This becomes evident when we run a Volta application – it creates a Volta test server icon in the tray that is used to display the diagnostics window:

 

logged requests

Each method and property access from the client portion (classes not decorated by RunAt attributes) to classes running on the server(s) will cause a server round-trip. As you can see, the effect is very seamless and easy to achieve with this preview.

As easy as this is, I do have some reservations about the current implementation of tier-splitting, which rather than spend more time repeating here I’ll just direct you to the blog posts, here and here.
 

Conclusion

All in all, I think Volta is a very exciting technology with some real potential benefits for developers. The more time developers can concentrate on solving the real business problems rather than writing the plumbing the better. I also think Volta has to be seen for what it is at the moment – a technology preview. This is not a finished product, but an idea with a bunch of implementations that are applicable to different scenarios; some of which are very compelling. That said, it clearly has a long way to go before whatever Volta becomes is released. Now is a great time to pull down the bits and experiment with how you could conceptually use this technology. Send feedback to the team – this is exactly why they released the preview. We have a chance to influence the direction of a potentially very powerful technology.

You might also like...

Comments

About the author

Richard Blewett United Kingdom

Richard is the CTO of DevelopMentor UK.

He began life as a mainframe programmer writing ALGOL and COBOL, but jumped to OS/2 after a year. In 1995, he started developing under Windows an...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It works on my machine.” - Anonymous