Monday, December 03, 2012

How Deep Are Your Unit Tests?

This is one of my favorite StackOverflow questions and answers: http://stackoverflow.com/questions/153234/how-deep-are-your-unit-tests

Kent Beck answers:
          
I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence (I suspect this level of confidence is high compared to industry standards, but that could just be hubris). If I don't typically make a kind of mistake (like setting the wrong variables in a constructor), I don't test for it. I do tend to make sense of test errors, so I'm extra careful when I have logic with complicated conditionals. When coding on a team, I modify my strategy to carefully test code that we, collectively, tend to get wrong.

Different people will have different testing strategies based on this philosophy, but that seems reasonable to me given the immature state of understanding of how tests can best fit into the inner loop of coding. Ten or twenty years from now we'll likely have a more universal theory of which tests to write, which tests not to write, and how to tell the difference. In the meantime, experimentation seems in order.


As the first comment says:

The world does not think that Kent Beck would say this! There are legions of developers dutifully pursuing 100% coverage because they think it is what Kent Beck would do! I have told many that you said, in your XP book, that you don't always adhere to Test First religiously. But I'm surprised too.

In case you don't know who Kent Beck is: http://en.wikipedia.org/wiki/Kent_Beck

Sunday, December 02, 2012

Sphero - Ball control - introduction video

Ball Control - hopefully coming soon to the Windows Phone 8 Store :)

Saturday, December 01, 2012

Sphero App submitted to Windows Phone Marketplace

I've submitted :)

My first WP8 app.

Don't know whether it will pass first time!

Below are some screenshots

Stuart

Friday, November 30, 2012

BallControl - an open source Sphero C# controller - WP7, MonoDroid and hopefully MonoTouch (and WinRT?)

Meet my latest open source project - meet BallControl for Sphero:


Here's a first video I made for the project - sorry about the low audio volume!


Xamarin the Native, Sphero the Ball and Lumia the Phone....

After a long week of coding, this experiment in sleep deprivation reaches its inevitable conclusion....

Featuring:
- Xamarin.Mobile Picture capture
- Native voice control
- Native accelerometer control
- Native UI with lots of touch
- Native BlueTooth
- Guest Starring Sphero the ball
- Cross platform Mvvm

Xamarin the Monkey....  because going Native matters

Can I sleep now?

Here's the apps first public outing to a local user group:


Some technical info

The project demonstrates Xamarin.Mobile by using Xamarin.Mobile media picker.... But, beyond that it also extends Xamarin.Mobile tackling some elements of several Xamarin.Mobile requests on uservoice:

The Source

The source is on: https://github.com/slodge/BallControl

Currently, we have:
  • a working WP8 app
  • a working (but ugly) MonoDroid app
  • a non-working Windows Store app - it seems that Windows Store does not yet support BlueTooth SPP devices - which is so bad :(
I will get a MonoTouch app working soon....

I will also post to the WP8 app store soon.

And I will post some more videos soon....

If anyone is interested in how the app was built I did live blog the first 10 hours of coding... see PDF at http://sdrv.ms/V8xdmV (or email me for a Word doc). Sorry I didn't blog the whole lot - but there was a lot of code to write... and I did it in 5 days end-to-end while still holding down the day job too.

That's AmazeBalls! How do I get a Sphero:


If you want a sphero, then try:

If you cannot open your WP7 Project in Visual Studio 2012!

For the last month I've been swearing at the Visual Studio 2102 and WP8 teams...

The reason: because when I open my WindowsPhone 7 solutions, then it shows them as "unavailable" - which makes me very very sad - because I have to use VS2010:


However, last night @dsplaisted asked me if I'd tried right-clicking on them and reloading them.

It worked

I can now open my Windows Phone 7 projects in VS2012 :)

Apparently, the problem was:
  • I first tried to open this solution before the WP8 SDK was installed
  • Visual Studio 2012 didn't know about how to open these - so it marked them 'do not open' in my solution options.
I am sooooooooooooo glad I can open all my projects in VS2012 again!

Wednesday, November 28, 2012

If you cannot see WP8 packages in nuget....

Then you need to install a newer version of nuget - http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c

I just wasted 30 minutes of my life trying to work out where the Phone Toolkit had gone and why I couldn't install it... ah well....

:)

An awesome sample - Wish List from Redth

An awesome sample of using Azure Mobile Services, Azure Web Sites, MvvmCross, ZXing.Net bar code scanning and Xamarin.Mobile too:



Source code is on https://github.com/Redth/WshLst

There might be some blogging on it at Redth.info and some tweeting from @Redth
  • if I were being critical:
    • it is currently a bit 'code heavy' in the UI layer, 
    • there are some #if things in the core code
    • the lack of portability support in Azure Mobile Services and in Xamarin.Mobile has forced it away from PCL which is a shame
  • but overall:
    • it's amazeballs - check it out!

Tuesday, November 27, 2012

A simple multitouch view for MonoDroid

I needed a multitouch view for MonoDroid (Mono for Android), so I built one :)

I based it on
http://android-er.blogspot.co.uk/2011/05/detect-multi-touch-on-custom-view.html

It seems to work quite well - to see it in action, just include it in your project and then you can use it in your axml or in your C#


The code:

Monday, November 26, 2012

MvvmCross on the TabletShow :)

Thanks to @MrLacey for this tipoff: http://www.thetabletshow.com/default.aspx?ShowNum=60

What they said (about 30 minutes in):
It's basically an Mvvm framework using the Xamarin tools. It takes it all the way up to the UI layer, so that the only thing you are building is, for example on the Windows 8 side, just the XAML; on the iOS side just the XML that describes the screens; and the same thing on the Android side.
And you're binding - that's it!
Everything else from that UI definition down is all shared code - so you're basically building almost your entire app with shared code. You're just defining the views each time.
There were plenty of "So Cool", "pretty exciting" and "Awesome" comments thrown in - and some inciteful remarks about:
  • the importance of native UI
  • how MvvmCross provides you a native UI
  • how it allows you to swap out views on each platform
  • how it helps lower the cost of native development
  • and about how MvvmCross is ideal for business apps

Thanks to John Sonmez and the Tablet Show team for the nice comments about the 'huge potential for cross-platform development' :)

Sunday, November 25, 2012

Happy 1st Birthday to MvvmCross - How hard can it be...?

It's official: MvvmCross is 1 year old this week!

The MvvmCross story started early in November 2011 when I started work on the Star Wars Kinect social app.

I had a plan to technically build that app using WindowsPhone, MonoTouch and Mono for Android, and I had a basic WindowsPhone prototype that I'd hacked together using TweetSharp and some code-behind... but, beyond that, I really didn't know what I was building or how I was going to do it.

Luckily, towards the middle of the month, MonoCross 1.0 was released. I downloaded it eagerly, and also struck up some online conversations with some of the MX guys, especially Kenny Goers who patiently and skillfully dealt with all of my queries.

Over the next week or two I talked, walked and typed through lots of code. There were lots of prototypes written, lots of emails and code exchanges back and forth, and lots and lots of time spent swearing at compilers, debuggers and phones.

I *loved* what the MonoCross guys had done in trying to put down a rigid MVC structure for their apps - in trying to provide a formal structure for sharing code cross-platform. However, I also hit a few problems with the MVC pattern itself, with the way MonoCross memory management was architected and with the static nature of the MX code base.

To try to work around these problems somewhere around the 25th November, I checked in my first Cirrious.MonoCrossExtensions commit - and Kenny and I again exchanged some emails - especially about memory management, about IoC and about charging forwards...

It was also at about this point that we had a technical meeting inside the Star Wars Kinect project... and at some point during that meeting one of myself or John McLoughlin (imaji on Twitter) said something like:
We could just go the whole way with Mvvm. How hard can it be?
That question hung there for a while....
How hard can it be....?

And so... on the 28th November I ended up abandoning Cirrious.MonoCrossExtensions and commiting the first files into Cirrious.MvvmCross

This was the first proper MvvmCross commit - 'OMG! What haz I done?' - just 280 changed files and 60,000 additions...

The rest, as they say, is history :)

Happy Birthday Mvx!

Thursday, November 22, 2012

ThanksGiving post - Thanks for more Portable Class Library/Portable Library Project solutions for MonoTouch/MonoDroid

On this day of ThanksGiving in the US....

Thanks!

I'm really grateful for some of the input I've gotten recently from Microsoft and Xamarin.

Especially:

1. Daniel Plaisted at Microsoft has just heroically supplied a detailed idiot-proof solution to the strong naming issues for ICommand, ObservableCollection, etc.

This solution is:

I think this is what you need to do to get around the type sharing / strong name signing issues for portable libraries on Mono:

-> Extract the public key of System.Windows.dll, and put it in the project directory for the Droid System.Windows project:

 Sn –e "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\Profile104\System.Windows.dll" system_windows.snk  

-> Modify the Droid system.windows project to delay-sign using the extracted key. Put the following in a PropertyGroup in the csproj file:

<SignAssembly>true</SignAssembly>  <AssemblyOriginatorKeyFile>system_windows.snk</AssemblyOriginatorKeyFile>  <DelaySign>true</DelaySign>  

-> Change the assembly version of the Droid System.Windows project (in AssemblyInfo.cs) to:

2.0.5.0   

In my testing, I didn't seem to need to disable strong name verification. So I don't think it will present any extra barriers for newbies – once you have these changes made they'll just need to get your code and it will build correctly.

However, if you do run into problems, try running the following from an admin VS command prompt:

 sn -Vr *,7cec85d7bea7798e   

Let me know how this works!

I've tested it - it seems to work really, really well :) This solution is now pushed into vNext at https://github.com/slodge/MvvmCross/commit/f6a88048467838e5ac5ca687744dc0b2d1958aa8

It seems to solve:
- http://stackoverflow.com/questions/13028321/portable-class-library-strong-assembly-reference-problems-in-monotouch-monodroid
- http://stackoverflow.com/questions/13197546/mvvmcross-vnext-observablecolletion-is-defined-in-an-assembly-that-is-not-refer

2. The Xamarin team for solving all the issues caused by sln file changes in VS11/VS2012 - https://bugzilla.xamarin.com/show_bug.cgi?id=4919

These changes may sound trivial, but they've been making code sharing very hard since May this year - and it's great that I can now dropbox/skydrive share my projects and solutions again now between Mac and PC :)

3. Michael, Alan, Jeff (and others) within Xamarin for fixing the problems with building the new Profiles - including 104 - https://bugzilla.xamarin.com/show_bug.cgi?id=7173

I hope by naming a few people I haven't upset anyone else who's helped.

I really am grateful to everyone who's helping  :)

Now... I'm going back to write some more PCL code... :)

Tuesday, November 20, 2012

Merging vNextDialog back into vNext

Firstly.... apologies if these changes cause you any problems... but I've tidied up the source tree in vNextDialog and I think these changes will have positive benefits for all users. So I'm merging the changes back into vNext.

The key details of the changes are:
  • Dialogs
    • I've added a version of Android.Dialog/MonoDroid.Dialog to the source - this is in CrossUI.Droid
    • I've added a PCL library - CrossUI.Core - which contains the shared Dialog/Menu/List code
    • I've moved the MT.Dialog code out of MvvmCross Dialog and back into a CrossUI.Dialog class
  • AutoViews
    • I've added projects for AutoViews - these aren't finished yet... but are a very good step in the right direction!
    • I've added an AutoView sample - based on CustomerManagement. This isn't a 'best practice' sample - it's more a 'here's 3 ways of using autoviews' - so may not be easy to follow yet.
    • AutoViews currently only exist for MonoTouch and MonoDroid
  • Build Paths
    • I've changed the build paths so that all the DLLs build into /bin/debug and /bin/release 
    • Importantly this means it should be easier to do a binary release of MvvmCross again soon :)
    • One side effect of these changes is that you probably won't be able to build both of Droid/Touch at the same time - this is because they will fight over the System.Windows and System.Net Assembly names - but otherwise they should still build individually.
  • MonoTouch project configurations
    • The MonoTouch library projects are now switched to simpler Debug/Release only - I'll try to maintain this as we move forwards! 
If these changes break your code.... sorry

The main things that will need changing to get you back building are:
  • If you were using MonoTouch.Dialog, then you will need to add the CrossUI.Core and CrossUI.Dialog projects and you will need to change some Cirrious.MvvmCross.Dialog.Touch.Elements namespaces to CrossUI.Touch.Dialog.Elements
  • If you were relying on the iPhone/iPhoneSimulator project configurations, then you will need to use the Configuration Manager to adjust these back to simpler Debug/Release dependencies.
Sorry again for making these changes so suddenly... but I was informed today that a new user was having problems building the main tree... and I wanted to fix these problems.

This merge back seemed like the best way to fix them and to provide the best possible platform moving forwards.


Monday, November 19, 2012

Cross Platform .Net Podcast from Jesse Liberty, Jon Galloway and Miguel de Icaza

@JesseLiberty, @jongalloway and @migueldeicaza discuss open source and Mono things including a couple of discussions around MvvmCross and MonoCross :)

Worth a listen - there's lots of good technical info; interesting questions like 'what does Miguel do all day?'; some great phrases like 'the delight of using Native APIs'; an intriguing comment right at the end about a major product launch next year - "a universe of goodness"; plus some interesting background on the relationships between Mono, Ximian, Novell, Xamarin, MonkeySpace, Microsoft and ... of course ... Monkeys :)



For the audio: http://jesseliberty.com/wp-content/media/Show80.mp3

For a background post: http://jesseliberty.com/2012/11/08/yet-another-podcast-80miguel-de-icaza-mono/

Thanks for the mentions :) I really want to know what the product next year is now :)

Saturday, November 17, 2012

AlphaLabs Node Garden - adding speech

My first attempt at a play with the AlphaLabs Node Garden.

I thought using the screen was too much like manual labour - so I thought I'd try voice control.

The verdict - wow, is it simple to add voice control to your apps!






wp8: speech is off until your new language pack has been installed

If you see the error 'speech is off until your new language pack has been installed'

Then this might just be because you've switched your phone from one language to another.

To get over this problem...
  • go to Speech in Settings
  • tap on the language box
  • choose your language (even if it's your existing language)
  • you'll then be asked to download it.... (needs WiFi really)
  • after the download, the phone will need  a reboot...

The speech privacy policy was not accepted prior to attempting a speech recognition

If you are trying to use SpeechRecognition and you see this general Exception - "The speech privacy policy was not accepted prior to attempting a speech recognition" - or possibly you see the "The text associated with this error code could not be found."...

Then the answer is http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662934%28v=vs.105%29.aspx#BKMK_Handlingthespeechprivacypolicyerror

Basically - try pressing and holding the start key - then getting the user to accept the terms and conditions...

Also, in your own app... it seems like maybe you need to be sure you are requsting the speech recognition in an async call on the UI thread?

Some low light pictures taken with a Nokia 920

I took a Nokia 920 out for a run this morning.

It was a real Autumn day... rainy... overcast... gloomy...

Which made it perfect to test out the PureView floating lens in the 920 :)

These photos are just 'snaps' taken on the run... and the deer in Bushy Park weren't being at all friendly... but I'm definite that 'yes, the 920 has a quite nice camera!'













Friday, November 16, 2012

Aviva - Drive.... An MvvmCross Testimonial

Back at the end of the Summer I got this email through from a Solution Designer in Aviva - a very large UK Insurance company:

Thought you'd like to know that we are using MvvmCross in our RateMyDrive app that is currently being Beta tested: http://www.aviva.co.uk/ratemydrive/
There's been a fair amount of press about it, and it's even been on the telly:  http://www.bbc.co.uk/iplayer/episode/b01m9396/Click_18_08_2012/  (fast forward to 9:08)
So a big thank you for the major contribution your framework has made to this project. It has allowed us to share the complex algorithms for deriving the driver rating scores between Android, iOS and Console/Test apps. In fact 90% of the code is shared and easily testable.

This project is still ongoing - http://www.aviva.co.uk/drive - and I think the above quotation says everything you need to know about MvvmCross.... :)


If you've been using MvvmCross, and you have any feedback, then please do send it to me :)

Hackery and WitchCraft - First AutoViews running on MonoTouch too

Following on from the MonoDroid work, I've started pushing some MonoTouch changes now for AutoViews too...

And after only a few hours - mostly filled with Reflection swearing - I now have this list view:


and this Dialog view:


These screens generated from the exact same code and JSON as the Droid UIs in Another update on the Default UI work for MvvmCross....

There's still a lot of code to write... and lots of debugging to go...  especially when I move to release builds on real devices....

But so far so good :)

Thursday, November 15, 2012

Free icons for ASP.Net, WinRT and WP development...

These are some of the icon sets I've used in the past - generally Creative Commons - and always used with attribution.

For maps:
http://code.google.com/p/google-maps-icons/

For general use:
http://www.famfamfam.com/lab/icons/
http://code.google.com/p/fugue-icons-src/ - preview at: http://p.yusukekamiyamane.com/icons/preview/fugue.png

For WinRT/WP7
https://github.com/Templarian/WindowsIcons

- plus SyncFusion have a free set which is growing big now - http://www.syncfusion.com/downloads/metrostudio

- plus BootStrap from Twitter has some interesting icons built-in