LIke most of my applications, I used to save all my application settings in the IsolatedStorageSettings.ApplicationSettings. It seems like a logical good choice. In my last application, I added a Background Agent to my project. When I was looking for best practices on how to exchange settings between the background agent and my application, I came across with this text from the MSDN library:
For Periodic and Resource-intensive Agents: Use LINQ 2 SQL or a file in isolated storage that is guarded with a Mutex. For one-direction communication where the foreground app writes and the agent only reads, we recommend using an isolated storage file with a Mutex. We recommend that you do not use IsolatedStorageSettings to communicate between processes because it is possible for the data to become corrupt.
After, I found someone who implemented a solution that uses a Mutex. While the solution is good, the only problem is that his personal settings are mixed with the IsolatedStorage operations.
To help the reuse of the solution in different projects, I created a IsolatedStorageHelper class. Also, instead of relying on the XmlSerializer in order to save an object, I based my solution using the powerful library of Json.NET.
The IsolatedStorageHelper has three methods:
Here is the example that uses all the methods:
Settings mySettings = new Settings();
IsolatedStorageHelper.WriteObjectToFileUsingJson("Settings.txt", mySettings, "MyMutexName");
Settings = IsolatedStorageHelper.ReadObjectFromFileUsingJson<Settings>("Settings.txt", "MyMutexName");
To use the IsolatedStorageHelper in your project:
1- Add the IsolatedStorageHelper.cs file into your project.
2- Add the Nuget package Json.net.
If your project does not have a background agent, you can still use my utility class, you can omit the mutexName parameter of the WriteObjectoToFileUsingJson and ReadObjectFromFileUsingJson.
Over the past year, I have built my own coding conventions for C#. I also always manage to convince my colleagues to follow my coding convention if they don’t already have one. I’m a real freak about following coding conventions; if I see someone modifying one of my files and not following my conventions, I might have trouble sleeping at night (ok, not that much, but…).
With the help of the great Visual Studio add-on ReSharper, it’s easy to format code with rules. You only need to press Ctrl-E/Ctrl-C to format a document. ReSharper is a must have tool for Visual Studio.
For the past two years, since the release of the Windows Phone platform, I have been using the XAML language to program my user interfaces. Finding coding conventions for C# is pretty easy, but for XAML, it was a bit more of a challenge. My first move was to check the default Microsoft projects, but I concluded that even they are a bit messy even for today.
Here is an example of a WIndows Store Grid App project:
First of all, there are not any empty lines, and secondly the button has attributes on separate lines, but for the TextBlock elements, the attributes are on the same lines without any order.
With time, I developed my own XAML coding convention that I would like to share. One of the reasons that I developed my own XAML coding convention is I don’t like to use the Properties window, because it is hard to have an overview of the properties that are not set to default.
My coding convention is resumed in 5 points:
1- Put empty lines between elements.
Don’t be afraid to put empty lines. It makes reading the code easier.
Some will argue that Height and Width should be side by side or on the adjacent line, but I still prefer the alphabetical order, because it is much easier to read when you know what order your definitions are in. Also, if there is an element with many attributes, it is much easier to check whether an attribute is missing.
4- Put the attached properties at the beginning and in an alphabetic order.
The Grid.Column / Grid.Row are the classic examples.
5- Definition of styles can be less strict.
When I’m creating styles with Expression Blend, I tend to leave them as-is when they are big. It is more about saving time than anything else. However, when a style is small, I don’t put empty lines and I put the properties in an alphabetic order like this:
For the past few months, I have been working on my first Windows Store app for Windows 8 called Canadian Developer Connection. Since yesterday, my application is now available in the Windows Store. The Canadian Developer Connection includes all the articles, videos-on demand, events, resources and more from the Microsoft Canadian evangelist team. Even if you are not a Canadian, the application contains useful information for any developers interested in Microsoft technologies.
Here are some screenshots:
The application allows you to stream a video to any Play To devices like an Xbox 360.
At the same time, I updated the Windows Phone version to includes the videos on-demand series and the developer events.
Don’t miss anything from the Canadian Developer Connection and download both versions!
A big thanks to my employer, Mirego, for letting me go to BUILD, and for paying for it too!
My BUILD journey started in August, on the day the tickets went on sale. I even had two computers all set up and ready to buy my ticket. When the registration confirmation came through, I was very happy. I started counting the days, like a child waiting for Christmas. I managed to convince a friend of mine from Switzerland, Marios, to come to the conference too.
One week before the conference started, Windows 8 and the Surface were both released. Now I was counting the hours…
I arrived in Seattle on Saturday the 27th of October, a few days before the conference was due to start. On Sunday the 28th, I visited the Museum of Flight. I highly recommend you visit this museum if you are in the Seattle area; it is one of the best museums I have ever seen. I spent more than an hour in the “Exploring Space” area alone. I even saw a lunar rock! I stepped inside one of JFK’s Air Force One jets, learned about aviation during both the first and second world wars, and took a tour of a Concorde. Three hours and 250 pictures later, I left to see some more of Seattle.
After the Flight Museum, I went to the Bellevue mall where I visited the first Microsoft store. The store was full, and there was a really good vibe, no doubt due to the just-released Surface. This was my first look at the Surface, and I fell in love very quickly!
Day 0 – Monday
On Monday morning, Microsoft had an official press conference for Windows Phone 8 in San Francisco. I was looking forward to watching, but I was a bit concerned that I wouldn’t be able to watch it due to the unreliable Internet connection in my hotel. Luckily, Microsoft had reserved a meeting room where Build attendees could watch the event. To ensure I wouldn’t miss anything, I left my hotel an hour before the scheduled start time. Destination: Microsoft building #40… At the event, I was expecting to meet some of my Twitter friends in person for the first time. I was not disappointed; I met Gary, and half an hour later, my friend Marios and his wife Lia arrived. Marios and I have exchanged thousands of emails since meeting in Los Angeles (at another Microsoft event!) over a year ago, but it’s always better to see your friends in person!
The WP8 press conference ran very smoothly. I really like Joe Belfiore’s presentation style. Having Jessica Alba around didn’t hurt, either! There were few surprises for me, but the most important news was that WP8 devices are coming before long, and Steve Ballmer promised that we will soon be seeing Windows Phone ads worldwide.
Registration opened at 3pm on Monday. Marios and I got in line early, and were very thankful for that fact, since the lineup an hour later was very long! I went to the reception and got my first beer. They also had some amazing cupcakes. Of course I had to have two!
The week before Build, I received an invitation to attend a private event being held by Nokia and the Windows Phone relation team at a nice restaurant in Bellevue. I was also lucky enough to be able to invite my friend Marios along. Upon our arrival, we met Kevin Hague, who happens to be the Director of Tools and Technology at Nokia. We sat beside him at dinner, and I saw a Lumia 820 phone. Without him actually saying anything directly, I knew that there would be a nice surprise from Nokia the following day at the conference. The food was very good, but of course there was too much. After dinner there was a bowling party at the Lucky Strike, but by this point the jet lag and large amounts of food caught up to me, so I decided to go back to my hotel early.
Day 1 – Tuesday
This is when the real event starts! Microsoft had built a huge tent just for the conference. After a long wait in the lineup, we found our way inside, and watched Steve Ballmer give the keynote address. He delivered a solid performance, demonstrating the beauty of Windows 8 on many different devices. After his speech, I was even prouder than before to be a Microsoft developer! Some of my friends may say I’ve been brainwashed… oh, well, that’s OK!
At the end of Steve Ballmer’s presentation, I could tell by the tone of his voice that he was about to give us something good. It started off with 100GB of SkyDrive space for everyone forever. Nice! Then came the “Free Surface” moment, although he did extract a promise from us that we’ll create applications for it. Sign me up! After that, there was “one more guest”, from Nokia, who announced that everyone would be receiving a Nokia Lumia 920. The feeling I had at the end of all this is hard to describe. Perhaps the “kid on Christmas morning” is the best way!
After the keynote address was over, I attended two sessions and visited the Microsoft employee store. Starting at 7pm, we could go and pick up our gifts, but the line up was just too crazy, so Marios and I decided to wait until the following morning. Besides, we had the Build Blogger Bash at the Lucky Strike to attend. I met two of my favourite bloggers there; Paul Thurrott and Mary Jo Foley.
Day 2 – Wednesday
Not wanting to go any more time without our gifts, Marios and I woke up early and went directly to the registration booth to get our devices. Instead of a two hour line up, it was only a two minute line up. At breakfast, I opened up the Lumia 920 and was instantly impressed by the device and the WP8 OS. Sadly, I had sessions to attend, so I had to put it away for a little while. The second keynote was all about Azure. It’s interesting, and definitely something I want to learn more about, but there are only so many hours in a day, and mine will be focused on Windows 8 and Windows Phone 8 for now.
I attended two more sessions during the day. I also registered to take certification exams in C# and Windows 8 Apps the next day. Normally, the exams cost $150 each, but Microsoft waived the cost for Build attendees for the week. That evening, I convinced Marios to participate in a hackathon with me (you know, because we weren’t busy enough already…). We coded all evening, and even skipped the beer fest! When I arrived back at the hotel, I finally had the opportunity to open the box containing my Surface. I played around a while, learning about it, then I went to bed.
Day 3 – Thursday
This was by far the busiest, craziest day of the week. After breakfast in the tent, I wrote my two exams. The C# exam went well and I passed, but the Windows 8 App one proved too much for me right now. I still have a few more things to learn. After that, I went back to work on our App for the hackathon, with Marios joining me an hour later. We finished our feature set with five minutes to spare before the 5:30pm deadline. It’s always a strange feeling, coding under pressure. The adrenaline is high, and it’s a joy when we finish.
That evening was the big Build party in Seattle. The party reminded me of the Ubisoft Christmas parties that I have attended. Hundreds of people show up, there’s lots of unhealthy food to eat, and some entertainment. Microsoft provided some old consoles like Atari and Sega to play with. At the end of the party, Marios and I found out that our hackathon App was not one of the finalists. I guess we should have added Azure, but it was fun to participate anyway.
Gorgeous picture from the Nokia Lumia 920 under low light condition:
Day 4 – Friday
This being the last day, there were fewer sessions to attend, although I still attended all of them. One of the problems at big conventions like this is that there is usually more than one thing going on at a time that I want to see. Lucky for me, all the sessions are recorded. In the next few weeks, I plan on watching the ones that I missed. My favourite session on Friday was about portable libraries. From now on, I’m going to try to use this feature in my Windows 8 and Windows Phone 8 apps. I also had a chance to talk to Jean-Christophe Cimetiere, who is the Director of Windows Phone Developer and Partner Programs. It’s always good to have contacts at Microsoft.
At the end of the day, I caught up on my emails and enjoyed a dinner with Marios and Lia. It felt good to relax!
Saturday the 3rd
Once again, I had a free day to spend in Seattle. I wandered around downtown in the afternoon, and for once, it didn’t rain. Despite the rain, the people in Seattle are nice and helpful.
For many years, I have wanted to visit the Microsoft campus. After spending a week there, I can say that I’ve visited some of it. It’s huge. There are more than 120 buildings, and most of them are really big. I would need my bike to visit the whole campus. It’s bigger than a lot of university campuses. It’s like a city-inside-a-city. There’s a Microsoft Commons building, with regular stores, where you can buy musical instruments, skis, etc. You can even book an appointment with an optician. And just like a city, it has its own transit system, called the Microsoft Connector. MC transports employees around in the morning and evening. The campus is surrounded by green areas and lots of trees.
All good things must come to an end, but I’m returning home very satisfied and happy. I met some great people, great developers. I’m looking forward to creating Windows 8 and WP8 apps with all the new features available to us. There’s no better time than now to develop for the Microsoft platform.