Sunday, March 25, 2012

Posts on new C# 5.0 features

I came across a couple of good posts on new C# 5.0 features that are worth reading:

Asynchronous Programming in C# 5
What else is new in C# 5?

I like in particular the async programming support being added in this new version of the language.

Windows Azure Dev Fabric: access it remotely

One of the common topics on Windows Azure is how to access remotely a compute emulator, or the development fabric (dev fabric). This is not, of course, a solution for production, but it can come in handy when you're developing two systems on separate computer and you need to test their integration before deploying them to Windows Azure.

The problem with the development fabric is that it binds to the looback device only, so it works only if accessed by the localhost address (

The computer emulator shows that it bound to

Also netstat output shows it:

So a remote access, which would hit the local interface, would never access your locally running application. In order to to do that, there are multiple options. Windows offers a command-line utility called netsh.exe that helps rerouting port accesses and would be great to use, but it doesn't work for loopback interfaces, so unfortunately it can't be used in this case.

Another good option is to tunnel the request via SSH. I tried that by installing Cygwin + OpenSSH, and it worked beautifully. I add some references to it at the end of this post if you're interested in this option.

However, the easiest way to get this accomplished was by using an application called "PassPort port forwarding utility Win XP", which is hosted on

By configuring it to forward from my local interface IP address to, I can access the application remotely. For instance, if your external IP is, this would be your configuration:

Just click on "Start" to start PassPort as a Windows Service and you're done. No need to change anything on the remote side other than pointing it to your IP:Port.

Another alternative, that I did not try myself, is rinetd. It is mentioned in the post below and if you have any experience with it, please post a comment:

References for OpenSSH

Software Liability

Interesting article on how software creators should be liable for its consequences:
Today the operant legal concept is "product liability," and the fundamental formula is "if you make money selling something, you'd better do it properly, or you will be held responsible for the trouble it causes." 
Some say the only two products not covered by product liability today are religion and software. For software that has to end; otherwise, we will never get a handle on the security madness unfolding before our eyes almost daily in increasingly dramatic headlines.

Sunday, March 18, 2012

Review: The Art of Readable Code


This is the review I posted to Amazon on the book The Art of Readable Code:

In short: this book deserves a space on bookshelf and not only for yourself, but to serve as reference when reviewing other's code. And not only reference: this is a short book that you can done in a week or two, like the authors say. I read it cover to cover and finished it within 10 days.

It is straight to the point, has a lot of funny and relevant cartoons, and packs great pieces of advice on how to write readable code. Many of these lessons seem to be common sense, but when I started paying attention to code other engineers developed, I saw how much the lessons taught in this book were not being applied. And I am talking about senior engineers here as well. I even took my own code, which had been checked in a few days earlier, and improved based on these tips.

I believe that many of these tips one can get from reading code written by good developers. I got many of them early in my career from reading the Linux kernel, for instance. But until you put these tips in practice and start seeing your code using these lenses of readability, you will be probably missing out on many of them.

In terms of contents, the authors start with names (incredibly important), but they go all the way to refactoring the code by extracting unrelated subproblems. One are that I liked in particular is how to make your comments useful, describing precisely and in a compact way.

Finally, for those who tend to disregard these tips in favor of "getting things done" and don't care about readability, the authors present an example of a supposedly simple minute/hour counter and show how valuable an organized and readable solution is.

Tuesday, March 06, 2012

Visual Studio extension: ReSharper

I've been working with ReSharper for a week or so and definitely recommend it if you're developing in Visual Studio. It is amazing how more productive you become once you start using its features.

One of the videos I watched to become familiarized with ReSharper is this:

It does talk about many of the tips and tricks, including a very good tooling around HTML and MVC.

I'd say that it may be worth the investment for a personal license. I guess I am getting spoiled and it will be hard to go back to other IDEs.

Sunday, March 04, 2012

Review: Service Design Patterns


This is the review I posted to Amazon on the book Service Design Patterns:

This book discusses many of already commonly used patterns in the industry concerning web services. Each pattern has code examples, and the nicest part is the very reasonable "Considerations" part, which has a list of items to consider before using any of the patterns.

However, if you have been working with web services for some years and have kept up with the changes and trends, this book will not necessarily learn much from this book. It's not a long book, so it may be worth your time reading it to fill any gaps in your understanding of web services. For anyone new to web services, though, this is a must read to understand the common patterns before moving on with any trendy way of doing things.

Also, this book is an attempt to formalize many of the patterns that the industry already follows - at least I've seen many companies following them in a way or another. It is good that we all have the same terminology, but on the other hand, it doesn't really get into a lot of details of each pattern, so the the reader needs to research further if s/he wants to deepen his/her knowledge. For each of these patterns - just like in a recipes book - the author gives an example (either in Java or C#) and he was able to keep them short enough but focused on the patterns he wants to show.

From my own experience, these are some patterns or areas I'd include in the book to make it more complete:
- Client-service interaction: long polling. Other than a regular Request/Response, nowadays you see services with long polling, which can be a quite important pattern to use depending on your use case. This pattern has been out for so many years that I surprised not to see it in this book.
- Service Interceptors: this is a really important and probably can be a book of its own, but I'd love to see more patterns on how certain things like exception handling and validation could be done and pros/cons of each approach. Oftentimes these are areas that many service developers get wrong and having patterns here would help steer them into the right direction (rather than realizing later the mistake). The author touches briefly on them from a high level, but there are different ways of the doing the same thing, and it deserved a little more attention in my opinion.
- Operation concerns: typically if one has a service, it tends to be a system that is supposed to be highly available, so service developers want to minimize downtime. For that, you must have a "devops" mindset to know where to put the right logging, where to log metrics for performance, in what places to log errors, how to handle log files. There are so many pieces of advice around operations - but unfortunately I did not find a book on them yet, so developers still need to learn from practice.

Last but not least, note that this book doesn't talk service architecture. It doesn't get into details of how to architect the service, including scalability, reliability, etc. You would need to find other option for that.