C#, Software Developement, Projects, Games »

[28 Aug 2014 | 341 Comments]

I like playing CounterStrike Source (CS:S). I like playing against my friends at LAN parties (yes we actually still physically gather with our pc’s at some location and network them up and play against each other, we call it Lanfix).We then like to know how I did. We used to use to use Psychostats to generate a visual dashboard of what happened in game but it was no longer maintained and did not support the log format now coming out of CS:S.

@naiboss put out a request on the Lanfix mailing list to see if someone could tweak the Psyhcostats code to work with the log files I though I would have a look.

Instead of tweaking the Psychostats code I wrote a new application. After I had finished writing the app I then NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence' target=_blank>read a good book about NoSql databases by Martin Fowler. At the end of the book he quickly covers other types of databases, one of them being an Event Sourcing databases and it occurred to me that is exactly what the CS:S log files were. The log files were events that had happened in that order in the game. My app essentially replayed these events to build up the state of the application. A fuller description of Event Sourcing can be found here. I didn’t know it at the time but I had built an app using an Event Sourcing database.

This post is a brief look at the the solution I came up with after I decided it would be easier to write an app from scratch rather than try and update the Psycostats codebase. The working version of the final application is up and running if you want to see what it does before reading how it does it. I finish the post with a summary of what I leant and

Why I didn’t tweak psyhcostats

I looked at the Psychostats code. It is written in php which is not my strong point and something I do not want to be a strong point, It required a mySql database which always cost some money and caused us problems with hosting and upgrades plus there was a process of uploading the files log files which then had to be interpreted and put the the correct database tables so the php webpages could run queries to display the webpages.

The interpretation engine was full of regex. I always forget how to regex stuff very quickly and find it hard to read. I didn’t relish trying to work out what regex I had to tweak to get the new style logs to load into the database properly. I also did not want to do a lot of re-work in a language that I personally don’t rate.

New Design Constraints

As I was starting from scratch it was a good opportunity to really think about the design. I came up with the following requirements:

  • Must be able to run without a database. That was always a pain to manage in the old system
  • Must be testable with automated unit tests
  • Must be easy to understand and maintain the code when the log files change. This really meant not using regex.
  • Must allow old logs to be interpreted side by side with new logs as and when the log format changes

Step 1 – Look at the raw log file

The most obvious place to start was the raw log file that had to be interpreted. It was interesting to see what I had to work with, every line had a timestamp, the lines ran in time order with each ‘cs:s server event’ being appended to the log file. Maps loading, players buying weapons, players shooting other players, in game chat, there were lots of things going on. The goal was to make sense of these things and display them in a nice dashboard.

Step 2 – Interpret the raw log file

I decided the first thing I needed to do was start writing something that parsed the file and populated an object I could then use in my application. I allowed the data I found in the log files drive the design of my domain objects.

I started by writing code and unit tests which picked out specific lines from the log file. After I got this working I wrote a ‘Line Processor’ for each line that was responsible to understanding what the data meant after the line had been identified. The processor extracted the data from the line and populated the appropriate domain objects.

Step 3 – Create a UI

The aim of the exercise is to create a nice dashboard for people to view the stats after a session. For this I used Sencha’s ExtJS framework. It has a very rich set of controls and excellent documentation. I delegated the layout to @naiboss and @krofunk. The UI development is what drove the requirements for the data that had to be delivered from the domain objects.

It was an interesting exercise because there were a number of ‘Server Events’ that were missing and the data had to be derived from what we had. An example of this was the ‘Successful’ bombing count, how to attribute that to a player. I solved this problem by keeping track of the last person to plant a bomb, when a round finished because of a bombing I attributed that to the personal who last planted the bomb. This required a context to be created for the Line Processors to work in so they could be aware of previous output.

Step 4 – Create a scoring system

People always like a bit of competition so @naiboss devised a scoring system so people were given points for various things, like ‘a kill’ or ‘a bombing’. The scores are weighted by weapon and bonus points given for awards, such as ‘most headshots’

The scoring system is developed against an interface allowing it to be swapped out for other scoring systems if required.

Step 5 – Mash it up - Steam Integration

As the UI and scoring system were progressing we were thinking of how we could make it easy for people to manage their profiles. The answer we came up with was to leverage their Steam profiles. The log provides the SteamId of the players so it was possible to query Steam for more information. Queries are made to get the logos and player names.

Step 6 File management – Mash it up – Dropbox integration

We were now thinking of how to allow the log files to be uploaded. As there was no database and the whole system runs on the fly from the log files I decided to look at integrating with Dropbox. A user could register their dropbox credentials and then sync their dropbox with the server to upload their log files.

This then raised another interesting possibility, how to allow sessions to be looked at in isolation or together. By using the ubiquitous analogy of file and folder management I updated the file parser to process all the log files in a folder and its sub folders. So when we had a lanparty with CS:S in the morning and afternoon we could create an ‘LanParty’ folder with AM and PM folders in it. By clicking on the LanParty folder you get the stats for all the logs on the day but by clicking on either the AM or PM folder you can see what happened in those individual sessions.

This just worked and I dread to think how hard it would have been to implement with something like the Pcyhostats database.

Closing Thoughts

It was a really interesting little project and is not quiet finished yet. The dropbox integration does not work properly yet which is essential to allow other people to use the system.

I learnt a lot as I implemented design patterns that I read in the excellent book ‘Dependancy Injection in .NET’. I have a good suite of unit tests over the file parser so I will be able to easily and safely change the parser to handle updated file formants.

Books, Software Developement, coding »

[1 Feb 2014 | 198 Comments]

I am currently pulling together various materials I have found useful over the years to create some short reference materials for software developers I am managing. This is just a quick reference list of the books that I have found very useful in shaping my opinions on the practical implementation of software development.

Clean Code – A handbook of agile software craftsmanship

This book gives detailed guidance on how to write software that is easy to read and maintain in the future by following S.O.L.I.D coding principles. It challenges many long held beliefs about how software should be written with well-reasoned arguments.

Refactoring – Improving the design of existing code

This is ‘the’ book to refer to when you want to change the design of existing code whilst not changing its behaviour. By following these methods is it possible to keep the existing functionality whist reduce the size of the codebase making the code more maintainable and extensible in the future.

xUnit Test Patterns – Refactoring Test Code

This book provides tried and tested strategies and patterns for structuring automated unit tests. It explains in detail what has to be considered when writing tests to ensure that they do not become more of a burden for a software project than an asset.

Dependency Injection in .Net

This book provides in depth and very clear explanation of what Dependency Injection is and how it should be used to realise the benefits it provides. Whist the excellent examples are in .Net the content in this book applies equally to any object orientated programming language.

The Art of Unit Testing

This book provides practical examples of how to write Unit Tests in a maintainable way. This book combined with Dependency Injection in .Net provides excellent working examples of how to structure code in a testable way.

Working Effectively With Legacy Code – Michael Feathers

This book provides tried and tested strategies for maintaining legacy code that does not currently have automated test coverage. It describes the various problems that you will encounter when trying to maintain or change existing code and what has to be considered

Books, Employment, Software Developement »

[12 Oct 2012 | 307 Comments]

 

Why I’m writing this post

Over the last few years I have taken on a mentor / coaching type role from time to time for some up and coming software developers and I have found myself repeating my thoughts on what they should focus their energies on to progress their careers each time. People who know me know that I believe in DRY (Don’t Repeat Yourself) so I have decided to write this advice down for future reference, and perhaps some people I haven’t met yet will find it useful!

Do not rely on other people to look after you, you need to look after number 1

I think my most important bit of advice is for software developers to look after themselves. It can be very easy for enthusiastic developers to be worn down and loose any love for software development by the daily grind of work and especially when the effort (and often the extra-ordinary effort) they go to is not recognised or fully appreciated. We primarily owe a duty of care to ourselves and our career. The harsh reality is you cannot expect anyone else to do this for you. How do you do this?

Get a balanced approach to work and life, it’s ok to say ‘No’

The thing that I found that wears down enthusiastic developers more than anything is when they are too accommodating and put themselves under pressure by always saying yes (or ‘I’ll try’ which is always understood to be a ‘Yes’). I used to do this and one of the pivotal moments in my life was when I discovered the power of the word ‘No’.

As unbelievable as it might sound to some developers it is ok to say ‘No’ to development request on a project. You need to be reasonable and allow people to turn their request into a ‘Yes’. I like to have an easy to understand process in place for people to give me a requests. My personal choice is usually something based on a Scrum type approach. A simple backlog of items which people can add tasks to with a priority. I take a couple of weeks worth of  top priority tasks at a time and work on, delivery those new features then rinse and repeat.

Except for the obvious P1 issues, if people understand the process they seem happy to follow it, allowing you to say ‘No I can’t do that today but add it to the backlog and make the case it is more important than the other items and you can have it in ‘x weeks’. Its amazing how many ‘urgent’ issues dissolve into nothing after a few days.

For a good read about Balance and software development by Nathan Gloyn

Invest in your skills and set yearly goals

I like the saying ‘You cannot score without a goal’. The idea here is to spend time objectively and strategically thinking what would be good for your career and define some tasks to complete that will help you get there. Without doing this it is easy to end up in a Skills Drift, suddenly realising 5 years have passed and wondering ‘How did I end up here?’.

Setting yearly goals was the bane of my life when I had to do it in a formal structure at a consultancy but as a freelance with no corporation to hide behind all I’ve got are my skills to offer people to get work. I have to be and show I am at the top of the game in my field. I do this by taking some control of my own destiny and improve or gain relevant skills buy setting goals. DOING THIS IS REALLY IMPORTANT.

The practical application of this is to do this pick fun things to do, ‘I’ll learn a new programming language this year’, ‘I’ll complete a reading list of these <insert list here /> titles’, ‘I’ll attend x number of user group sessions’ (even better, give some presentations), ‘I’ll answer 10 stack overflow questions’, ‘I’ll write 6 blog posts’, ‘I’ll write a phone app with a Cloud backend’. These are the sorts of things I task myself with, they are cheap, interesting and packed full of learning value. These tasks should also help keep you interested in software development in general.

If you can get a budget to take a course and get a bit of paper with the word ‘Certified’ on it then go ahead but be aware that often they are sometimes not seen as a good indicator of your skills. See this post from Martin Fowler about the Certification Competence Correlation. 

Update your CV every year

This follows on from the previous point but make sure you update you CV every year. I found when I had nothing to add to it after a year it was obvious if my skills were stagnating and I was entering a Skills Drift. When this happens try to change this by talking to your manager for more training or something new to do. This might not work so. The saying i read in Jeff Atwood’s book Effective Programming: More Than Writing Code  ‘Try to change your company otherwise change your company’ applies here.

Write Clean Code

Any code you write will be read many, many, many times in its lifetime. So please try and make you code easy to read and understand. This does not mean just adding comments as this is generally a sign that the code is bad and not readable on its own (Martin Fowler calls comments ‘deodorant for bad (smelly) code’) .

Clean Code should be S.O.L.I.D so it is highly cohesive, loosely coupled, well named, easy to test (with tests please) making it easier and and safe to change sometime in the future.

My favourite resource and inspiration for explaining clean code is ‘Uncle Bob’. His style is quite zany but the message is very important and based in decades of experience in writing code. http://www.cleancoders.com/ 

Software development show be seen as a craft and there is a growing movement to make this a more mainstream idea and improve the quality of software development. http://manifesto.softwarecraftsmanship.org/ has lot of interesting information on the subject.

Admit when you don’t know

One thing that screams ‘inexperienced programmer’ is when they never say ‘I don’t know’ or even worse is when they do things and make statements which are based on obviously flawed assumptions of how things work and they see it as failure if they need to concede they were wrong. I recognise a good experienced developer or someone who is open to new or better ways of doing things as someone who is quick to identify the gaps in their knowledge and question what they think they know. When they are not sure (having evidence / experience to backup their argument) and are challenged will say ‘I’m not sure but I’ll find out’.

If I know you only have a few years experience I have a rough idea on how much stuff you probably know and expect to hear ‘How do you do that’ or ‘Is there a better way to do this’, ‘I don’t know how to do that’. While I expect this please don’t make me repeat the same advice or explanations over and over, it makes me feel you know value what I say. Make sure you learn from the things that people tell you.

Software development is like anything you learn, it takes many many years of practice and learning to become an expert in it. Research puts a time of about 10 years to become an expert in anything I’ve been doing this for over 10 years and am still learning and improving my skills every year, so perhaps I’m a slow learner! There are no short cuts, put in the hours, get experience be open to learning and you will get better.

Work smarter not harder

This follows on from the ‘Admit things when you don’t know’. If you find a task repetitive, long winded, error prone then it is probably worth the time to investigate if there is a more effective way to solve the problem. You might find that the answer is a revision to how you are currently solving the problem or perhaps there is a whole other technology or process that you might be able to use to make life easier.

Code generators, web frameworks, off the shelf products, open source projects, different languages, new software tools are examples of things that with some time invested in them can pay back multiples times over..

It is hard to do investigate and evaluate all these things on your own. To get an introduction to these things it is often better to hear from others who can summarize their field of expertise and if you find it interesting / relevant you can spend more time learning it it detail. See if you can go to some industry conferences, go to user groups, follow expert in you field on twitter, ask how other people are doing things on Stack Overflow, this is all part of you continuing self development. If you are lucky you might be working with someone who has done the research but see if you should still seek out new and improved ways of doing things. Once you get new knowledge see if you can share it with your peers in the industry.

Reading List

One of my favourite sources of quality information is books. Blogs and forums are useful for acute problems you need solved immediately but I find usually only treats the symptom of my lack of knowledge. Online media is great but there is a lot of shit on the Internet and sometimes it is hard to know when you stepped in it.

To treat the cause of you lack of knowledge you need to invest time in learning this missing bits of the jigsaw from a quality source that has been designed to tell the whole story. For me this is where books come in. The are significant bits of work contributed to by many experts in the field, with and army of people editing, reviewing and proof reading it to make sure it of a high standard. Books can describe the history and reasoning behind the designs and approaches of what you want to learn about. Below are some books which I would recommend to anyone wanting to do software development (there are more but this is what is on my Kindle at time of writing!).

Extra curricular activities

There is one thing that makes someone stand out as a developer who enjoys what they do an want to learn and that is what they do outside of the 9 to 5 job. So I encourage every developer to do something and it ties back to the early section of investing in your skills.

Create something

To really learn you need to do, so create something in your spare time to try out new ideas or technologies you’ve heard of. It’s the best way to get proper understanding of what things can do. Good types of projects are websites or mobile phone apps as they are easy to show people.

Sometimes I have found that my own projects are what keep me interested in programming when the work that pays the bills is dull and un-inspiring.

Get involved in an Open Source Project or two

If you want to get a springboard into learning a technology then get involved in an appropriate open source project. This is easier than ever with services like GitHub and CodePlex. The other great thing with doing this is that a lot of tool vendors, like JetBrains, will allow you to use their top of the range products for free on these projects.

This allows you to see how other people write code, structure their ideas and solve technical problems as well as getting feedback on how you write code, Don’t forget that there is no ‘correct’ approach and these projects with take an opinionated approached on how to tackle a problem. You might agree or disagree with the different approaches but make sure you keep your mind open to learn about the strengths and weaknesses of the different solutions.

Blog about things you have learnt

Get a blog going as somewhere to record things you learnt, did or think. You might not think that you have anything of interest to say on a blog, if that is true then nobody will read it but more than likely someone out there will appreciate your nuggets of information you throw out there. I’ve even found the answer to my own problem via Google on my own blog years after I  had originally solved the problem..

The thing I find about writing posts is that it forces you to really think about the subject, which really helps me understand the subject more. It also shows that you know stuff and is a good indication you are someone that likes to share and help others.

Attend community events

There are a lot of user groups / hack days going on all round the country. It is easy and cheap to attend these and you get to meet lots of like minded people. You never know who you might meet and learn from. The developers I’ve met at these events are of all abilities and backgrounds, from corporate IT workers, to start ups to people working on some of the biggest brand name websites in the UK.

In Summary

Being a developer can be one of the most rewarding and fun professions to be in. The industry is evolving so quickly it can sometimes feel a bit overwhelming but exciting at the same time.

There is a significant risk that you miss out on this excitement because the daily grid of un-inspiring projects using out dated technologies wears you down. You can easily become a battery hen 9 to 5 developer who looses the love they once had for the work. I have met a lot of these guys and it is a crying shame for our industry. As the country's economy evolves i can only see the demand for quality software developers will increase.

So my parting words are these:

Invest in yourself and give a little back to the industry and you will have a good chance of riding this growing technology wave to having a fulfilling career in software development.

Employment, Software Developement, Contracting »

[5 Oct 2012 | 31 Comments]

Why I think I can give some advice

Four years ago I created own start-up which did the very opposite of making me a millionaire, my plan B at that point was to become an I.T. contractor, which I did 3 years ago. I’m not the most experienced contractor but I have learnt a lot of lessons along the way. A couple of years ago a friend asked for some advice about becoming a contractor and another friend just asked me again this morning. So I’ve dug out the email I sent a couple of years ago and have put it here..

The Pros

  • The money is good
  • You can pick and choose contracts which includes locations (I compare this to when I worked at a consultancy who could send you anywhere round the country for months on end)
  • Every contract you meet new people, learn new things (business stuff as well as technical) and has the possibility to take you career in a different direction
  • You can stay out of corporate politics
  • As a temporary member of staff you generally don’t get given long term responsibility (although some people like having this responsibility so it might be a Con)

The Cons

  • The work is not guaranteed and the future is unknown
  • You generally only have 1 weeks notice (I was given that once when the client suddenly realised they had no money left, so it does happen)
  • You can be treated as a bit of an outsider sometimes.
  • No structured career path.
  • No perks and you never have that sense of ‘belonging’ which you can get as an employee in a company.

My Advice

In a nutshell, if you know a particular product / technology very well, you can convince people of this and my Pro list sounds good and the Con list doesn’t sounds too bad then you probably have a good chance of enjoying being a contractor, so here is the rest of my advice:

Setting your self up

  1. You have to believe enough in your abilities to quit a safe job for an unknown future.
  2. Set-up a Limited company
  3. Get an accountant to do the books / returns. This probably costs in the region of £800 - £1000 a year but it money well spent
  4. Get VAT registered on the Flat rate scheme. You charge you clients 20% and pay the HMRC 15% but you cannot claim VAT back on any of your purchases, so if you buy loads of stuff you might loose out here, ask you accountant you got in step 3!
  5. Get a good number of on going clients. There is a tax rule (IR35) that you cannot work solely for one company otherwise the tax situation is different. If you build a customer base of a dozen or so companies you regularly do business for this can help the situation. Speak to you accountant for professional advice on the situation (make them earn their £800 - £1000).
  6. Get an online accounts package. There are a good number out there, they can make it easy to raise and track invoices plus integrate with HMRC’s returns system, plus it’s online so it is available wherever you are. (£15 - £20 / pm ish) http://www.kashflow.com/ or http://www.freeagent.com are good examples.
  7. Build up a war chest. You need to save enough money to see you through any lean times. If you can save enough to keep you going for a year that is good. It also enables you to bargain harder for rates if you know you are not desperate for a new contract to pay the bills.
  8. Stay functional. When times get lean projects still need people who do the work and will cut out the management and make the doers manage the project as well, don’t get dragged solely into management and loose those functional skills.
  9. Be wary of recruitment agents. Take anything they say with a pinch of salt because they don’t work for you. ‘If you don’t pay for the product, YOU ARE THE PRODUCT’. At the end of the day the client companies hiring pay the the agent’s mortgage. This means the agent will do what it takes to keep the client company happy, not you. There are some excellent agents out there, just finding them and building a good relationship with them is the key.

Your are the product so sell and market yourself

Now that you realise you are a product you need to package and market yourself properly:

  1. Get a good CV. I used this book http://www.careerconsultants.co.uk/career/books-perfectcv.asp and spent 2 days re-writing my CV and hours doing re-work before I apply for new roles. CV writing is time very well spent.
  2. Be excellent developer but make sure you are a specialist in a popular product. This increases the chances of getting a contract plus increases the rate you can get. As a Microsoft developer I’ve chosen to be a Dynamics Crm specialist. Sharepoint and BizTalk are in demand at the moment as well.
  3. Blog / write articles, attend user groups, answer Stack Overflow questions, give back to the technical community you live in. This builds reputation and sets you apart from the other candidates who are going for the same contract. When you need a new contract these people you have helped by sharing your knowledge could help you back.
  4. Make a good name for yourself, be excellent at what you do and make sure the right people know this. If you are a contractor and you speak at events, make sure the audience know this as they might want to have you on their project for a few weeks / months. It is all about personal brand and inbound marketing.
  5. Networking and Inbound marketing is important. LinkedIn is excellent, make sure you keep your skills and availability updated. Updating your status to looking for work is sometimes all it takes to get a new contract.

 

In Summary, You need to get a hard nose

It might sound obvious but you are now on your own.

There is no sick leave, holiday pay or pension. If you are not working you are not earning. You have to pay the employees and employers tax / NI on what you do earn, you have to pay for accountants and your own training, your own hardware and software licenses the list goes on and on. This is why contractors rates look good to people who don’t understand the cost of being a contractor. Everything you do needs to be earning money. If you are asked to work a bit later on a project then make sure you get paid for it somehow. If your contract hasn’t been extended with a month to go, find a new contract as ‘if you are not working you are not earning’. Been asked to be ‘exclusive’ by an agent? Tell them to get stuffed unless they are willing to pay you if you are out of contract and they haven’t found anything for you. Been told that the contract is yours but haven’t signed anything? Keep looking until the ink is dry on the bottom of the paper.

I found my hard nose by loosing lots of money on my start-up and feel that is a big reason why I have done ok so far as a contractor. I ignored my own advice on one contract and put in a lot of effort over and above what I was contracted to do, the thanks I got was my 1 weeks notice just before Christmas when the project ran out of money. It was a sharp reminder to me why I should stick to my own rules!

Software Developement »

[7 Oct 2010 | 1 Comments]

We have recently upgraded our development environments on my project to match the production environment which is running on a 64bit servers. There was a big gotcha which was the delayed signed dll’s in the dev environment were chucking a “Strong name validation failed” error when they were accessed.

There are well documented solutions around using the following command

SN.exe -Vr *,*

However this did not work on the 64bit computer because SN.exe is a 32bit program and put the entry in the 32bit part of the registry. So I moved the registry key this tool enters and put it in the 64bit part of the registry and then everything worked.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,*]

Hope that helps some people out there ;)

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

Software Developement, Human Interaction »

[27 Aug 2009 | 0 Comments]

One thing that I have had to do over the last year is to hire people to help build by websites. Anyone that has been in the hiring position will know the pain that follows placing an advert… the deluge of CV’s which are generally very poor quality. I was discussing recently with some colleagues the filtering technique for applicants I use which has been very successful for me. It was pointed out to me that I was essentially implementing a CAPTCHA system – but in the physical rather than virtual world.

The idea is More...

Projects, Software Developement »

[28 Jul 2009 | 2 Comments]

It was 2 weeks ago now but I had the privilege of giving a 20 minute talk at the £5 App event in Brighton.

My slide deck of the talk will be at the bottom of this post for download if anyone is interested. The event was recorded by Ian Ozsvald and posted on his blog as well as the £5 App website.

I talked about quitting my job and hiring a small team to help develop the websites I had created into something with more quality and could be a commercial success. I wish I had had a little more time as I didn’t get do demo any of the functionality but it was great to be able to talk about them! The websites are http://www.skillbook.co.uk http://www.safetytrainingnetwork.co.uk and http://www.trainingcoursebooker.com .

On reflection there was one point which I wish I had made. I have spent most of my career working for large companies which we can call ‘The Man’ and at the talk I was congratulated for ditching ‘The Man’ and doing my own thing. However this implies that working for ‘The Man’ is a bad thing and this is where I wish I had made the following point.

In my opinion More...