But it works on my PC!

The random thoughts of Richard Fennell on technology and software development

The community - a route to free training

I presented last night at the West Yorkshire BCS and received a number of comments that it was great to see free training being available. This for me is one of the most important areas of our community, and an area we are very lucky with. There are plenty of opportunities to access knowledge…..

Of late we have seen that the big vendor conferences (such as Microsoft’s TechEd, PDC and MIX) and the platform independent developer conferences (such as NDC) streaming their sessions live for free and also have their sessions available for free download within a few days. Microsoft’ Channel 9 is also an excellent resource of conference sessions and specially made material on a vast range of subjects from language design to scheduling of the buses on Microsoft campus. Or if you prefer to listen to something whist your drive why not try the .Net Rocks podcast. There are plenty more specialist resources out there on the web.

At the national level in the UK we also have vendor events such as Microsoft UK Techdays, and company run events like my company’s Black Marbles free events.

Outside company structures we have community events like DDD (general .NET interest) and SQLBits (SQL specific). These are free community run conferences where the members of the community submit session ideas, these are voted for by the community and a free Saturday conference is run using usually the  20 most popular sessions. Again, increasing some of these sessions are videoed and made available on the web.

At the even more local level there are always usergroup. In Leeds we have the BCS, Agile Yorkshire, Leeds SQL Usergroup, GeekUp and more I am sure I have not heard of. This pattern is reflected across the OK, it is just a matter of searching to see what is near you.

So there is no excuse for not trying to keep up to date, whether you want to learn via the web or in person. Why not have a look?

Lenovo W520 – one week on

I have had my Lenovo W520 a week now and must say I am very happy with it. I am still hitting the wrong keys a good deal of the time, the only problem being the Fn and Ctrl keys are reversed in position from my old Acer, it is a good job Fn-V and Fn-C does nothing dangerous!.

The keyboard is very nice to type on, a far more solid feel than any previous laptop I have had.

The performance is great, but you would expect it to be good with an Core i7 and 16Gb.

But the most impressive thing has been the battery life, a good five hours even running a TFS instance on Windows 7 and having VS2010 and Office open as I do most days. I had not expected that, the battery extender bits seems to do the job very well.

So all in all very happy, seems an excellent desktop replacement, I just need to find the time to get a lab management demo rig onto it to check it out in really bit load.

My first serious problem with my WP7 device

My WP7 LG-E900 decided to do a factory reset last night. It locked while playing the XBox Live GEODefense game on a particular busy level I had just lost (so lots of graphic processing). The phone paused for a while then restarted and ran the first use wizard, in German. This is because it is one of the PDC units that seem, given the packaging, to have been sourced from Vodafone German.

This is the first failure I have had on the phone, not a real pain as once the phone was back running in English it was quick to setup and sync, but 15 minutes I would rather have not spent.

[Update 17 Jun 20011] What I had fogotten to setup

  1. I had to set the APN for mobile data (just the name 'internet' with no UID or PWD for Vodafone UK, but I had forgotten that too and of course could not chekc them on the internet). When I first got this phone I am sure mobile data just worked. Anyway I only found it was not working when stuck in a huge traffic jam and I could not use the maps on my phone to get an alternative route. At home data had worked as I had setup WiFi
  2. Pair my bluetooth headset, again only found this out when tried to make a call from the huge traffic jam to say I would be late. Turns out it is hard to pair a headset in a traffic jam full of bluetooth devices.
  3. And I keep finding I am missing application and I can't remember what they are called......

The slow slide to a paperless life

I posted in the past about my though processes on getting a Kindle, they boiled down to to

  1. Why do the books cost virtually as much as paper edition when the author gets no more royalties and the production/distribution costs as far lower?
  2. I don’t want an extra device to carry about

Well I have been using the WP7 Kindle Client to read free classics and actually buying current novels. When I finished my first purchased novel, it was virtually automatic to go and buy another. No going to the bookshop or waiting for Amazon to deliver.

The reading experience, even on my LG phone was fine. I actually found I was reading more, as my phone is always with me (the novel would have been a bit bulky at 800+ pages).

So I think I am a convert to the format, but I did not really doubt that. It is now whether to get a Kindle itself to make the experience even better. Maybe as the read a home device, but keeping my phone for the quick read at the railway station.

Professional Foundation Server 2010

Over the holiday I have been reading Professional Foundation Server 2010 by Ed Blankenship, Martin Woodward, Grant Holiday and Brian Keller, yes I know how to have time off and have fun!

So who is this book for? It is a comprehensive guide to TFS 2010, the components and their usage, but this does not mean the book is only for teams new to TFS or people planning to take certification exams. Spread throughout there are useful little titbits of information where you find yourself going ‘I never know that’ or ‘arr.. that explains so much

image

So I would suggest it is well worth a look for anyone who is working, or planning to work, with TFS.

It is even available as Kindle edition, how times change, used to be only novels for the Kindle!

Kindle on the Phone 7

I asked the question a while ago if I should buy a Kindle? I still think that new books are too expensive, but as there are loads of out of copyright books available for the platform so I did not hesitate to download the Windows Phone 7 Kindle app today. You never know when you need something to read and what could be better to dip into than a bit of Sherlock Holmes?

image

Ok the experience on a phone is never going to be a good as on the Kindle hardware, but first impressions are good. It is nice and clear to read, much like the experience on the older Microsoft Reader on my old Windows Mobile 6.x, but with far easier navigation.

I am sure it will help we pass time when waiting at airports, train stations etc.

A week with a Windows Phone 7 – It just works!

I have had my LG WP7 phone about a week now. The best thing about it, it just works. Ok I have had a few learning issues over the Metro UI, but usually the answer is so obvious I have just overlooked it. Stupid things like I was looking for the button that was equivalent to the long press on the end key on my HTC Windows 6.5 phone to lock the phone; I had not consider the off button! A classic UTS (user too stupid) error, or maybe a user dragging old habits over to a very different way of working?

The thing that has impressed me the most so far is the voice control. In the past using a voice system usually involved recorded names and phrases and tagging them to applications or people so calls can be made. On WP7 it just works, press the button say CALL FRED BLOGGS MOBILE and it dos the rest. I have not had it fail one yet, very impressive.

The main thing I dislike most is the one I expect to dislike and that is the lack of tethering, I used my old phone as 3G modem when at client sites. It was great that I could just use my standard phone voice and data package for both phone internet access and PC internet access. I tended to not use this feature every week, but when I needed it I tended to use a lot of data, but it did not matter it was just covered by a single package at no extra charge. However, now I need an extra 3G dongle, so I have to work out whether it is more cost effective to get a PAYG dongle or an extra contract.

Another minor irritant, and this is not the operating system but the electronics, is that there is no led to show if the phone is charging or low on battery. It is all shown via the main screen. At one point I let the phone go completely flat and when I plugged it into a PC via USB to charge I saw nothing for about half an hour until there was enough power to show the screen. I though the phone was broken;, a nice little led would have fixed this for me,

So thus far it is a success, far better than my old HTC Diamond2 (but I am having to keep that in the glove box of my car to do SatNav for a while until there is WP7 solution)

PDC 2010 thoughts - the next morning

I sat in the office yesterday with a beer in my hand watching the PDC2010 keynote. I have to say I preferred this to the option of a flight, jet lag and a less than comfortable seat in a usually overly cooled conference hall. With the Silverlight streaming the experience was excellent, especially as we connected an Acer 1420P to our projector/audio via a single HDMI cable and it just worked.

So what do you lose by not flying out? Well the obvious is the ‘free’ Windows Phone 7 the attendees got; too many people IMHO get hooked up on the swag at conferences, you go for knowledge not toys. They also forget they (or their company) paid for item anyway in their conference fee. More seriously you miss out on the chats between the sessions, and as the conference is on campus the easier access to the Microsoft staff. Also the act of travelling to a conference isolates you from the day to day interruptions of the office, the online experience does not and you will have to stay up late to view sessions live due to timezones. The whole travelling experience still cannot be replaced by the online experience, not matter how good the streaming.

However, even though I don’t get the ‘conference corridor experience’ it does not mean I cannot check out sessions, it is great to see they are all available free and live, or immediately available recordings if I don’t want to stay up.

The keynote was pretty much as I had expected. There were new announcements but nothing that was ground breaking, but good vNext steps. I thought the best place to start for me was the session “Lessons learned from moving team foundation server to the cloud”, this was on TFS, and obvious area of interest for me, but more importantly no real world experience to move a complex application to Azure. This is something that is going to effect all of us if Microsoft’s bet on the cloud is correct. Seems, though there are many gottas, the process was not as bad as you would expect. For me the most interesting point was the port to Azure caused changes to the codebase that actually improved the original implementation either in manageability or performance. Also that many of the major stumbling blocks were business/charging models not technology. This is going to effect us all as we move to service platforms like Azure or even internally host equivalents like AppFabic

So one session watched, what to watch next?

First look at Postsharp AOP framework for .NET

At the Software Craftsmanship 2010 conference I met Gael Fraiteur of Sharpcrafters, he had given a talk on Aspect Oriented Programming AOP.Since the conference I have had a chance to look at his Postsharp AOP product for .NET.

I decided to do a quick spike project for a tender I have been working on, the requirement is to add a security model to an existing .NET assembly. Usually this would have entailed adding some security logic at the start of each public method to implement the security model. Using AOP I hoped I would be able to get the same effect by adding an attribute to the classes/methods, hopefully making the changes easier to read and quicker to develop.

So I have the following business logic I wish to added security too. All I did was add the [Security] attribute to the business logic method

public class BusinessLogic
{
    IDataProvider data;
 
    public BusinessLogic(IDataProvider data)
    {
        this.data = data;
    }
 
    [Security]
    public DataRecord GetItem(int customerId)
    {
        Debug.WriteLine("BusinessLogic.GetItem");
        return this.data.GetItemFromDB(customerId);
    }
}

So what is in the AOP attribute? Basically I use the AOP framework to intercept the method call, and before the method is invoked I make a call to a factory method to get an instance of the security provider and check if I have the rights to run the method.

[Serializable]
 public class SecurityAttribute :MethodInterceptionAspect
 {
     public override void OnInvoke(MethodInterceptionArgs args)
     {
         Debug.WriteLine("SecurityAttribute.OnInvoke");
 
         // this assumes we know the type of arguement and that we can 
         if (MembershipProviderFactory.GetProvider().CanCurrentUserViewThisItem((int)args.Arguments[0]) == true)
         {
             Debug.WriteLine("SecurityAttribute.OnInvoke: We have rights to view");
             base.OnInvoke(args);
         }
         else
         {
             Debug.WriteLine("SecurityAttribute.OnInvoke: We dont have rights to view");
         }
     }
 }

As it was a spike project I did not bother to write the security provider (or the DB provider for that matter). I used Typemock Isolator to fake it all, so my tests were as shown below. I found this way of working much quicker for my purposes.

/// <summary>
  /// test for both the success and failure paths of the attribute
  /// </summary>
  [TestClass]
  public class Tests
  {
      [Isolated]
      [TestMethod]
      public void When_the_membership_provider_gives_access_the_data_is_returned()
      {
          // arrange
 
          // create a fake objects
          var fakeIMembershipProvider = Isolate.Fake.Instance<IMembershipProvider>();
          var fakeISqlProvider = Isolate.Fake.Instance<ISqlProvider>();
 
          // create real objects
          var fakeData = new DataRecord();
          var bl = new BusinessLogic(fakeISqlProvider);
 
          // Set that when we call the factory method we get the fake membership system
          Isolate.WhenCalled(() => MembershipProviderFactory.GetProvider()).WillReturn(fakeIMembershipProvider);
                      // Set when we call the DB layer we get the fake object
          Isolate.WhenCalled(() => fakeISqlProvider.GetItemFromDB(0)).WillReturn(fakeData);
          // Set that we are allowed to see the item
          Isolate.WhenCalled(() => fakeIMembershipProvider.CanCurrentUserViewThisItem(0)).WillReturn(true);
 
          // act
          var actual = bl.GetItem(1);
 
          // assert
          Assert.AreEqual(fakeData, actual);
          Isolate.Verify.WasCalledWithExactArguments(() => fakeISqlProvider.GetItemFromDB(1));
      }
 
      [Isolated]
      [TestMethod]
      public void When_the_membership_provider_does_not_give_access_the_data_is_returned()
      {
          // arrange
 
          // create a fake objects
          var fakeIMembershipProvider = Isolate.Fake.Instance<IMembershipProvider>();
          var fakeISqlProvider = Isolate.Fake.Instance<ISqlProvider>();
 
          // create real objects
          var fakeData = new DataRecord();
          var bl = new BusinessLogic(fakeISqlProvider);
 
          // Set that when we call the factory method we get the fake membership system
          Isolate.WhenCalled(() => MembershipProviderFactory.GetProvider()).WillReturn(fakeIMembershipProvider);
          // Set when we call the DB layer we get the fake object
          Isolate.WhenCalled(() => fakeISqlProvider.GetItemFromDB(0)).WillReturn(fakeData);
          // Set that we are not allowed to see the item
          Isolate.WhenCalled(() => fakeIMembershipProvider.CanCurrentUserViewThisItem(0)).WillReturn(false);
 
          // act
          var actual = bl.GetItem(1);
 
          // assert
          Assert.AreEqual(null, actual);
          Isolate.Verify.WasNotCalled(() => fakeISqlProvider.GetItemFromDB(1));
      }
 
  }

This all work beautifully and I have to say this was nice and straight forward to code. The code looks clean and using Reflector the generated code is OK tool.

My only worries are

  1. That of performance, but after looking at the code I can’t see that the AOP framework generated code is any great deal less efficient that me adding security methods calls in all the business method. Using Postsharp would certainly require much less repetitive coding. In my spike the security factory strikes me as the bottleneck, but this is my problem, not the frameworks, and can be addressed with a better design pattern to make sure it is not created on every method call.
  2. I can see complexity appearing depending on handling the parameters being passed between the attribute and method being invoked. In my spike I need to know order of the parameters so I could pass the correct one to my security methods, however again I don’t see this as being a major stumbling block, the framework could provide something I am unaware of or I just need to write few forms of the security aspect constructor.

So will I be using Postsharp? I suppose immediately it depends if I win this tender, but I have to say I like what I saw from this first usage.

Should I buy a Kindle?

I have always read a lot of novels, and I like to have a book with me for those unexpected moments when I get a chance to read. Of late this has meant I use the Microsoft Reader on my phone. It is not too bad an experience, using Project Gutenberg I can get a book (fiddle a bit in Word) and export to the Reader format. However I would like a slicker experience and be able to read new releases, so the Kindle seems just the job.

As a device it seems perfect, about the size and weight of a paperback, excellent battery life (as power is only used to turn/display the page, not to view pages), excellent in natural light and now the price has dropped to the point that if you did lose it you are pissed off, but not bankrupt. Oh and dropping in the bath, though it might ruin the device will not electrocute you!

My problem is the price of new books, take William Gibson’s Zero History as an example. On Amazon this is £12.29 in hardback but £9.99 for the Kindle edition. So from this we assume the production costs, shipping warehousing etc for the physical copy total £2.30, seems a bit low to me! How is the £9.99 justified, there will be the writer’s royalty, the file production costs and the marketing and other publishing overheads but £9.99 seems steep, especially give the royalty rate that I know friends who are writers gets for their novels. Someone is making a tidy profit, and it is not the writer.

If we look at one of Gibson’s older books, Spook Country, now in Paperpack for £2.99 we see the Kindle price is £2.84. So it seems the Kindle price is set at (very roughly) 10% below the lowest physical edition cost.

So I am being asked to buy a eBook at almost the same cost as I can get a paper copy, when the publisher/supplier chain do not have to make the physical copy or ship it. I get the convenience that I can carry around 3500 books at a time, but I can only read one! Also I cannot lend a book to a friend, thus I admit reducing the potential royalties of a writer, but also removing any viral marketing opportunities.

So should I buy a Kindle? At this price for the eBooks I think not. I will stick to buying my new books on paper and keep a selection of out of copyright classics on my phone. I will wait until the publishing industry reviews it sales model for these editions, maybe increasing the writers royalties to reflect that it is their efforts that are being purchased not examples of the book binders art!.