But it works on my PC!

The random thoughts of Richard Fennell on technology and software development

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!.

All our futures behind us?

I had a strangely thought provoking weekend, I took my son to do the tour of Concorde at Manchester Airport, and whilst in the area popped into Jodrell Bank to look at the Radio Telescope and the arboretum. Two great technological achievement, well worth a visit, but I felt both seemed to be in our past. I remember Concorde, I remember Apollo (just) and I remember sitting in a room at school to watch the first Shuttle launch, but where is the equivalent today? I started to feel that this ‘thrusting to the future’ style of project no longer exists; there seem to be few children saying ‘I want to be an engineer’ or ‘an astronaut’. I fear they are too often now saying ‘I just want to be famous’.

image

But then I thought a bit more and I think these projects are still there; we have had the LHC switched on last year and just last week BBC News covered the break through of the Gotthard Rail Tunnel. Big science/technology is still a news story, but I have to say more usually not in the positive sense, too many stories are presented in the ‘science gone mad’ category. We (or should I have said the media) have lost the awe for big science and replaced it with fear or at least a mistrust.

Maybe I am just looking at the past with rose tinted spectacles, Jodrell Bank was over budget about 10x and people complained ‘why send men to the moon when people are starving on earth’, so maybe the coverage was the same. The current mainstream tone of reporting could just be a factor of living in a less deferential age. For me there is no question it is good to question the value of science, but this has to be done from an informed position, you have to least start to understand the question to give an reasonable opinion (or even ask a reasonable question in the first place).

What I worry is that this move, this lack of awe and excitement in science, will drive children away from wanted to be involved in science and technology. At least we are seeing a return to accessible science on the BBC (worth every penny of the license fee) in Bang Goes the Theory, the World of Invention and the new archive of The Great Egg Race (proper 1970’s mad scientists, I doubt you would get a 30 minute programme today with people fiddling with bits of string and rubber bands whist wearing wing collar nylon shirts, think of the health and safety static risk alone!).

So I guess my initial fear is unfounded, there is the sense of wonder out there, maybe we just have to make more of an effort go to find it.

New book on Refactoring with Visual Studio 2010 from Packt Publishing

Recently Packt Publishing sent me a copy of ‘Refactoring with Microsoft Visual Studio 2010’ by Peter Ritchie, I have to say I have rather impressed by it.

image

My only major issue with it is that of the title, this book covers much more than the refactoring features of 2010. It provides a very clear example driven discussion of the use and application of both refactoring patterns and design patterns. I think this would be an excellent book for a developer who want to start to apply design patterns to their C# code. The examples being more real world than Head First’s ‘Design Patterns’ (and the examples are in C# as opposed to Java) and the book being a far easier read than the classic ‘Design patterns : elements of reusable object-oriented software’

It is telling how much the book contents differs from the title that one of the most common sentences seems to be ‘that this is a not a build in automated refactoring in Visual Studio 2010’. Even though this appears fairly regularly the author goes onto explain how this limitation can be addressed in nice practical ways, interesting choosing to not mention third party refactoring tools until virtual the last page of the book.

Basically this book discuses theory in a nice accessible manner. It is not a simple ‘click here to do this’ tooling reference, don’t let the title fool you. It is well worth the read, you can see a sample 'Chapter No 6 "Improving Class Quality' online at Packt

Great iPlayer Media Center Plugin

I am very impressed with the iPlayer Media Center Plugin I found on the Australian Media Center Community, I like most people found it installed fine but that it failed to add itself to the start menu. However this was easily fixed using Media Center Studio once I got my head around the Media Center Studio’s user interface. The basic process is:

  1. Load Media Center Studio
  2. Go onto the Start Menu tab
  3. At the bottom of the screen look for the entry points section (needs expanding usually)
  4. In here you should find the iPlayer application (has a red’ish pay button logo)
  5. Drag it onto whichever part of the start menu you want, but be aware there are some limitation as to where it can go, Extensions worked fine for me
  6. Save the changes
  7. Restart Media Center

Once this is done you should be able to view WMV based iPlayer content from within Media Center. I have seen it take a while to start buffering content, but other than that it seems to work well and certainly looks the part.