Monday, 28 January 2013

Use the Dictionary Indexer for upserts

If you have a Dictionary<T,T> and you want to upsert a value (i.e. update or insert depending on its existence), you don't have to perform the existence check yourself:

It turns out the dictionary's set indexer will do the check for you. All you need is

This applies to the .Net Dictionary<T,T>, SortedDictionary<T,T> and SortedList<T,T> implementations of IDictionary<T,T> .  But bear in mind that if you're coding to the abstraction IDictionary<T,T>, you can't guarantee that the specific implementation you're using will work this way.

Saturday, 5 January 2013

Pick A Ship-It-Day Project That Scares You

Our team has started running Ship It Days (a short write-up here) as a way of driving innovation for the company. The basic idea is that the whole development team gets 2 days to work on small projects, each of which will either deliver a feature for the company or increase the technical knowledge within the team.

As an example, over 2 days this week, we [a team of 2 developers and 2 testers] produced a heatmap of phone calls in progress on our network, across the world. We produced code to surface phone call data, map the source and destination phone number prefixes to geographic points, and overlay the routes on Google Maps' world map. The map is likely to be displayed in the Network Operations Centre as a dashboard item to see how busy the network is, and by customers to see what calls are in progress on their contact centre.

Although the 2 days were an absolute success in terms of delivering the feature (it won 2 company-wide votes, Best Minimum Viable Product and Most Innovative), for me the work involved was too close to my day job for me to get *really* excited. Don't get me wrong; I love the job I do and could think of few jobs I'd rather do than write code all day. But. This project was about surfacing, transforming and visualising data, using WebAPI, C# and JavaScript.

Next time, I'll choose a project that scares me.