Using Layer Diagrams – Keeping your MVVM code from turning into spaghetti

Raleigh Code Camp 2013 is wrapping up this afternoon. The venue and the crowd was phenomenal. I really enjoyed presenting “Using Layer Diagrams – Keeping your MVVM code from turning into spaghetti”. Thanks to everyone who attended the presentation.

John Sonmez, Our Keynote Speaker, made my day by accepting my request to attend my presentation. It was awesome to have him in the audience and to get feedback from him!

I did not get the time to complete the raffle at the end of the presentation. But the folks who won the raffle should be getting an email from me with instructions to download their free license of CodeDemo (Professional).

The presentation slides can be downloaded from here : download.

 

 

Protecting Your Api Keys

I am working on a Windows 8 app (details to follow in a subsequent post) and the code is published in a public repo on github. My app uses third-party APIs and after I committed the first cut to github, I realized that I had included my api keys in the code. The whole world had access to my keys. I did not want to publish the developer keys for those APIs to the entire world.

When the app will be released and distributed, those keys will need to be included in the app somehow. Once the keys are out there they can not be 100% protected from a determined mind. So, why bother? Why would I want to hide the api keys in the source code? Here are some good reasons

1. It might be illegal to put the keys out there in plain sight for the whole world to see.
2. Developer keys may be throttled or have other restrictions on how many times they can be used per day or per minute.
3. The keys might allow access to expensive cloud computing resources.
4. The keys might allow access to confidential/sensitive customer data.

First, I had to take my keys back from git repo. Can you really remove information from a public git repository? Yes, you can, using git filter-branch. Here is how – https://help.github.com/articles/remove-sensitive-data. It worked! I successfully rewrote the history! My past commits don’t have those file(s) anymore that had my private api keys.

Next, I made sure that I don’t make this mistake again –

1. I added a new file ApiKeys.cs to the project.
2. Exposed the api keys as constants from a static class in this new file.
3 Added ApiKeys.cs in .gitignore file, to prevent this file from being committed to the repository.
4. Added instructions in ReadMe.txt for external developers to include their own keys.

This is not an ideal solution. If you are using a continuous build server, this technique will obviously not work. The code will not compile as-is, a file must be added to the project before it will start compiling. This works for me for now, but I am still looking for a better solution.

Code Validation in TortoiseSVN pre_commit_hook

If you want to abort a commit if your code fails certain rule and you don’t have access to the SVN Server to configure a hook. What do you do ?

Assuming you are using TortoiseSVN, you can configure a Client-Side hook.

Here is an example – Say you want to abort commit if you have a comment in your code that starts with //Do Not Commit. You can create a PowerShell script that validates all the files in your changeset and use this script as a Client-Side pre_commit_hook in TortoiseSVN.

TortoiseSVN-Settings-HookScripts
TortoiseSVN-Settings-HookScripts

The pre_commit_hook configuration :

Configure-Hook-Scripts
Configure-Hook-Scripts

//Powershell script : pre_commit.ps1

$donotcommit = “//Do Not Commit“;

$changeset = Get-Content $args[0];

foreach($file in $changeset)
{
if( Get-Content $file | Select-String $donotcommit -quiet )
{
Write-Error$file contains code that you are not supposed to commit. [$donotcommit]“;
exit 9;
}
}

Now, if your changeset has a file with a comment starting with //Do Not Commit and you click on OK to commit this change, the commit will be aborted with this error message –

pre_commit_hook-validation
pre_commit_hook-validation

Session Recommendations for SoCal Code Camp @ USC

SoCal Code Camp is coming up on November 21st & 22nd 2009 at University of Southern California, Los Angeles. There is just an incredible lineup of sessions. If you are trying to make up your mind about the sessions to attend, here are my recommendations –

1. Attend as many of Llewellyn Falco’s and Woody Zuill‘s sessions as you can. Specially, Unit Testing The Easy Way and one of the Dojo sessions. Any one of these sessions will make your entire trip worthwhile.

2.Kristian Hermansen’s Get Hacked Live ..

3. Stacey Broadwell’s Using Technology & Social Media to Target Candidates & Jobs should be very useful. I attended her recent presentation at L.A. Dot Net @ UCLA, it was very informative.

4. and of course If it walks like a Scrum … by yours sincerely.

I am planning to attend as many of the following sessions as the schedule allows –

* Algorithmic Trading in C#
scott hodson

* Automated Grid layout in Silverlight and WPF
Richard Fencel

* Building nTier Applications with Entity Framework Services
David McCarter

* Experiencing Agile Through Games
Carlton Nettleton

* Interoperability in the Cloud
Alejandro Espinoza

* Rapid Prototyping with Expression Blend
mark bosley

* One of Paul Sheriff’s WPF presentations

* SCRUM CLUB: Agile Requirements Gathering Workshop!
Amanda Abelove

See you there !

Using DbUpdater with MySql

DbUpdater can be used with mysql.

Here are the files you need to jumpstart the integration – DbUpdater-MySql.zip

1. You might need to change the path to mysql.exe in mysql-exec.bat.

2. Modify values in mysql-sample-command-line.bat.

Make sure mysql.data.dll is placed in GAC or in the same directory as DbUpdater.exe. Connector binaries can be downloaded from here –
http://dev.mysql.com/downloads/connector/net/6.1.html