First time here? You are looking at the most recent posts. You may also want to check out older archives or the tag cloud. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS. Thank you for visiting! (hide this)

January 2012 Blog Posts

TechDays Belgium 2012: a look at interesting sessions

TechDays 2012 Belgium is just 2 weeks away, and it’s time to have a look at the agenda and decide which of the sessions to attend.

My highlights are:

But filling in all the slots was a tough decision, especially in the second day, with lot of overlapping interesting talks (whereas in the first day some time slots were almost empty) but here is my tentative agenda for the 3 days

So, hope to see you there.

The last UGIALT.net Conference

logo_big

Last Saturday it was the 7th and last Conference organized by UGIALT.net. With last I really mean last, as in there won’t be any more conferences organized by UGIALT.net, at least not in its current form.

This is the end

Those who attended know the reasons why we decided to terminate operations, but if you were not there, you can have a look at the keynote’s slides, watch the video of the keynote, or reading the more detailed explanations on Emanuele’s blog post, Perchè UGIALT.net ha chiuso?, or on my Italian blog L’ultima UGIALT.net conference. And for those who don’t read Italian I’ll try to summarize the reasons here:

  • we started (almost 4 years and half ago) with the goal of pushing Microsoft and the other .NET user groups to widen their horizons, and it looks like we succeeded: thanks to the ALT.NET movement Microsoft has become more agile, more focused on good practices and more open to Open Source, and other user groups started to include in their agenda more talks about fundamentals and practices and less “how to use MS XYZ lib”.
  • the ALT.NET movement (in Italy, but also worldwide) kind of split in two groups: the ones satisfied with the direction MS and other traditional user groups took, and the ones not satisfied. The first merged back into the traditional communities, and the latter moved to other platforms (ruby, nodejs and similar).
  • And finally, being too successful, with more than 150 attendees and many “mainstream developers” attending our last conference, we realized that the next step should have been a bigger conference, in a bigger venue. But that wouldn’t have been possible with just the 3 of us organizing it in our (little) spare time, financed just by donations. We should have set up a legal and fiscal entity to sell tickets, get paying sponsors, pay for the venue and either dedicate more time or find someone to help us (which didn’t happen in 4 years). But that’s a direction we didn’t want to take. We hope the other Italian User Groups will follow our steps, and keep on including ALTernative tracks in their conferences.

The conference

As I already mentioned this was the edition that beat all records: the highest number of registrations (more than 240), the highest number of attendees (around 150, the maximum, maybe more, capacity of the venue), the highest value of gifts and prizes for the attendees (more than 60.000€ of commercial value), mainly thanks to Umbraco for its Umbraco.TV subscriptions for everybody, and to Mindscape for the gift to the speakers and the 20 licenses of LightSpeed.

And #uan12 has even been an official twitter trending topic on Saturday in Italy: I think this is yet another record, being the first developer conference in Italy to become a trending topic.

If you couldn’t attend, we published all the slides online on Joind.in: http://joind.in/event/uan12. If you attended please check-in on the event, and leave your feedback.

We also recorded most of the presentations, and they are available on the Vimeo channel of DotNetMarche, one of our two main spiritual heirs, in the 7th UGIALT.net Conference video album.

But a conference is not only technical contents, it’s also user interaction and social media: you can see what happened, or live it again, in the photo twitter wall created by PepperTweet for UAN12.

What’s next?

We pushed the other UGs during these 4 years, now we hope some of them will continue on our footsteps. In the context of .NET I’m pretty sure we’ll see a lot of good stuff coming from DotNetMarche, and outside of the .NET world, there is a very fervent community in Brescia, called WEBdeBS, which is organizing (and has organized) a lot of interesting events.

 407693_3108061259636_1207452102_3374094_2060978480_n

Personally, now I’ll dedicate more time to coding, other interests (like Arduino). I’ll help WEBdeBS and DotNetMarche in some of their activities and will try to start collaborating more with the local (as in Belgian) communities.

What’s new in ASP.NET MVC 4: slides and demo are now online

Today I had my first live webcast for Microsoft Belgium, about the new features released with ASP.NET MVC 4 at Build in September.

There were around 80+ people registered and around 50 people attending, and almost nobody left before the end of the webcast, so I guess it pretty well. We also are aware there were some glitches in the audio during the async part of the webcast: the audio was also recorded directly from the mic, so the video that will be published in the next week on Channel9 will have good audio.

Or just register for the TechDays2012 Belgium next February, where The Gu, besides giving the opening dev session, will give a session on ASP.NET MVC 4.

Here are the slides I uploaded to SlideShare.

Also available for download are:

Video

The video has been published on Channel9: What's New in ASP.NET MVC 4

Some resources

Additional resources to check are:

Not related to ASP.NET MVC 4, but since a few people asked how I got the Lumia 800 skin on my WP7 emulator, here is the link: Windows Phone 7 Emulator Skin Switcher.

If you attended, please let me know how it went, and if you didn’t stay tuned: in a week or so the video will be available on Channel9. I’ll write a new post with the video.

Getting started with Git and GitHub

Now that Subtext, the blogging engine I’m working (or at least I should) on together with Phil Haack, has been officially moved to GitHub (guess the reason why), I finally have a reason to really study git and github.

I already tried starting a few years ago, and even used it a bit lately to work on the ugialt.net conference site (here the conf-oo github repo), but never really studied in depth, and still didn’t fully get the key differences between a traditional source control and a distributed source control.

So I asked around and found some good pointers.

Think Like (a) Git

The most recommended pointer I got is the Think Like (a) Git website, a self-proclaimed “Guide for the perplexed”. It’s a pretty nice tutorial covering all the key concepts of Git.

It also comes with a slideshow and an all-in-one page if you want to print it or PDFize it.

ProGit book and site

The second most popular recommendation I got is the Pro Git book from Apress. The thing that differentiate it from other books is its widespread usage of visuals and samples.

The cool thing is that, while still being a paper book and having a Kindle version, both released on 2009, there is also a Creative Common licensed ebook (PDF, Mobi, ePub) and also available for online reading.

The “code” for the book and his images is available on github and is updated with fixes coming from readers.

Other Git books

But Pro Git is not the only book available. Other two interesting books are the Pragmatic Guide to Git, published by Pragmatic Programmers and Version Control with Git: Powerful Tools and Techniques for Collaborative Software Development, by O'Reilly.

Cheat sheets

Then come the cheat sheets: GitHub lists a few ones.

But I particularly like the one on DZone, which besides being a cheat sheet is also a compendium of the main key points, and one of the first, but still one of the best, git cheat sheet.

Contributing to Open Source Projects On GitHub For .NET Developers video series

UPDATE: suggested by Bobby Johnson in the comments, a series of 3 videos on how to use Git and GitHub for contributing to OSS projects:

The GitHub Flow

One thing is to know the commands and how to use them, another matter is using it with the right approach and workflow.

I found two nice blog posts that explain two different versioning/branching strategies:

  • The usual workflow based on master + develop and feature branches, release branches, hot-fix branches, this time referred to as Git-Flow
  • The workflow used by GitHub itself, which is kind of less formal in some ways (no tons of release-based branches) and more strict in other ways (never commit to master without a code review and a pull request).

One works great if you have a product with formal releases and have the time and resources to manage all that formal branches, the other works great in less formal environment, with continuous deployments, and no formal releases.

Some other useful links

Do you have any other resources to recommend?

This is what I found, and apparently what the most popular resources are. But I’d love if you could add your own findings by posting a comment.

The evolution of asynchronous controllers in ASP.NET MVC

Asynchronous operations in ASP.NET MVC have always been left a bit behind. They appeared in ASP.NET MVC 2, remained untouched in v3, but now in MVC 4 (especially  in combination with C# 5 and async/await) they reached the same easiness of use of the standard synchronous controller. Now (or better, in a few months with the release of ASP.NET MVC 4, .NET 4.5 and C# 5) you can write

public async Task<ViewResult> Stuff()
{
    return View(await DoStuff("Some stuff"));
}

In this post I’m going to show how the code for implementing asynchronous controllers evolved from ASP.NET MVC 2/3 to ASP.NET MVC 4 with C# 5.

Disclaimer: The samples for ASP.NET MVC 4 are based on the Developer Preview that has been released at Build in September 2011. It might be different from the final version when it gets released.

Async Controller in ASP.NET MVC 3

In ASP.NET MVC 3 you had to create two methods, one to start the async operation, and another to end it, and you had to manually update the counters of the outstanding operations. I showed an example in blog post I wrote last month about the AsyncTimeout, but I’m copying here  the code for your convenience. The code also includes the normal method I call asynchronously.

public class DoController : AsyncController
{
    public void StuffAsync()
    {
        syncManager.OutstandingOperations.Increment();
        var bg = new BackgroundWorker();
        bg.DoWork += (o, e) => DoStuff("Some other stuff", e);
        bg.RunWorkerCompleted += (o, e) =>
                 {
                     AsyncManager.Parameters["text"] = e.Result;
                     AsyncManager.OutstandingOperations.Decrement();
                 };
        bg.RunWorkerAsync();
    }
    
    public ActionResult StuffCompleted(string text)
    {
        return View(new DoStuffViewModel(){Text=text});
    }
    
    private void DoStuff(string input, DoWorkEventArgs e)
    {
        Thread.Sleep(5000);
        e.Result = input;
    }
}

Introducing the Task Library

The sample above uses the BackgroundWorker to call asynchronously the DoStuff method. When using ASP.NET MVC 3 with .NET 4 we could also use a Task with continuation and make it look a bit better. If you have never used the Task library I recommend you read the awesome post by Justin Etheredge: .NET 4.0 and System.Threading.Tasks.

public class DoController : AsyncController
{
    public void StuffAsync()
    {
        AsyncManager.OutstandingOperations.Increment();
        var task = Task.Factory.StartNew(() => DoStuff("Some other stuff"));
        task.ContinueWith(t =>
        {
            AsyncManager.Parameters["model"] = t.Result;
            AsyncManager.OutstandingOperations.Decrement();
        });
    }
    
    public ActionResult StuffCompleted(string text)
    {
        return View(new DoStuffViewModel(){Text=text});
    }
    
    private string DoStuff(string input)
    {
        Thread.Sleep(5000);
        return input;
    }
}

Not a lot better, but still less lines and event handling around (which I personally don’t like that much). This is as far as you can go with officially released versions of ASP.NET MVC.

Async controllers in ASP.NET 4 Developer preview

Dropped the support for .NET 3, ASP.NET MVC 4 fully embraces the Task library: no more 2 methods per action, no more manual counter increment/decrement. Your action only need to return a Task<ActionResult> and the action invoker will take care of all the synchronization.

public class DoController : AsyncController
{
    public Task<ViewResult> Stuff()
    {
        return Task.Factory.StartNew(() => DoStuff("Some other stuff"))
            .ContinueWith(t =>
                              {
                                  return View(new DoStuffViewModel()
                                                  {
                                                      Text = t.Result
                                                  });
                              });
    }

    private string DoStuff(string input)
    {
        Thread.Sleep(5000);
        return input;
    }
}

Isn’t it a lot better? It could have been even terser by using an expression:

public Task<ViewResult> Stuff()
{
    return Task.Factory.StartNew(() => DoStuff("Some other stuff"))
        .ContinueWith(t => View(new DoStuffViewModel{ Text = t.Result }));
}

So, no manual counters, no double methods. But we can go even further.

Adding async/await

If we go one one step further, to ASP.NET 4.5, with C# 5, or install the Async CTP on top of .NET 4 we get the async/await keywords. They are new features of C#, that make asynchronous code much more easy to write.

Using them, the code of our simple controller becomes:

public class DoController : AsyncController
{
    public async Task<ViewResult> Stuff()
    {
        return View(new DoStuffViewModel()
                        {
                            Text = await DoStuff("Some other stuff")
                        });
    }

    private async Task<string> DoStuff(string input)
    {
        Thread.Sleep(5000);
        return input;
    }
}

Are we arrived?

Now Asynchronous controllers are as easy to do as  standard controllers, and thanks to the Task library and to the async/await keywords async calls are easier to implement and less error prone than before. This raises another problem: do not overuse them. If doing async with short tasks and with lots of requests the server will spend more time in thread switching than executing your code. So never do it just for the sake of it, but use some grain of salt and do performance testing.

Do community because you like it, not because of the incentives

Every time there is a MVP renewal there are always some tweets or posts from people not being re-awarded, but this New Year re-awarding cycle was different: a few vocal and prominent community members didn't get re-awarded. Most of them were MVPs because of their OSS projects, so conspiracy theories started about Microsoft dropping his support to Open Source, and the bashing game started.

Contributes to the community because you like it, not because of the incentives

You should contribute to the community because you love doing it. Not because of the incentives MS gives you with the MVP program.

I love doing what I do for the community (books, articles, my blog, speeches, managing a user group, organizing UG meetings) and I would do the same even without the MVP program, because I love sharing my experience and my knowledge and my passion.

Everybody should do the same, for the same reasons.

If you do it for getting the MVP logo on you business card you'll be disappointed: the benefits MS gives to MVPs are almost nothing compared to the effort put into becoming and maintaining the award. What I think is the real value of the MVP is being able to help product teams with your observations of what is the real world outside Redmond.

Of course the MVP program has its problems (which I'll explain later), but they are not relevant if you do your contributions to the community for the sake of it, and not for becoming a MVP.

What is the MVP program

A lot has already been said about the MVP program, and how people are evaluated: basically it boils down to filling a report with all the things you did to contribute to the MS community: speeches, books, articles, blog posts, user-group activities, forum participation, OSS contributions and so on. And the the MVP lead of the region will evaluate your contributions compared to all the other candidates. So if you fill in this report without care (like Keyvan that said he added in 5 minutes only the 25% of his contributions) or your contributions are less compared to the other candidates, you are not getting the award.  And it's also probably true that, since MVP leads are not technical persons, they might not be able to give the right importance to contributions to a famous .NET OSS library. Probably this should change, especially now that the strategy of Microsoft is moving more and more to OpenSource (in the DevDiv at least).

It is also true that MVP, Most Valuable Professional, might not reflect the new meaning of the program: maybe it was when it was created in the '90s, but now nothing proves a MVP is someone that adopts the best practices and his a great developer. As said a few lines above, MVPs are people that contribute to the community. Maybe the name should be changed to "Community Champions" or something similar.

Disclaimer: Before becoming a MVP I had attacked the program for lack of transparency. Since then, the transparency increased a bit, and despite my attack they awarded me anyway, so this proves personal opinions are not taken into account when awarding MVPs