Reading Notes #121

Reading Notes #121

Cloud

Programming

(oups, I lost my notes... sorry.)

Reading Notes #120

Suggestion of the week

Christmas Planet

Cloud


Programming


Databases


Architecture

  • Composite Pattern (Gunnar Peipman) - Good post that explains clearly a pattern with code sample.

Miscellaneous



Reading Notes #119

 

Stack of books-300

Suggestion of the week

  • BizTalk Summit 2013 Wrap-up (Kent Weare) - Very important news from the integration world. This post is a very complete summary of the event. Good job.

 

Cloud


Databases

 

Programming

Miscellaneous


~Frank


Reading Notes #118

NodeJSSuggestion of the week

Cloud

Programming

Miscellaneous


~Frank


Reading Notes #117

2013-11-24_2213Suggestion of the week


Cloud


Programming


Miscellaneous




Reading Notes #116

 

SomethingIsCommingCloud

Programming

Channel 9 has an excellent streaming video that covers Code Maps here 

Databases

Miscellaneous

~Frank

Reading Notes #115

Moustache-Glasses-2_originalSuggestion of the week

Cloud

Databases

  • WebLog of Ken Cox - I find out that using the migration wazard was the best option in my case... Until they update Sql Management Studio.

UX

Programming

Miscellaneous


~Frank


Localization from url with Asp.Net MVC 4



To offer a website in multiple languages using ASP.Net we simply need to add some resource.resx files to our project and voilà. Based on the language of the browser, IIS will match the localization resource. However, what if we want to give the choice to the user?

The goal

One pattern often used to achieve this, is to split the resource based on the URL.

Ex:
http://www.DomainName.com/EN/About for the English path
http://www.DomainName.com/FR/About for the French path

The needs

We will need something to grab the desired language from the URL and set it as the current language.

The Solution

First, let's add a new route. Asp.Net uses routing to parse the URL and to extract information from it, while keeping the displayed URL more user friendly. The default route is {controller}/{action}/{id}. So without a new route, our language will be treated as a Controller name; but that’s no good.
The route we want is {lang}/{controller}/{action}/{id}. We could just replace the default, but then what would happen to "normal" calls?

The best thing to do is to add our localized route first and keep the default second. The way the routing works, it will use the first route that matches. Since we will use the two-letter code for chosen language, lets add the first part {lang}, which must be two characters long to be considered valid. You can see this in the code where I define a constraint using the following Regex: "^[a-zA-Z]{2}$".

Class_RouteConfig
Now that we have the language, we must change the user interface culture of the current thread. I decided to use an Attribute, making it easy to use. Under the Filter folder add a new class which inherits from ActionFilterAttribute. This method will check if "lang" is available from RouteData. If lang is present it will change the currentUICulture of the current thread. If "lang" is not part of the URL, then it will set it to the default.

Class_LocalizationAttribute

We could put the [Localization] attribute on all controller classes, but a best practice is to create a BaseController class and use it there.

Class_BaseController

Voilà, you can now change the language of the entire website by changing the URL.

Bonus: Use it everywhere


To use it in the view and the controller it's easy; just add the namespace and just type Resources.NameOfYourResourceString.
To use it in the validation and the generated code from the model, we could use something like this:

Class_PersonModel

This way, in the view, the code will still stay clean and simple.

@Html.LabelFor(model.UserName)

I hope this post helps you in your development efforts. Any comments, suggestions and/or questions are welcome.
 

~Frank



Reading Notes #114

Suggestion of the week

Cloud

Database

Programming

UX

Miscellaneous


~Frank


Reading Notes #113

 

pumpkin_CloudSuggestion of the week

Cloud

Programming

Database

Architecture

Miscellaneous

~Frank


Reading Notes #112

http://visualstudiowallpapers.com/image/53341361070Suggestion of the week

Cloud

Programming

Miscellaneous

~Frank


Reading Notes #111

Cloud


Programming


Database


Miscellaneous


~Frank




Reading Notes #110

 

CloudyFallSuggestion of the week

Cloud

Programming


Miscellaneous

  • 10 best new features in Excel 2013 (Susan Harkins) - Interesting, go you know your Excel?

  • Writing About Code: Structure - Second part of a very interesting article about how to write. This
    one is all about get our writing in a good shape. Because well structured our post will be easier to read, understand and share.

~Frank



How Windows Azure Simplified my Development

(This post was originaly published on Matricis Blog)

Usually my posts are a lot more technical, but this time I decided to share an experience with Windows Azure that saved me a lot of headaches while saving my boss a bunch of money ;)

The Context

Here at Matricis, we often set up our development environments on virtual machines (VMs) witch we host on our internal infrastructure. We have several different development VM configurations, based on the technologies and versions needed. A big advantage to doing so is that if the required environment changes, we simply choose the corresponding VM template. For the project I'm about to talk about, we needed quite a powerful development system, especially since every developer required Visual Studio 2012, SharePoint Foundation 2013, SQL Server, ADFS, and a handful of other tools (fiddler, notepad++, different browsers, etc.)

The Problem

To be able to develop with SharePoint, it is strongly recommended to have at least 8 gigabytes of RAM (I first tried with just 6 gigs, but it was still a nightmare). My laptop only has 8 gigs of memory, so I couldn't run the VM locally. I asked our IT guys if it was possible to host the VM on a local on-premise server. They answered that they didn't have enough space for the environment. They were very sorry, but I was actually quite happy about it; I now had a perfect use-case to work in Windows Azure!

The Solution

I went to see my boss and explained the situation: instead of buying a brand new server for development and test environment purposes, we should simply use Windows Azure’s IaaS! We could start setting up the VM in less than 10 minutes. In an hour we would be ready to code! The development VM would only be up while it was in use, meaning that it wouldn’t cost a cent while nobody was working on it. On project completion… we would delete all the VMs we were using, and no more fees! My boss loved the idea!

The core team for this project involved four full-time developers, and here is a high level look at our development environment: The Active Directory is shared but every developer has their own SharePoint, Sql Server, and ADFS making them autonomous.

Development environment


As you can see, it's a hybrid environment since the Team Foundation Server (TFS) is on one our local servers. In the morning, I start my VM and within a few minutes, I'm connected remotely and I’m ready to work on a great machine. With a little PowerShell script that I wrote, I don't even need to log in to the Azure Portal to start and stop my VM. Another great joy to this scenario is that I can now work from anywhere and on any kind of machine: from home on the family computer without VPN or from a Hotel on my laptop or my Surface Pro! Happiness often comes from simple things.

In general, I would say that the experience was very positive, but on the road we did encounter some issues that we had to resolve. Since all IPs on Azure are dynamic, we discovered that the domain controller that is hosted in Azure, must be started before the other VMs. This way its IP will always be the first one, therefore the other VMs will find it without any issues. Furthermore, in our architecture, the source-control (TFS) is on-premise. When you check-out or check-in your code, you are passing through the firewall. However, since these actions are intensive, the firewall may interpret the activity as attacks.

Because the job of a firewall is to protect your network, you can imagine what happened... the connection was lost. Once we identified this and created Firewall exceptions for the Azure VMs, everything was good.

In Conclution

I hope this post will encourage you to try Windows Azure as a development and test environment, because it's a really effective and cost-beneficial way to execute on different projects. For more information about the Windows Azure Infrastructure as a Service go to the Windows Azure Web Site.


~Frank


Reading Notes #109

 

WP_20130928_004Suggestion of the week


Cloud


Programming


Database

Miscellaneous


~Frank


Reading Notes #108

powershell

Suggestion of the week


Cloud


Programming


Miscellaneous

~ Frank


Reading Notes #107

Retro_CloudSuggestion of the week


Cloud


Programming


Miscellaneous


~Frank


Reading Notes #106

WP_20130908_002Suggestion of the week


Cloud


Databases


Programming


Integration


Miscellaneous


~Frank


Reading Notes #105

 

Image from sxc.huSuggestion of the week


Cloud


Programming


Miscellaneous



~Frank

[Image from sxc.hu]

Reading Notes Special Books Edition

For the last months I read few technical books.  I thought it could be interesting to add it.  This is not a complete review and it only reflect my personal opinion.


EF CodeFirst coverProgramming Entity Framework: Code First 
By Julia Lerman, Rowan Miller
Publisher: O'Reilly Media
Released: November 2011
ISBN 10:1-4493-1294-2

Note: By the time I write this post the version of Entity framework is 5.0.
Even if this book was about the previous version of Entity framework, it’s a golden mine of information. I found very useful the example that helps me to understand how to define the relation and more importantly what was the deference between the attribute way and the fluent way. It was easy to read, because well explains not because it was doing only the “beginner” stuff. Since EF is really useful when starting a new project or even for a POC, I think this book should be in all developer’s bookshelf.

 
PowerShell BestPractices coverWindows PowerShell 2.0 Best Practices
By Ed Wilson
Publisher: Microsoft
Released: December 14, 2010
ISBN-10: 0735626464

If you are a .Net developer and you still don’t know PowerShell or don’t know why you should consider PowerShell than this book is not for you… You should read some Introduction books or post THEN read this book.
This book is all about best practices. It will help you to structures your code or your library of scripts. That way, you will be able to understand and found and reuse all of it. Whether to do something in a build or to deploy something in Windows Azure or even just to quickly do a repetitive task this book will help to do it.  A book to keep nearby. 


Claims-Based_CoverClaims-based Identity Second Edition device
By Dominick Baier, Vittorio Bertocci, Keith Brown and Matias Woloski
Publisher: Microsoft
Releaed: April 21, 2010
ISBN-10: 0735640599

This is definitely THE book to get started with claims. It starts right at the beginning explaining what’s a claim, why we should use it.  Many different scenarios are presented. Each of them is presented with and without claims and most of the time how to migrate from one to the other.  The complete solution is available on codeplex.com and if a PDF is good enough for you; it's also available on codeplex for free. 


Building N-Layered Applications with ASP.NET 4.5N-Layer_Build_cover
By Imar Spaanjaars
Publisher: Imar.Spaanjaars.Com
Released: July 2013

This document is, in fact, a series of post about the best practices related to Asp. Net 4.5. While writing this notes, only two or three posts were available online. To get the full document with the source code you must pay. Eventually, all parts of the rich document will be available for free, but it's only 20$ and its own is value.
The solution explained in this document is simple enough so it’s easy to understand the architecture but detailed enough to cover most of the case.  The solution will include a lot of technologies like: Entity Framework, Asp. Net MVC, WCF Services and many patterns: Dependency Injection, Repository, Unit Test, Mocking, etc.
It’s a really well done document, and I think it’s a must to any web developer or architect.

Microsoft SharePoint 2013 App Development
Microsoft® SharePoint® 2013 App Development
By Scot Hillier, Ted Pattison
Publisher: Microsoft Press
Released: November 2012
ISBN 10:0-7356-7498-1

I read this book to know more about the new “Apps” thing.  While I was ready, I understand that my project was not a good match for SharePoint App, so I didn’t finish it… yet. However, I found the book explications really clear, and it gives me all the tooling and options I needed to get started.
Since Apps are now very present in SharePoint, I decided to include it in my notes.



~Frank