ailon's DevBlog: Development related stuff in my life

See You at MIX10!

3/11/2010 7:21:18 PM

So I’m going to MIX10. This will be my first trip to Vegas, my first trip to USA, my first flight over Atlantic Ocean and I think my first conference of any sort. I guess I’m not that old after all, if I can get so many first time experiences from one trip.

I’m looking forward to all the cool info on Windows Phone 7, Silverlight 4, etc. And I’m looking forward to meeting loads of cool nerds. Not sure if my brain can handle it, though. I really like meeting interesting people but I’m a shy person and I guess I may have problems approaching people for no other reason than saying “hello”. So I included my mug shot below (click to enlarge) for those who aren’t as shy as I am. I encourage you to come say “hi” if you see me at MIX.

IMG_1380

And as a bonus ask me for a free amCharts license and I’ll give you one!

I’m planning on doing a short trip to Los Angeles and San Francisco area after MIX. So if you are driving from Las Vegas to LA on March 18th and have a place for a passenger, please, consider me. You can contact me via email or twitter @ailon.

And if you’d like to grab a beer in LA on 18th-19th or in SF area on 20th-22nd drop me a line too.

See you at MIX!

Tags: ,

Steps to Migrate from Subversion to Git

3/1/2010 5:04:47 PM

I’ve migrated a couple of my SVN repositories to Git, but each time I forget how to do this. And each time I had to look into Pro Git book and process all the extra info there. So, I decided to document the steps I did for future reference. This is in no way a tutorial or something that has a good explanation of what’s going on. If you want to get a deeper information on the subject go read the book mentioned above.

I don’t work in a mixed SVN/Git environment so I only need to do this once for each project and forget about SVN on that project, so I figured I will document the steps and follow them blindly when I need to repeat the procedure for the next project. Note that this only migrates the trunk (or branch specified by the url) and doesn’t migrate tags, etc. If you need more than just a change log of your main branch, read the book/documentation.

So here we go.

  1. Create a directory for the new Git repository
  2. In that directory create a file called users.txt which looks like this:

    username = Real Name <email@email.com>

    It’s used to match usernames in SVN commits to Git’s user information
  3. Run Git Bash in that directory and enter this command:

    git svn clone <svn-repository-url> --authors-file=users.txt --no-metadata

    Where <svn-repository-url> is the url of your SVN repository. If you use TortoiseSVN you can easily find this url by right clicking on your working copy and navigating to “TortoiseSVN->Relocate…” in the context menu.

    --authors-file tells Git to use your users file and --no-metadata tells it to omit metadata used by Git to synchronize repository with SVN. When you are migrating it’s quite important to use no-metadata as by default git-svn adds extra information to commit messages and you don’t want it.

And that’s basically it. However I do a couple extra steps to remove traces of SVN in my new Git repository.

Removing traces of SVN

Now I’m sure I don’t do this properly, but I couldn’t figure out how to do this the right way. So if you know how to do this from command line or some tool, please, let me know in the comments bellow.

  1. Remove sections [svn-remote …] and [svn] in file .git/config
  2. Delete file .git/refs/remotes/git-svn
  3. Remove directory .git/svn

As I said it’s not a good idea to mess with files in .git directory directly but I was unable to find commands to do this properly. So proceed on your own risk. It’s worth mentioning that this isn’t necessary, but for some reason these unneeded traces of SVN annoy me.

MIX10K Winners on SilverlightTV

2/19/2010 10:13:15 AM

Yesturday John Papa and Adam Kinney announced MIX 10K winners on SilverlightTV. Check it out:

Get Microsoft Silverlight

The part about my entry starts at approximately 6:18 mark. And John accidentally hits a link to my games.ailon.org site. Oops :) I’m sorry, John.

I’m going to MIX10!

2/16/2010 11:10:44 AM

Thanks to all who voted for my MIX 10K Smart Coding Challenge entry. Thanks to you I’ve won the Community Prize!

image

I’ve already bought the plane tickets and I’m flying Vilnius – Copenhagen – Newark – Las Vegas on March 13th. Anyone on the same route? These are probably the most pleasant unexpected expenses of my life.

Congratulations to Grand Prize winner Jimmy D for his awesome Frog Log game made in HTML5 and to all runners-up!

I especially liked Pipe Runner by Rafal C – truly awesome game. You have to check it out. When I first saw it I thought I have no chances but I guess being an early bird paid off.

Thanks again to everyone who voted for my little game. You can download the source code of a slightly spiced up version here. It’s not a 10kb version and it’s not a good example of how you should develop Silverlight games (the beauty of code was not the objective) but it’s available for the curious.

Mix10_SeeYou_blk_240

If you would like to hook up at the conference or en route feel free to email me at ailon@ailon.org or message me on twitter @ailon or leave a comment here.

See you in Vegas!

Book Review: The Art of Unit Testing by Roy Osherove

2/2/2010 7:49:36 PM

The Art of Unit Testing by Roy Osherove

Personal preface

I must admit – I haven’t been doing any real-life unit testing until now. Back in 2004 I was leading a relatively big WinForms project and I thought we should do unit testing on it. Unfortunately we had already finalized our conceptual designs (which didn’t consider unit testing), the tooling at the time wasn’t as mature as it is now and, most importantly, we had no knowledge on how this unit testing thing should be done properly. So after playing around with NUnit for some time I’ve concluded that it was neither the time nor the place to start doing it for real and put it away.

After that project I was mostly involved with smaller ASP.NET projects and never thought that unit testing was really feasible for them. So, basically unit testing was always somewhere on my mind but not too close to the surface.

Five years later I’ve started working on amCharts for WPF & Silverlight and as we release new products, add new features and fix bugs I’ve started feeling a real fear of breaking something while fixing a bug or adding a new feature. Manual testing helps but the fear is always there. I understood that it’s time for “take 2” on unit testing.

This time I knew that I have to do it right. This is one of those subjects where you can’t just start doing it and learn as you go. That is a sure way to fail (see my experience above).

The Book

Fortunately this time there is this book and it’s targeted at .NET developers which is not essential but a nice bonus. I’ve been reading Roy Osherove’s blog for quite some time and following him on twitter. I’ve been using his Regulator regular expression testing tool before that. So, I sort of “knew” and respected the author, the book got raving reviews at Amazon – buying it was a no-brainer.

The book is short (less than 300 pages) but on point with almost none “water spilled” and space wasted. I’ve swallowed it in less than a week reading it in the evenings only. That wouldn’t be that fast for a fiction book, but I think that’s a record for me for a technical book. I usually fall asleep reading technical books in bed pretty quickly and I only did it once with this book ;)

It covers all the aspects of unit testing, writing good tests and testable code, tooling for .NET (also mentions tools for Java, C++, etc.). It also offers quite strong author’s opinions on the matters. Some people might not like this, but as long as you can see that it’s an opinion and not something written in stone, I really do like it.

Minor Criticism

I can’t say anything bad about the content of this book, but I have a few minor complaints about presentation. First of all I didn’t like the font used. I’m no expert of fonts and this could be the default Manning (publisher) font, but it didn’t feel right to me (too wide or something). The use of some “comic” type of font for ToC and headings is another story, but since it’s not the main font it didn’t bother me much. There were some minor issues with sample code too: incorrect indentation, a couple of auto-capitalized “return” statements and things like that, but nothing major.

The book comes with free access to ebook version in PDF, ePub and Mobipocket formats w/o DRM (as far as I understand). Unpleasant thing was that my name and email address was inserted in the footer of every page of the PDF. I don’t even know what is more unpleasant DRM or this. Should I protect the PDF now so it doesn’t spread over internet accidentally or something? If I wanted to spread illegal copies I’d find a way to remove this, but now I don’t even feel comfortable giving that PDF to my colleague which I consider a fair use (I’ll give him a paper book anyway). Anyway this is a minor issue and I should stop complaining.

Conclusion

If you are serious about starting unit testing or improving your skills, do yourself a favor and don’t just jump right in, but buy this book (especially if your main platform is .NET). It’s a really excellent starting point for anyone who doesn’t consider himself a unit testing guru (and I guess even gurus might find something new). After reading this book I feel pretty confident that my next project will include unit tests and I’ll have a good basis and this book as a reference if I have questions.

Links

Tags: , ,

MIX10K T-shirt

2/2/2010 12:44:44 PM

Got my Mix10K T-shirt Today:

Mix10K t-shirtMix10K t-shirt

Don’t forget to vote for my entry in the MIX 10k Smart Coding Challenge. You know, that’s the only chance I have of going to Las Vegas this year ;)

Tags: ,

Weekend project: Spiced Up Tic-Tac-Toe 3D

1/18/2010 2:41:56 PM

TicTacToe3D

Over the weekend I’ve spiced up my little entry in MIX 10k Challenge and posted it to games.ailon.org. Check it out. And vote for it in the contest. Thanks!

As usually source code is included, but… The objective of the initial project was to fit it into 10k and even though I’ve spiced it up visually I didn’t change the overall code architecture so it’s some pretty ugly code. Sorry :)

kick it on DotNetKicks.com Shout it submit to reddit

Tags:

Writing WPF/Silverlight compatible code. Part 6: Adding XAML files as links

1/13/2010 5:05:40 PM

Note for future readers: These series discuss WPF and Silverlight versions that are current stable versions at the time of this writing – WPF 3.5 and Silverlight 3.

These are ongoing series of posts on the subject of WPF/Silverlight compatibility. New posts will be added to the Table of Contents post as they are written so bookmark that post or just subscribe to my RSS feed.

While developing WPF/Silverlight applications and controls one of the main code sharing techniques is adding shared code files as links to one of your projects.

Visual Studio - Add As Link

This works perfectly with C# or VB files but not as good with XAML. In this article I’ll show you a workaround to make this technique work with only a small overhead.

The Problem

Suppose you’ve created a WPF project and your own custom control named MyTemplatedControl. It does nothing in our example (just sets DefaultStyleKey property).

   1: public class MyTemplatedControl : Control
   2: {
   3:     public MyTemplatedControl()
   4:     {
   5:         this.DefaultStyleKey = typeof(MyTemplatedControl);
   6:     }
   7: }

Now we create a default ControlTemplate for our control. To do this we add Themes folder to our project and Generic.xaml flie in that folder.

image

Our template will just display a blue rectangle (just so we can see if it’s applied). Here’s the XAML in Generic.xaml file.

   1: <ResourceDictionary
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:     xmlns:local="clr-namespace:TestControl"
   5:     >
   6:  
   7:     <Style TargetType="local:MyTemplatedControl">
   8:         <Setter Property="Template">
   9:             <Setter.Value>
  10:                 <ControlTemplate TargetType="local:MyTemplatedControl">
  11:                     <Canvas>
  12:                         <Rectangle Canvas.Left="20" Canvas.Top="20" Width="100" Height="100" 
  13:                                    Fill="Blue" Stroke="Black" StrokeThickness="3" />
  14:                     </Canvas>
  15:                 </ControlTemplate>
  16:             </Setter.Value>
  17:         </Setter>
  18:     </Style>
  19: </ResourceDictionary>

We add our control to a test window and run the app we see something like this:

image

Now we want to create a Silverlight version of the control. We create a Silverlight custom control project, “Add As Link” our MyTemplatedControl.cs file, create Themes directory and “Add As Link” our Generic.xaml file. Everything compiles just fine. But when we add the control to a Silverlight application and run it we get an empty white screen. The template is not applied.

This happens because for some reason (I don’t know if it’s done for a reason or is it just a bug) XAML compiler compiles local and linked .xaml files differently. Here’s an article describing what happens. Short story is that resource key for local and linked xaml files are different and since the engine looks for a specific resource key for default styles it just can’t see the linked version because it’s key is not equal to what it looks for.

The Solution

The above mentioned LearnWPF.com article suggest a workaround of moving all resources to a separate assembly. I’m pretty sure that wouldn’t work with default styles and generally is not something you would want to do in simple scenarios.

I solved this issue using MergedDictionaries. The solution is to move you Generic.xaml content to other XAML file (or even better separate files for each control). This way you can “Add As Link” those specific files and add separate Generic.xaml files with only a list of MergedDictionaries addressing the resource key differences.

Let’s apply this technique to our example. So we move our XAML to a separate MyTemplatedControl.xaml file and reference it from MergedDictionaries in Generic.xaml.

MyTemplatedControl.xaml:

   1: <ResourceDictionary
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:     xmlns:local="clr-namespace:TestControl"
   5:     >
   6:     <Style TargetType="local:MyTemplatedControl">
   7:         <Setter Property="Template">
   8:             <Setter.Value>
   9:                 <ControlTemplate TargetType="local:MyTemplatedControl">
  10:                     <Canvas>
  11:                         <Rectangle Canvas.Left="20" Canvas.Top="20" Width="100" Height="100" 
  12:                                    Fill="Blue" Stroke="Black" StrokeThickness="3" />
  13:                     </Canvas>
  14:                 </ControlTemplate>
  15:             </Setter.Value>
  16:         </Setter>
  17:     </Style>
  18: </ResourceDictionary>

Generic.xaml

   1: <ResourceDictionary
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:     >
   5:     <ResourceDictionary.MergedDictionaries>
   6:         <ResourceDictionary Source="/WpfControl;component/Themes/MyTemplatedControl.xaml" />
   7:     </ResourceDictionary.MergedDictionaries>
   8: </ResourceDictionary>

Now we “Add As Link” MyTemplatedControl.xaml to our Silverlight project and add a copy of Generic.xaml and make required changes.

Generic.xaml (Silverlight project version)

   1: <ResourceDictionary
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:     >
   5:     <ResourceDictionary.MergedDictionaries>
   6:         <ResourceDictionary Source="/SlControl;component/MyTemplatedControl.xaml" />
   7:     </ResourceDictionary.MergedDictionaries>
   8: </ResourceDictionary>

Notice the differences in Source of ResourceDictionary:

  1. It refers to out Silverlight assembly (SlControl)
  2. It addresses linked XAML file by it’s “incorrect” resource key which is a side effect of linking the XAML file described above (notice that there’s no “Themes” portion in the path)

Now our Silverlight app runs as expected:

image

This way we can share elaborate XAML between WPF and Silverlight versions (or just between several WPF and/or Silverlight projects) without having to maintain 2 versions of the file. And the only price to pay for this is that we have to add a line to both Generic.xaml files every time we add a new XAML file.

kick it on DotNetKicks.com Shout it

My Entry in MIX 10K Challenge

12/22/2009 11:00:17 AM

ttt3d500 

My entry in MIX 10K Challenge has been published. For those who don’t know the challenge is a contest where participants create small apps with combined source code size of up to 10kb. The grand prize is a trip to Las Vegas to MIX 2010 conference.

My entry is a Silverlight 3D Tic-Tac-Toe game. Check it out, vote, tweet, retweet, show your friends and co-workers. Send me to Las Vegas!

Thanks.

Tags:

Stock Chart for WPF & Silverlight 1.1 Released

12/17/2009 9:49:04 AM

amCharts Stock Chart for Silverlight and WPF

We’ve shipped final version 1.1 of amCharts Stock Chart for WPF & Silverlight. Now there’s a powerful (and FREE) advanced financial charting control for Silverlight and WPF. Key additions in this release are:

  • Silverlight version based on the same code base as WPF
  • 3 new EventBullet types: VerticalBand, HorizontalBand and GraphHighlight;
  • support for mouse wheel scrolling and zooming;
  • support for different colors for positive and negative columns in column graph;
  • performance improvements.

More details can be found in the official announcement.

Tags:

Copyright © 2003 - 2010 Alan Mendelevich
Powered by BlogEngine.NET 1.5.0.7