Hello Android!
I’m making my first Android App with IntelliJ Community Edition.
Here’s a great Hello Android tutorial:
Following the video, I got my own Hello Android app working. Cool.
DroidDraw is a nifty wysywig layout designer. It may be outdated but it keeps me out of Eclipse. Last time I used Eclipse, it was horribly slow, but with all the cool Android support it has, I’m likely to give it a try again.
Now the app shows up in my emulator and I even added some checkboxes that I’ll be using later.
All in all, this tiny bit of Android development is looking very xamly.
The only hitch was that the emulator doesn’t like spaces in the names of virtual phones.
No x:Type, No Problem
I had an interesting problem this week. I needed to use a default template on a subclassed control. Ordinarily, that would just be:
Style=”{StaticResource {x:Type BaseClass}}”
Of course in Silverlight, there is no x:Type.
The solution I used was to make an attached behavior that takes the class that has the style, finds the style in the resources and applies it.
The problem
Using a TextBox as an example, here’s some default styling that doesn’t get applied to the subclass:
It ends up looking like this:
The Solution
With an attached behavior, it can look like this (the bottom TextBoxSubclass has the default TextBox style applied):
The attached behavior is pretty simple:
static void StyleTypeValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
Conclusion
I think its exceedingly obvious how you could apply this universally as a default style on the subclass. This looks like it has potential to be a pattern to compensate for other Silverlight omissions too.
Book Review: Unity 2.0
To start my current dive into the state of WPF composition and IoC frameworks I read the Unity documentation book: Unity 2.0 General Purpose Dependency Injection Mechanism for your .Net Applications. I’m rather familiar with Unity, but it seemed time for me to finally read the docs to see if I was missing anything. The book is a pdf freely available on the Unity Codeplex Page.
The book is as dry as the desert sands of Arrakis. You wont find gripping prose found in such tech classics as Naked came the Null Delegate. Also, it leads with 70 pages detailing xml configuration which in an informal survey, I found exactly 0 people in favor of over runtime configuration. The book is also not entirely thorough and in depth, though I believe all Unity 2.0 features are covered. So it works pretty well as a shopping list for further web research. The most annoying thing about this book is that there’s a ton of blue text with blue underlines that aren’t hyperlinked. Click and click and go nowhere. There oughtta be a law against this:
In any case, I found what I wanted to know which was if I read the book, would I learn anything about Unity that I didn’t already know. Spoiler Alert. The answer was yes, but not by much.
One of the best paragraphs in the book explained Unity itself:
Application Design Concepts with Unity
Features such as inversion of control, dependency injection, interception, factory, and lifetime… provide several major advantages when building applications that consist of many individual classes and components. Designing applications that conform to these patterns can provide the following:
The capability to substitute one component for another using a pluggable architecture.
The capability to centralize and abstract common features and to manage crosscutting concerns such as logging, authentication, caching, and validation.
Increased configuration flexibility.
The capability to locate and instantiate services and components, including singleton instances of these services and components.
Simplified testability for individual components and sections of the application.
Simplified overall design, with faster and less error‐prone development.
Ease off reuse for common components within other applications.
Then again, the Unity Home Page may do an even better job.
I’ll flesh out a few details from the book in my next post.
Caliburn–Hasta la Vista
My Caliburn project is over. A couple of thoughts.
I liked Caliburn Micro. The best thing was that it makes it easy to connect events and methods — where you would normally use a DelegateCommand/ICommand and binding, now you get simple by convention auto wireup. The worst thing is that using convention to autowire VM to View doesn’t show mock data in Blend for my favorite mock data objects which are subclasses of the VM, so I ended up using explicit bindings in the Xaml and not using a big benefit of Caliburn.
Caliburn Micro–Soup to Nuts
Just getting into Caliburn Micro for a new Silverlight project. I was a bit disappointed when I saw that the official cheat sheet was “coming soon”. Rob Eisenberg made this excellent 9+ part Soup to Nuts tutorial and the Soup to Nuts section of the documentation has content, so the documentation for Caliburn is actually pretty good. Of course, both these resources suffer from the death of the long form. Once again I had to convert them to pdf so I could read them on the subway. Maybe next time I’ll try this utility.
In any case, I’m excited to try out Caliburn Micro and my experience so far has been positive, but more on that later.
3 New Favorite Techniques in Visual Studio
Here’s 3 techniques in Visual Studio that have lately become favorites of mine.
Breakpoint Output Logging
In my previous post on output logging with breakpoints, my colleague Ken Overton, pointed out the existence of something that used to be called “TracePoints”. I went looking for these mythical beasts and was pleasantly surprised to find the “When Hit” option for breakpoints. It’s available in the breakpoint right click menu.
You can output text and variable values when the breakpoint is hit instead of stopping:
The logging will show in the Output Window. On the downside, it slows down program execution speed, seemingly more than conditional and regular breakpoints.
Object ID
My colleague Andrei Kashcha, master extraordinaire of debugging techniques, shared this with me and I’m starting to use it regularly. When you make an “object id” for a class instance, its a globally available reference to that instance for debug inspection and can be used to breakpoint in a single instance or verify which instance you are looking at.
To “Make Object ID”, just select that in the watch window context menu for an initialized variable.
That instance can now be referenced globally as 1#:
And to breakpoint in just that instance, set a conditional breakpoint with the condition “this == 1#”:
ReSharper Class List Navigator
I see a lot of people using this, but its recently become my goto navigation method. For those of us ReSharper fans (with standard R# key mappings), just press ctl-t and up pops a handy class navigator that supports filtered search with partial class name and Pascal Cased abbreviations such as AVLCN for AVeryLongClassName.
Metup June 2011
The .Net Meetup in June was well attended with a strong Lab49 contingent in attendance. The topics and speakers were a big draw for me. All that and pizza too. I enjoyed it.
FSharpSpec
Thorsten Lorenz gave a high level introduction to BDD and detailed his testing framework FSharpSpec. The B is for behavior and I’m sure you know about the DD part.
I was quite impressed with Thorsten’s feature rich unit tester. His comparison of frameworks reminded me that there’s more to testing than coverage. He even has his own mocks. Pretty clever.
I was looking forward to hearing Snuggs speak about Git. He’s widely versed in technology and a character to boot. He did not disappoint.
I’ve heard about Git several times before, but never enough or in the right way to see why I should be using it. Snuggs told us about about the internals, that its all about the branches and how awesome single feature commits and rollbacks can be. Don’t forget about GitHub “it’s like facebook for programmers”.
Something definitely clicked and for the next few days I was repeatedly seeing issues I expected Git would help resolve better. I heard that some clients are using Git, so I can definitely see Git in my future.
@Lab
Geeky Fun
Fire up your What If Machine

What if Visual Studio had Achievements?
Choose a Side or Get Out of the Way
Flash & HTML5 Together?
The classic game of pong comes back to life with Flash & HTML5.
An example of how flash and HTML5 can coexist in web applications. This is a table tennis game where half of the table is implemented in Flash and the other half is an HTML canvas.
Reflector.Cost != (decimal)0.0;
Extract Styles in Blend
Cool tip from the Dotneteers on extracting styles in Expression Blend.
Monads, Duals, and MinLink
This monad tutorial sparked a discussions and comment from our resident experts. This talk sounds interesting. Unfortunately its in England, and in the past, 2 barriers I’m currently having difficulty with.
Then again, maybe monads don’t matter.
above: Bart De Smet: MinLINQ – The Essence of LINQ – also related to Monads
Hmm… What’s a Code Review Site Good For?
SQL Replication works great IMHO, windbg, Gateway.NET, Air Printing, Hadoop, Esper, Mono
CodeCamp
Lab49 is sponsoring a Code Camp in February. You too can speak.
Code Camps are “grass roots” mini application platform developer conferences, free of charge to attendees and open to presenters of all stripes and experience.
SqlDbx

I met the developer of SQLDbx and I was impressed. It’s a sql coding and data management utility in a single exe with no 3rd party dependencies written in c++. Perfect for running off cd or thumb drive. If I were still working with databases (not) I bet this would make my shortlist of favorite utilities. You can decide for yourself with the free personal edition.
Losing my Memory
After fixing the classic event handler reference memory leak, I uncovered a WPF memory leak in my application. It seems that WPF itself has a memory issue in the way it tries to lazy load dictionary resources.
I had a lot of additional memory in snapshot diffs being taken up by DeferredAppResourceReference objects. There seems to be a Hotfix that addresses the issue, but I found a decent code solution by Andrew S on MSDN. This code will instantiate the dictionary objects on startup, avoiding the buggy MS lazy loading.
Ironically, now one of the largest growth objects in my app is WeakReference.



