charity, Windows Phone 7, programming, paypal, WP7, hacking »

[23 Sep 2010 | 3 Comments]

So I went to Charity Hack and as promised have put together a video of the event.

The Event

It was a great event (again) with the standard of apps even better than last year. John Lunn has done a write up of the event with videos of all the winning hacks.

There is also a great write up by Ben Matthews about all 18 entries which is well worth a read to get a overall feel of the event. http://benrmatthews.posterous.com/28520434

There is also a great photo stream here of the event: http://www.flickr.com/photos/martin_88/with/5004083392/

Our App

We created a Windows Phone 7 app which used a number of API’s provided by JustGiving and PayPal to collect the donations from users. We only had a limited time to learn what the development tools for Windows Phone 7 could do but it was really easy to pickup and get something doing pretty complex api calls in a very short time. It does an number of restful web service calls in the background which was made even easier with the http://restsharp.org/ library. We were really pleased with the outcome so please enjoy the video!

MS CRM4, MS CRM, C#, programming, Software Developement »

[17 Sep 2010 | 0 Comments]

Now this might seem like something that would be easy to do but I’ve just spent 2 days struggling to do just this because of what I consider a bug in one of the SDK wrappers. I have now found a work around to enable unit testing which I will share with you now.

The Error message

Test method XrmEntityWrappers.Tests.CaseEntity.GetCaseByTicketNumber threw exception:  System.TypeInitializationException: The type initializer for 'Microsoft.Xrm.Client.Caching.Cache' threw an exception. --->  System.IO.DirectoryNotFoundException: Could not find a part of the path 'appDomain=UnitTestAdapterDomain_ForC:\Projects\Thg.Ohov.Crm\SourceCode\Thg.Ohov.Crm\TestResults\dh27_WIN-51UPWVCUQ6V 2010-09-16 18_21_40\Out\XrmEntityWrappers.Tests.dll:key=Microsoft.Xrm.Client.Caching.InMemoryCacheProvider'..

System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
b__0(Object userData)
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean& createdNew, MutexSecurity mutexSecurity)
System.Threading.Mutex..ctor(Boolean initiallyOwned, String name)
Microsoft.Xrm.Client.Threading.MutexExtensions.Lock(String key, Int32 millisecondsTimeout, Action`1 action)
Microsoft.Xrm.Client.Threading.MutexExtensions.Get[T](String key, Int32 millisecondsTimeout, Func`2 loadFromCache, Func`2 loadFromService)
Microsoft.Xrm.Client.Threading.MutexExtensions.Get[T](String key, Int32 millisecondsTimeout, Func`2 loadFromCache, Func`2 loadFromService, Action`2 addToCache)
Microsoft.Xrm.Client.Threading.MutexExtensions.Get[T](String key, Func`2 loadFromCache, Func`2 loadFromService, Action`2 addToCache)
Microsoft.Xrm.Client.Caching.InMemoryCacheProvider.GetExtendedCache()
Microsoft.Xrm.Client.Caching.CacheManager.GetExtendedCache()
Microsoft.Xrm.Client.Caching.Cache..cctor()
Microsoft.Xrm.Client.Caching.Cache.Get[T](String label, Func`2 load)
Microsoft.Xrm.Client.CrmConnection..ctor(String connectionStringName, String connectionString)
Microsoft.Xrm.Client.CrmConnection.Parse(String connectionString)
Thg.Ohov.Crm.Core.XrmEntityWrappers.XrmAdapter..ctor() in C:\Projects\Thg.Ohov.Crm\SourceCode\Thg.Ohov.Crm\Core\XrmEntityWrappers\XrmAdapter.cs: line 28
Thg.Ohov.Crm.Core.XrmEntityWrappers.incident.get_XrmAdapter() in C:\Projects\Thg.Ohov.Crm\SourceCode\Thg.Ohov.Crm\Core\XrmEntityWrappers\incident.cs: line 25
Thg.Ohov.Crm.Core.XrmEntityWrappers.incident.GetIncident(String caseId) in C:\Projects\Thg.Ohov.Crm\SourceCode\Thg.Ohov.Crm\Core\XrmEntityWrappers\incident.cs: line 44
XrmEntityWrappers.Tests.CaseEntity.GetCaseByTicketNumber() in C:\Projects\Thg.Ohov.Crm\SourceCode\Thg.Ohov.Crm\XrmEntityWrappers.Tests\CaseEntity.cs: line 23

The reason for the error

The Microsoft.Xrm.Client.dll tries to create a Mutex object with the

Thread.GetDomain().FriendlyName;

When running ordinary in a console app or web app this is not a problem as the FriendlyName does not contain any ‘\’ characters. However UnitTest frameworks do put ‘\’ characters in the GetDomain().FriendlyName which then causes the Mutex object to throw a ‘System.IO.DirectoryNotFoundException’.

The fix

The real fix is for Microsoft to update the Microsoft.Xrm.Client.dll so that it doesn’t put any ‘\’ characters into the Mutex constructor. However my work around for this is thanks to Nick Watkins who found this article on how to change the GetDomain().FriendlyName

http://www.timvasil.com/blog14/post/2008/11/Fixing-Instance-names-used-for-writing-to-custom-counters-must-be-127-characters-or-less.aspx

The key bit of code being this if you want to set the FriendlyName to ‘Test’ (which doesn’t have any ‘\’ characters!):

typeof(AppDomain).GetMethod("nSetupFriendlyName", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(AppDomain.CurrentDomain, new object[] { "Test" });

To rename the GetDomain().FriendlyName before calling any of the wrapper code in the unit tests. So the test might look a bit like this:

[TestMethod()]
        public void GetIncidentTest()
        {

typeof(AppDomain).GetMethod("nSetupFriendlyName", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(AppDomain.CurrentDomain, new object[] { "Test" });

            string caseId = "1234"; // TODO: Initialize to an appropriate value
            incident expected = null; // TODO: Initialize to an appropriate value
            incident actual;
            actual = incident.GetIncident(caseId);
            Assert.AreEqual(expected, actual);

}

Summary

I’m happy now I can unit test my custom code that uses the xRM Wrappers and I hope that my support call with Microsoft will result in the SDK dll being updated.

WP7, Software Developement, programming, Windows Phone 7 »

[29 Jul 2010 | 1 Comments]

Just writing a quick article about going to the first Windows Phone 7 User Group @wpug last night. With the device release within touching distance I get a feeling there is more and more excitement growing about the device and what developers will be able to do with it.

First off a bit thank you to Matt Lacey for organising the event, EMC Consulting (especially Michelle Flynn)hosting the event and Microsoft for great information about what is happening, buying beer and showing off some prototype phones.

It was a great format, an opening presentation then 5 demo’s from participants an a closing presentation.

Is Microsoft doing any thing new?

Personally I don’t think that there is anything particularly new in what Microsoft is offering. What is new is how it has been packaged up and delivered to the end user with a lovely new handsets and OS. The core components of building applications on Windows Phone 7 are:

  • Visual Studio
  • Expression Blend
  • Silverlight
  • Xna

wpug All these tools are tried and tested, they are well known, they have excellent support from both Microsoft and the development community. I think this is fantastic, it really lowers the risk of developing an app for this device. Microsoft are just leveraging these existing technologies to make development easy.

 

 

 

Is Microsoft doing anything differently?

I think this is a big YES. Microsoft know that it is them ‘on the hook’ for the user’s experience so they are taking ownership of a lot of what controls this.

The devices are new but Microsoft have set a very high minimum specification for the hardware manufacturers. This is again excellent news, I feel that a number of the Windows Mobile handsets were underpowered and gave a poor user experience.

The Marketplace is the only way that you can get apps onto your handset (unless you have unlocked your phone via a Marketplace developer account). Again this is excellent news for two reasons.

  • Before finding an app was hard. They were very distributed with a few 3rd party market places or vendors selling their apps on their own websites. The new Marketplace means that there will only be one place to look and one way to purchase which puts this important part of the user experience right in Microsoft’s control
  • Microsoft can ensure the quality of the apps that are put on the Marketplace. This should mean that people don’t pay for or have to wade through 1000’s of sub quality apps that would reduce that all important user experience.

The last thing which I think will make a difference is how controlled 3rd party software is on the device. While the device is multi-tasking 3rd party apps are not allowed to leverage this. The reason being that badly behaving applications running in the background could drain the battery, use cpu and generally slow down the device. Making 3rd party software exit when a phone call is received for example is a sensible approach but a little frustrating for us developers.

A big thanks to Microsoft’s Paul Foster for his very interesting session about what’s going on with Windows Phone 7 and an even giving me the chance to use his prototype phone.

It is easy to create an application

Yes it is very easy. The development tools are free and can be downloaded from http://developer.windowsphone.com/ .

There are some excellent tutorial labs to follow which are very clear and easy to follow. They touch on all the key points of development using the development tools and the Windows Phone 7 os. I blogged about my attempt to create an iPhone app back in January which was a horrendous experience, I found this process much clearer and painless. I have been a .Net developer for 10 years which probably helped but I’m sure that the Microsoft tools are far superior to Apple’s XCode IDE.

Rob Fonseca-Ensor showed how easy it was to create an Xna game on the phone, and it was surprisingly easy. Create a picture, load it in the app and then pop it on the screen and that was about it.

At the user group there were 5 demo’s of apps that people had created. The app which I thought was the best (although I naturally voted for myself!) was Hosain’s tube app. It was a beautify clean design with lots of useful information being displayed from a data feed on the TFL website. I spoke to him afterwards and he had only spent about a week on the app, very impressive.

Other slick apps that were shown where UkTree’s CryoDefense which was a Tower Defence game. This was a very nice game created by seasoned mobile developers.

 KeyboardP had created a really nice app to store information that can be used In Case of Emergency (ICE) he also had the best line of the night:

“I hope you buy my app and never use it” KeyboardP

 

I didn’t spend much time on my app at all It was a client to read and display skillbooks from my www.skillbook.co.uk website. I spent a day doing the labs I downloaded and then a day writing the bulk of my app and it was really really easy. I had another few hours to do a few tweaks on the app but in total probably about 12 hours, plus it was the first time I had used Silverlight. I didn’t win the X-Box but I hope people found the concept useful, here is a video of my demo:

A video of me demoing my Skillbook App

 

 

 

 

 

 

 

 

 

 

 

Summary

I really enjoyed the event, it was great to see Microsoft engaging with the development community and to also see what other developers are doing on the platform.

I was pretty sceptical about the ‘new windows phone’ when I first heard about it because of the previous pain I have had with Windows Mobile. However Windows Phone 7 is a completely different beast and looks fantastic, and I for one am getting very excited about it’s launch in the not too distance future!

Software Developement, programming, Scrum »

[5 Mar 2010 | 2 Comments]

I have been following a new blog by Tim McOwan called www.devballs.com and it focuses on delivering software using a Scrum Process.

His latest article, Guess What? Scrum Developers should be cutting code, period! has provoked some interesting comments and my comment turned out to be so long I decided it should become an article in it’s own right. The comment I was replying to was from Jason Gorman, in a nutshell it was that Business Analysts are not required developers should work directly with the customer.

While I understood what was being said I could not agree with that point of view and it seems that it would be throwing the baby out with the bath water. It sounded very Us and Them which is a bad place to be and seemed to be describing problems associated with a waterfall approach rather than scrum.


I'm a developer and have learnt some very hard and expensive lessons over the last 2 years about the holistic success of software projects, not just [more] the technical success. This has given me a very different view and appreciation of what non-technical people bring to the overall success of a project, essentially removing that developer chip on my shoulder.

I strongly believe:
1)    That BA's can have an important role but are not always essential.
2)    Having a good manager is a must
3)    Using Scrum properly means that everyone knows and values what everyone else is doing.

The Manager

The reason you need a good manager / scrum master is to protect your developers from the customer and enforce the Scrum rules. They ensure the bits of the project jigsaw will fit together. They should be masters of the political game, they should be setting customer expectations, organising the customer's people to be available, keeping them up-to-date, making sure that the developers don't have any impediments stopping their development, keeping an eye on the team, settle any disputes etc. They don't need to cut code they just need to pull it all together. And if they are good nobody notices how hard/well they are working. (well I notice nowadays).

The Business Analyst (BA)

It is a common experience that developers have of a BA who don't deliver great information. However they do get a first version of this information and that can be a full time job in itself. It is hard to organise meetings with the customer. How many times at a first meeting do you ask someone what they want and they just have not thought about it. How many times does one department know what they do but are not really sure what other departments do and fit in. There's another meeting to organise and another then another. Finding out who does what is really really hard and takes a long time. As a developer I don't want to do that for days or weeks at a time, I want to be cutting code.


Where there is complexity and uncertainty in the business requirements let the BA's at it so that an overall picture can emerge and prioritisation of what delivers the most business value can happen. However if it is a fairly small, well defined business requirement I don't think you would need a BA and letting the developer engage directly with the customer would work very well.


The BA also serves another role which is essentially after sales / customer care. Once the software has been written and made live the BA should go back to the customer and see how well it is working. It could be the new software has thrown up some unforeseen problems. This is all very time consuming and having a highly skilled developer doing this makes little sense. It requires a personal and working relationship between the project team and the customer again this takes time to develop. Let the BA’s do this which frees up the developers to write software.

The Developer

We like creating stuff, we like solving technical problems playing with latest technologies, new software packages, coding techniques. Letting a developer loose with the customer to get requirements could quickly turn into an indulgence of what we want to do rather than solving business problems. We will be coming up with the technical solution to a problem before the problem has been properly thought through. It is fairly easy to persuading the customer they need a more complicated solution than is required.


By giving the developers a first version of the requirements and then let us think of the solution is a much more sensible approach. Yes the requirements will consist of nonsense and contradictions but the general direction has been set and we just need to work through the detail. The BA’s and customer will be on hand to help navigate this minefield.

Scrum

Here’s the kicker, using scrum properly ensures high communication and visibility between everyone involved in the project. There should not be “developers in meeting rooms  gassing about it with analysts and managers”. The analysts should be on hand to sit with you when you develop something, even better – get the customer involved. The dev’s will see what the BA’s are doing and visa-versa which should foster a sense of ‘Team’ and if someone isn’t delivering value it will become apparent pretty quickly. They should either be helped to perform or removed from the team.

 

Summary

So in summary, a scrum team needs these different roles and everyone brings value to the project and if they don’t it will be seen and there should be systems to deal with them. The manager protects the dev team and brings it all together, the BA’s build relationships with the business and get requirements and makes sure that the software has delivered value, the dev team get 3 week sprints to develop working software and are able to call on the BA’s / customers to clarify any nonsense and contradictions.


I read a book about 6 years ago called Coding Slave by Bob Reselman, it was a good read. One bit stuck in my mind and that was us coders are like Charlemagne’s scribes and I think this is very true:
http://www.informit.com/articles/article.aspx?p=170198

It has taken me a long time to appreciate this but now I appreciate the value others bring I am much happier in my own work.