Uncategorized

Do developers make things hard for themselves and fellow developers

Today has made me wonder if we are doing something wrong as developers. This weekend I gave myself two tasks. The first was to replace some immersion heaters. (Ours had stopped working and we have been without hot water for a couple of weeks. The shower and washing machine heat their own water so it hadn’t been a huge priority.) The second was to do some more work on a private project to try and get my head more around windsor, nhibernate, etc.

The immersion heater was relatively painless. I found, http://www.ultimatehandyman.co.uk/plumb_immersion_heater.htm on the internet which armed me with enough knowledge to go to screwfix direct and buy the bits. So the process was:

1. Buy bits.
2. Unwire old heaters
3. Remove heaters (this took a while as they didn’t want to budge)
4. Screw new heaters in.
5. Wire them back up.
6. Try and plug leak with sealant

The whole process was relatively painless and I never felt like I didn’t know what I was doing or felt like hitting my head against a wall. Now the second task my private project, wire up automapper and write data to a repository. I see automapper as a component, just like the immersion heater. If you don’t know Automapper is an awsome library that will try its best to map from one object to another without having to say object1.FieldX maps to object2.FieldX.

So the first step to get automapper to work is to register the mappers. Some googling later brings up this suggestion:

 public static class AutoMapperRegistrar 
    {
       public static void RegisterMappings()
       {
           var autoMapperClasses = Assembly.GetAssembly(typeof(AutoMapperRegistrar)).GetTypes().Where(t => String.Equals(t.Namespace, "restaurantBooker.Automapper.Maps", StringComparison.Ordinal));
           
           foreach (var autoMapperClass in autoMapperClasses)
           {
               autoMapperClass.InvokeMember(
                    "CreateMap",
                    BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public |
                        BindingFlags.Static,
                    null,
                    null,
                    null);
           }
       }

    }

So far so good. I add the relevant classes and I get my basic mapping working. I now have my objects mapping nicely. I try to save my object to the repository only to find I have forgotten to add a resolver to map from an Id to an entity in the database. I had done this at work so a quick google on resolveusing, refreshes my memory and I create a resolver.

public class RestaurantResolver : ValueResolver
    {
        private INHibernateRepository _restaurantRepository;

        public RestaurantResolver(INHibernateRepository restaurantRepository)
        {
            _restaurantRepository = restaurantRepository;
        }
      
        protected override Restaurant ResolveCore(int source)
        {
            return _restaurantRepository.Load(source);
        }
    }

and update my mapping file

 public class Table_KoViewModelsTable : BaseMapper, ITable_KoViewModelsTable
    {
        
        private readonly INHibernateRepository _restaurantRepository;

      
        public Table_KoViewModelsTable(INHibernateRepository restaurantRepository)
        {
            _restaurantRepository = restaurantRepository;
        }

        protected override void CreateMap()
        {
            Mapper.CreateMap();
            Mapper.CreateMap()
                .ForMember(dest => dest.Restaurant, opt => opt
                                                            .ResolveUsing()
                                                            .FromMember(src => src.RestaurantId)
                                                            .ConstructedBy(() => new RestaurantResolver(_restaurantRepository))
                                                            );
        }

       
    }

So I run the code and find that _restaurantRepository is null. So the _restaurantRepository should be injected in by Castle Windsor but because I am using reflection to call the createMap, it doesn’t inject. After around an hours worth of googling, I draw blanks so I log onto work and see how we do it there. I then spent around another 40 minutes trying to work out how the create map is working. Eventually I find that all the mappers derive from a base mapper which has a constructor which setups the mappers. During the component registration, castle windsor runs the constructors on each of the classes, thus creating the maps. I then went on to create a similar setup and at last I have it working.

So whats my point?

Well with the immersion heater, the immersion heaters diameters are standard. Wiring the heater up consists of 3 wires, each are standardized in their colours. You can get either 11″ or 22″ in length immersion heaters but its obvious which one will fit in the boiler. Now if we look at the fun with automapper and windsor, we find that we have significantly more ways that we can implement these libraries, not all of which solve all the problems, so we have to play about to try and get the right combination that works for us. I think design patterns goes some way to help us try and standardize our code but this doesn’t help with implementation. When we design our code it is designed to be consumed in different ways. Sometimes I do wonder if we should try and have more standard ways of using libraries. After all if I can fit an immersion heater after reading one web page, it does suggest that as developers we make things difficult for ourselves.

Sunday, February 19th, 2012 Uncategorized No Comments

Onlive, My Thoughts

I bought an onlive box,and 2 games for £2 plus delivery. For that price, I thought I had to give it a go. Onlive is moving computer gaming in to the cloud. The idea is that you will never have to upgrade your computer again as all the game processing is done on big computers on the internet and the graphics are sent to your device.

Onlive supports, its own console, PC, and promises to have Ipad and Android support soon. This interests me as it would be good to play my games where ever I have my Ipad and an internet connection. Also any saved games should follow me on my devices. Other people can watch you play and give you a thumbs up or thumbs down, which is a nice touch adding more social to game playing.

After seeing the quality at a gaming show and comparing it to my own, it seems my internet connection isn’t quite up to the job. I rarely get any problems with playing games, the graphics look blocky in comparison to what I saw at the show suggesting they downgrade the graphics for differnet internet connections.

What worries me about Onlive is their business model. They charge the same price for a game as you can buy in a shop although in some cases it can be more expensive. Which would be fine aside from when you purchase a game they say that you are buying this game but it will only be available to play for x period of time. This is understandable as they have to have these games loaded on a hdd somewhere and guaranteeing lifetime access to the game is a bit of a far fetch. However, when you think about this some more, you realise that if you went to the shop and bought that game or purchased it off of Steam, then you would own that game. You can play that for as long as you have a computer that can play it. I hear some people saying, but realistically I only play games for a few years and then they get dusty. Is that necessarily correct though? If that was true, would ebay have so many sales and purchases of old games? I mean you can even buy NES games.

My point is that when you buy a game via Onlive, you are effectively renting it compared to if you bought the game in the shop (remember the price is the same). So why would I do this. Another concern arises when you read the ts and cs where they state that at the moment, membership to their system is free but they reserve the right to charge a monthly fee and you can only play the game if you are a member. So worse still in the future I may only be able to play my game if I pay a monthly fee.

In conclusion I like the idea of online and think it is a very good innovation to the market. I do however beleive that they shouldn’t sell you games at full price but let you rent them, like you can from blockbuster. To me this seems how Onlive will evolve to and when it does, I would be more interested in spending more cash with them but at the moment, buying a game through them isn’t a better deal than buying from a shop.

Tags:

Saturday, November 5th, 2011 Uncategorized No Comments
 
August 2019
M T W T F S S
« Jan    
 1234
567891011
12131415161718
19202122232425
262728293031