In the beginning of January 2015, I moved from Brighton, England to Lund, Sweden to start a new job as a contractor for tretton37 but unfortunately I have faced some problems in moving here.

Moving to Sweden has been a complete life changing experience for me, there is no question there, however those changes are both of a mixture of good and bad. A very large part of my life back in England involved me spending a lot of time hanging out with friends building electronics in BuildBrighton along with sharing knowledge and teaching a lot of young minds the basics of electronics at events such as Brighton Digital Festival and Brighton Mini Maker Faire. I loved it, the moment one event would finish I would start to think about the next one, and what I should prepare. Everybody would comment on how I was so patient with people of all ages, and capable of taking complex subjects and making them simple for everybody to understand.

Another joy I had was being able to spend entire days in coffee shops on a regular basis, making friends with all the people that worked there whilst writing code on my laptop and enjoying more coffee than most people consumed within a week. On top of all of this, I never once needed to even consider looking at my bank statements each month wondering how much I had spent the previous month, because even though I lived a very comfortable life, I did not live to the extremes. I rarely ate out, hardly ever indulged in any toys, gadgets and treats.

Having moved to Sweden, I now have to give up on these pleasures for a number of reasons.

My friends back in Brighton were some of the best in the world at what they did. Chris Holden taught me almost everything I know about electronics, and would spend countless hours re-teaching me everything I forgot from lack of use. He also often would help me with a lot of my projects if he had the spare time to do so, and we always enjoyed a good chat about life in general. Steve Carpenter was not an electronics or coding like Chris, but he was a product designer that had an eye for detail and a head full of ideas, mixed with enough knowledge on how to get something done. Every time I wanted to do something simple but make it work quickly and look amazing, he was the guy that was able to help. He often shared some of his code with me when he was trying to fix a problem, and it was perhaps some of the biggest mess I had ever seen, but it would always achieve the job he required of it. Jason Hotchkiss was a hobbiest electronics designer with a lot of knowledge around midi from his hobbies, and many years of knowledge around programming in C and C++ for his day job. Often I would spend time talking to him about his amazing projects, how he made them and what he had planned next. When I did my first big project, Space-Buddies, he actually helped me a great deal with a lot of the code around storing and playing the musical tunes in a compact and efficient manner.

Where I live, there are no Maker Faires, nor Digital Festivals, but there are a number of small events for teaching kids to write code. Unfortunately for me, kids in Sweden learn Swedish first, and do not understand a good amount of the English language until much later on in life. So until I become fluent in Swedish (which may be enough 12-24 months), I will not be able to participate in any such events, even if they did exist here.

Everything is expensive and my salary after tax is a LOT lower than it was back in the UK. Sure my rent is lower, but even after paying rent, I lived a much more comfortable lifestyle back in England. I have had to watch every penny I spend since moving here, just so I can put a little away each month, either to save up for vacations or just generally have some savings. This means no more regular trips to the coffee shop for me, no more random purchases of electronics components from the internet, and being careful on every penny I spend in general, including my groceries. Back in the UK, I paid for my own mobile phone and gym membership along with regular payments for a personal trainer and a private tutor who taught me German, and I still had money at the end of every month. Here in Sweden, my company provide me a mobile phone (with a 1GB data limit), my gym membership (at a gym of my choice) but no personal trainer of course. I guess you can start to paint the picture of how great a difference salaries are over here, along with how much more the cost of living (not counting rent) is for people. The big thing over here is the “everybody is equal”, so somebody at a supermarket will not be earning much less than I am, whilst back in the UK I spent years fine tuning my skills to be able to earn a good salary. I was still earning below the average in the UK, so I did not expect the change over here to be so much of a big deal.

None the less, this all adds up as stress from time to time, and the stress gets to me. I am glad that I moved here for the many great things it has done for me, but it has made quite the impact on what I once called my life.

Last week I was struggling to find out how to make good use of metadata within NancyFx. I was reading through their extensive documentation along with searching Google for answers. The closest I could find was a single blog post written by Jim Liddell and unfortunately it did not cover the specifics of what I wanted to try and achieve.

I wanted to provide metadata for specific routes within specific modules, in a clean and structured manner. I did not want to add any extra layers of complexity, I just wanted something simple that just worked. I spent a few hours trying to get it working with how I believed it should be working, based off of the methods in the framework but unfortunately kept on hitting runtime errors. So in the end, I created a gist of what I was trying to do, and sent it to Andreas Håkansson via email, asking what I was doing wrong. A couple of days later, he came back to me with the answer and of course at that moment I instantly realized how it all worked. This was still not what I wanted as an end result, but by knowing how the framework worked, I could make it work the way I wanted.

I wanted to be able to create a MetadataModule file for each Module that I wanted to provide Metadata for, and have it work with paths that were relative (the base path) to what was already found my existing Nancy Modules. So this is what I did…

I created an interface named IDataModule, that would allow me to have a structured way of retrieving my information from each of my MetadataModule files.

public interface IDataModule<T>
{
    T Get(string path);
}

Along with a simple object structure that would serve as my Metadata itself.

public class MetadataModel
{
    public int Index { get; set; }
}

I then created an instance of a MetadataModule file, but I decided to try and keep a bit of structure to this, just to make my life a little easier. So currently all my Nancy Modules live in a folder named Modules so I decided my Metadata files should live in a folder named Metadata. I also decided that since my Modules have the naming convention of NameModule that my Metadata should have a matching convention, so a matching file would be NameMetadataModule. So for HomeModule I would then have a matching HomeMetadataModule file.

public class HomeMetadataModule : IDataModule<MetadataModel>
{
    private readonly Dictionary<string, MetadataModel> _paths = new Dictionary<string, MetadataModel>
    {
        {"/", new MetadataModel {Index = 1}}
    };

    public MetadataModel Get(string path)
    {
        return _paths.ContainsKey(path) ? _paths[path] : null;
    }
}

Now for this all to work, I needed an IRouteMetadataProvider instance, which supported all these rules I put into place. It is perhaps not the cleanest implementation, but it works perfectly for my needs.

public class RouteMetadataProvider : IRouteMetadataProvider
{
    public Type GetMetadataType(INancyModule module, RouteDescription routeDescription)
    {
        return typeof (MetadataModel);
    }

    public object GetMetadata(INancyModule module, RouteDescription routeDescription)
    {
        var moduleType = module.GetType();
        var moduleName = moduleType.FullName;
        var parts = moduleName.Split('.').ToArray();
        if (parts[0] != GetType().FullName.Split('.')[0]) return null;
        if (parts[parts.Length - 2] != "Modules") return null;
        parts[parts.Length - 2] = "Metadata";
        parts[parts.Length - 1] = ReplaceModuleWithMetadataModule(parts[parts.Length - 1]);
        var metadataModuleName = string.Join(".", parts);
        var type = Type.GetType(metadataModuleName);
        var dataModuleType = type == null ? null : TinyIoCContainer.Current.Resolve(type) as IDataModule<MetadataModel>;
        if (dataModuleType == null) return null;
        var requestPath = routeDescription.Path.Substring(module.ModulePath.Length) + "/";
        return dataModuleType.Get(requestPath);
    }

    private string ReplaceModuleWithMetadataModule(string moduleName)
    {
        var i = moduleName.LastIndexOf("Module", StringComparison.Ordinal);
        return moduleName.Substring(0, i) + "MetadataModule";
    }
}

Now in my instance usage case, I wanted this to store an index position so that I could create an object for generating a navbar. I used a very simple object for storing my navbar.

public class LinkModel
{
    public string Link { get; set; }
    public string Text { get; set; }
}

I then created a simple method for reading the data for me, including the Metadata, from the IRouteCache instance.

public IEnumerable<LinkModel> GetMainLinks(IRouteCache routeCache)
{
    return routeCache
        .SelectMany(routes =>
    {
        return routes.Value
            .Where(route => route.Item1 == 0 &&
                            route.Item2.Method == "GET" &&
                            route.Item2.Name != string.Empty)
            .Select(route => new
            {
                route.Item2.Metadata.Retrieve<MetadataModel>().Index,
                route.Item2.Path,
                route.Item2.Name
            });
    })
        .OrderBy(route => route.Index)
        .Select(route => new LinkModel
        {
            Link = route.Path,
            Text = route.Name
        });
}

I will most likely create some improvements on this in the near future, but for now, it works perfectly for what I need and perhaps this will serve as useful for others.

So the past week I have taken a break from social media, and includes all of the following, and perhaps a couple more :

  • Twitter,
  • Facebook
  • Skype
  • Slack
  • Google Hangouts
  • IRC

I needed a break from all the noise of the world around me, a chance to recharge my batteries and concentrate a bit more on myself and just getting my job done. Now as a software developer, working as a contractor/consultant, this provded to be a very difficult task indeed!

Part of my job involves me working with new technologies, or at least working with technology that other people may be uncertain on how to best use. I have three things which make me excel in this type of work.

I am good at reading documentation

Whenever I am faced with a new system, if I am not already familiar with the system, I am very good at finding the information I need from the documentation, along with exploring the code to find out the best way to use the system in question.

I have a lot of development experience

Many years of writing code in a number of different languages, for different companies, in different industries has trained me indirectly to know when something is good, something is bad, and often how things should really be done.

I have a large social network

If there is something I do not know, often, I know somebody who does and I can just drop them a message with a brief of what I need help understanding and they will help me out.

So what’s the problem?

Well this past week I have had a personal project which is nearing completion which makes use of NancyFX, but unfortunately the feature I was working on this week was making use of Metadata and unfortunately that is one feature that is not very well documented, simply because not many people make use of it (a future blog post will cover what I did). Now normally this is no problem, because my co-worker Andreas Håkansson is the creator of this system and I can just ping him a message on Skype, and he will help me out. Unfortunately though, if I were to do that, I would be breaking my social media restriction I imposed upon myself, so instead I spent a lot more time trying to workout exactly how to use this feature of his system. I failed. So to get around this, I created a simple gist on GitHub, and then sent him a small email with a link, explaining my plight and of course he replied a couple days later when he had time to sit down and write me an email. Now this worked fine for a personal project, as there is no concrete deadline that I need to meet, but what about my dayjob?

Unfortunately, in my day job I ran into the exact same issue with a different system which again had slightly confusing documentation around what I wanted to do. After spending a few hours trying to understand the system, I ended up having to make a small exception on my social media ban by commenting on a blog post, asking for clarification on a certain part of a system, followed by a tweet to the blog owner Karoline Klever. I received the answered I needed to complete my work, however in this instance failed at my avoidance of social media, simply because I had to just to do my job.

Summary

As a normal human being, avoiding social media is extremely easy to do, and I feel better for doing so. I am an introvert by nature and being around people for too long drives me insane, even though I am very good in social situations, I need time to charge my batteries.

As a contractor, unless I am in the rare situation where I am working on a technology that I have 100% knowledge of, it is almost impossible for me to completely avoid social media and do my job at the high speed that I do it. My social network is part of my toolset, just like my laptop and all the software I installed upon it.

This year has been one heck of a ride, almost completed another year completed and things are still extremely active and busy! So much has happened in these past few months, along with my attitude on life, and so far I have had nothing but great experiences as a result. The problem is finding time to share my experiences on a blog post for everybody else to read.

Going forward, I think instead of planning out nice big blog posts which never happen, I am going to make more frequent, smaller blog posts which should in turn provide more content to my website.

Anyway, until I begin with my useful posts covering things I have to share, here is a summary of what I have done since my last blog post.

  • Competed in Malmö Toughest 8km obstacle course
  • Competed in Helsingborg Springtime 10km race
  • Learned a load of Swedish and Danish words
  • Visited Poland
  • Backpacked around Japan
  • Was interviewed in the fashion capital of Tokyo, Japan for my style
  • Attended a coding hackathon in Spain
  • Was on the speaker’s committee for the large tech conference Leetspeak 2015 which was held in Stockholm
  • Learned NancyFX
  • Migrated a friend’s WinForms application to a self hosted NancyFX application
  • Learned Python
  • Learned EPiServer
  • Sent a load of pull requests to a number of OpenSource projects
  • Completed Hacktoberfest 2015 in under an hour
  • Bought tickets for BuildStuff 2015 in Lithuania
  • Bought plane tickets for my first trip of 2016, Amsterdam

At the beginning of January I emigrated from England to Sweden, and began my journey to discover the wonders of Sweden. The culture is completely different to what I have been used to previously, and often confusing, but ultimately is something that I am glad I got to experience.

There has been a lot of red tape involved in me moving here to Sweden, but I was lucky in that I was hired by the best company in the country. I am proud to say I am a Ninja for tretton37, a company who value knowledge and people over all else.

The biggest problem I have faced with moving to Sweden is becoming part of the society as far as the Swedish tax office is concerned. To do anything in Sweden, from opening a bank account to making purchases online, you need to have a Swedish personal number (much like a National Insurance number in the UK, and Social Security number in America). Filling in the form to obtain this number is extremely easy, however you have to submit it in person within the same city that you hold an address. Their opening hours are only week days and regular work hours, so you need to make sure that you either work in the same city that you live, or you need to book time off of work to spend 1-2 hours in a queue waiting to submit a form that takes no longer than 2 minutes to complete. It then takes a further 3+ months for your personal number to be issued to you, however you are unable to question the status of this process and have to simply wait.

Once you have a personal number, you are a person! You can actually be paid, because until you have this number, your employer is unable to tax you, so technically, you are unable to receive a salary, but many employers that are taking employees from another country will offer you an “advance” which is a set amount of your salary, but they do not know what your tax is until they have your personal number. Now you have this number, you can open a bank account to put this money into, however unfortunately you are not allowed to have online banking nor a debit card to withdraw your own money, and are forced to visit the bank with your passport every time you want to withdraw money. Why is this you may ask? The answer is that Swedish banks require that you have a Swedish ID card to obtain these, because a passport and a driver’s license are not valid ID in Sweden.

So now we need to apply for a Swedish ID card, surely that should be straight forward! Well think again, because you need to transfer some money to the tax office’s bank account giving your personal number as the reference, you cannot pay by card nor cash, you have to do it as a transfer from a Swedish account to another Swedish account, to ultimately obtain the account you cannot have in the first place! So how do you do this? You need to visit FexEx who will charge you 50 SEK for the transfer. You then need to wait at least 24 hours before visiting the tax office, after that you will be able to wait a further 2 hours at the tax office so they can measure your height, take your photo, your signature and that is it! They then tell you that it will take UP TO 2 weeks for your ID card to arrive… a little over 3 weeks later and I am still waiting for mine.

The summary of it all is this… Sweden may as well not be in the EU, simply because their tax office have made it clear that you are not a person until you have their crazy personal number which takes forever to obtain and without which you cannot be paid. Following which, all ID is not valid with the exception of their own issued ID. Once you are in the system though, you are all set. The people in general in Sweden are extremely polite, friendly, intelligent and generally good to be around. I guess this all just came as a shock to me, since I always thought Swedish people were known for efficiency yet their government is completely the opposite.