Archive for the ‘c#’ Category
Thanks to all of you who attended my session at AIC earlier today. The slides will be made available on line over the next week or so.
I think the interesting capability made possible by the DLR is using static languages and dynamic languages together. And there’s another benefit of learning a new language: when we only use one language we tend to think in that language – having other languages in our toolkit means that we have other approaches available to us.
So, where can you start to take advantage of dynamic languages? The areas I discussed today were:
- extending your application by adding scripting support to your application
- configuring your application with a dynamic language
- creating a DSL using a dynamic language
- writing one or more layers of your architecture in a dynamic language
- testing your application(s) with a dynamic language
Of all of these, extending and testing are probably the best places to start.
I also talked a bit about the DLR (and a couple of the Iron Languages – Iron Python and Iron Ruby) and the way that C# will be taking advantage of the DLR. It’s fascinating to see the evolution of programming languages and how the trends of dynamic, functional and concurrent programming are influencing this evolution.
Here are the links that I gave out in my session:
•Dynamic Languages on .NET (www.microsoftpdc.com)
I also mentioned the Anders Hejlsberg session on the future of C# – you can watch that here – and a Channel 9 video of Anders Hejlsberg and Gilad Bracha discussing language design, which you can find here.
As part of the preparation for the session, I exchanged some emails with a few folks including Michael Foord. For those of you who’d like to see Michael’s take on this subject, he’s posted about it here.
I’ve been busy with a couple of Proofs of Concept recently. The second of these that I worked on was iWantGreatCare. iWantGreatCare is a website that lets you submit reviews of doctors, both GPs and specialists. The existing site is built using Ruby on Rails and MySql. The Proof of Concept (PoC) was built in three weeks by a small team from Microsoft, iWantGreatCare and DotNetSolutions.
We had a few objectives for the PoC. We wanted to show:
- Integration with healthcare providers’ systems
- Intuitive, engaging user experience
- Extensible architecture
- Fit of Microsoft Technologies
We focused on a key scenario based around a mother with a son who requires medical attention who has just moved to a new area. This scenario covers finding a GP, reviewing the GP, finding a specialist and reviewing that specialist. We also looked at how healthcare providers could use and analyse the data that is created by these reviews.
We chose to build the site in ASP .NET MVC (version 1.0 of which has just been released.) Using ASP .NET MVC allowed us to build the site quickly and we were also able to extend it easily to provide different views (for instance, mobile phones and RSS feeds.) It is also readily learned by Ruby on Rails developers. The geospatial features of SQL Server 2008 made the location based searching far simpler than the existing implementation (we used Virtual Earth to show locations) – and Reporting Services provided drill-down reports that can be consumed by healthcare providers through the site. We also demonstrated integration with Sharepoint – a common technology in the NHS.
At the conclusion of the PoC, we had a working application that included all the features we had planned along with a couple of extras (the RSS feeds being an example.) ASP .NET MVC and the speed at which we were able to develop made this possible. iWantGreatCare are already well advanced with the migration to SQL Server 2008, and I look forward to seeing the ways in which the site develops.
Last week I presented the results of a Proof of Concept (PoC) at the Local Authority Urban Interest Conference, a sub group of ITS United Kingdom, which is the intelligent transport society for the UK. The PoC was completed the week before in the Microsoft Technology Centre (MTC). We had a team that included people from Microsoft, Birmingham City Council, Coventry University Enterprises, Shoothill and EMC Consulting. A PoC in the MTC is a three week exercise so you need clear objectives and a focussed team.
The Intelligent City programme is a Birmingham City wide initiative to “address key urban issues relating to transport, tourism, security and climate change through the exploitation of information technology”.
As with any PoC, there are some proof points. In this case the key points are to:
- Articulate and demonstrate a slice of the shared Intelligent Cities vision for Birmingham
- Demonstrate an interoperable service layer platform integrated with existing data / services
- Demonstrate compelling user experiences cross-device – manage a journey tracking and hopping across devices and modes of transport
- Demonstrate empowering individuals to make more informed, smarter choices
For the PoC, we focussed on transport and looked at a couple of specific scenarios. The first scenario is that of someone – we called him Colin – staying in a hotel in Birmingham who wants to visit his aunt during his time there. The second scenario focuses on Colin driving into the centre of Birmingham to go to the offices of a client.
We had data about the road network, the bus routes and schedule as well as access to a service that gave us real time positions of buses on some routes and data of traffic levels.
At the heart of the solution is a service layer that is able to create, store and share routes using that data and services we had available to us. We also built 3 client applications that used this service layer: a website, a mobile application and a mock sat-nav application. As you’d expect, the service layer is WCF, C# and a SQL Server 2008 database.
It’s probably worth saying a little about the routing before going any further. The routing algorithm had a model we built up of the road and bus network (including the schedule we had) so it could provide multi-modal routes across Birmingham – there is no park and ride scheme as such in Birmingham, so a car route is a car-only route for the purposes of the PoC. The way the model was created means that adding in other forms of transport would be relatively simple, provided you know where the modes of transport intersect (e.g. where a train station or car park is.) Adding in realtime information about journey times would also be simple.
The website is an ASP.NET App that shows traffic levels in Birmingham along with the realtime bus positions we have layered on Virtual Earth. It can also be used to get a route across Birmingham – once a route has been created, the user can log in and save the journey. The journey can also be shared – this allows other users with whom the journey has been shared to see your progress along the route.
The mobile application is a Silverlight app that addresses a problem we all face getting around. It’s all very well plotting a route on a website, but can you remember it? You can print it out, but the print out doesn’t know where you are. A mobile application can take advantage of GPS, which is increasingly prevalent in mobile devices. You can log in and retrieve the route you previously saved and the application will guide you along your route – including getting on and off buses. If you’ve chosen to share your route, it’ll upload this information so those people with whom you’ve shared your route can see where you are and when you’re expected to arrive.
The mock sat-nav application is a WPF application that is intended to show what a sat-nav could do to take advantage of the service layer. It shows how you could choose to be directed to a public car park near to your destination (you could use the mobile app to get from the car park to your destination.) During the journey, the car park fills up, so the sat-nav alerts you and directs you to the next available car park.
Having the service layer made each of these applications quick to develop – and allows the development of other applications. Demonstrating these applications brings that point home and shows how a big difference can be made to our experience of Birmingham in the very near future.
The video from the TechNet Event that was held on October 1st at which the National Rail Enquiries Proof of Concept was shown is now online. You can watch it here – click the National Rail Enquiries link beneath the video player. On my screen the video is a little small to get the full UI experience, but the commentary from Jason Webb and Stuart Harris is well worth it. While you’re there, check out some of the other videos. And if you’d like a second opinion, Mark Roddis shares his thoughts here and here (right at the end of this post) about the presentation.
While it is still (relatively) fresh, I thought I’d share my experiences writing some multithreaded code for the .NET Compact Framework. You can read the article here.
Over the last few weeks, I’ve been part of a team from Microsoft, Conchango and National Rail Enquiries building a proof of concept. On Wednesday 1 October, at the TechNet event in London at which Steve Ballmer spoke, we showed a live demo of some of what we had built in the three week proof of concept. The concept we proved is the use of National Rail Enquiries services in multiple channels. National Rail Enquiries already have a very popular Vista gadget available that allows you to see live train departure information on your desktop. Prior to starting the proof of concept, we held a two day architectural workshop to establish what services and applications rail users need to make their experience of using trains even better. The priority sample applications were an Outlook Add-In, a Windows Mobile application, a new way of presenting live train information on the web and an internal dashboard application. Those of you who attended the TechNet event on Wednesday will have seen the first three of these applications in action.
The Outlook Add-In enables users to book travel time. Most of us have appointments in our Outlook calendar. Some of these appointments require travel. The add-in lets you select the appointment and plan your train journey to and from the appointment. When you select the trains you want to take, it books time in your diary automatically – in the detail of this travel time there is information about the selected journey and an earlier and later journey should everything not run to plan. It’s simply formatted so that it reads well on your mobile device. It also links directly to the live train information on the web.
Speaking of the web, we set out to build something that would enable you to get the information you want quickly and as intuitively as possible. So, we settled on using Silverlight using DeepZoom to navigate around Virtual Earth imagery, on top of which we overlay track and train information. You can zoom in to your chosen station and get station information, see the trains in the area (blue for on time, red for late) and get information on them, too. And, even better than that, the train positions are updated so they move. Here’s a peek at what it looks like:
The map can be embedded in the National Rail Enquiries site and there’s a button that allows you to expand it to a full screen view (which is the view I’ve used above.) Given the popularity of the National Rail Enquiries site, scalability was a primary consideration. When you think that there are in the region of half a million visits per day to the site and thousands of trains, you can see it would be easy to design an application that would not scale. We used a state service which holds a model of the train network on the server – thus minimising the network traffic that would result from this model being held on the client given that every client would have to get updates from the server. This way a client only gets the information it needs. The other thing to note about the service is that it has SQL Server 2008 at its heart – we made usage of the geospatial capabilities to store information about tracks and stations.
The last application we demoed was a mobile phone application that enables you to check what time the next train leaves, if it’s on time, when it’s due to arrive and what platform it’s leaving from. Given that this is a mobile application, it’s written using the .NET Compact Framework 3.5. It takes advantage of local storage (for instance the list of stations is held on the device) and features of the compact framework such as multithreading while using a web service to get live information.
All in all, I think this is a great demonstration of how your architecture can cover multiple delivery channels taking advantage of different devices. I’ve already been using the mobile application (someone needs to test it) – and my journeys have involved less waiting in stations as a result.
Having posted a number of times about Ruby over the last few months, I thought I should also write a bit about Python. The first thing I decided to try and do was to run some IronPython from C#. I downloaded version 2.0 beta 5, which includes the latest version of the DLR. I created a Console Application and added references to Microsoft.Scripting.dll and Microsoft.Scripting.Core.dll – the assemblies that constitute the DLR. I also added a reference to IronPython.dll and IronPython.Modules.dll. I decided to try to output some text, set a variable in IronPython and retrieve the value in C#. Here’s the code:
ScriptRuntimeSetup setup = new ScriptRuntimeSetup(); setup.LanguageSetups.Add(IronPython.Hosting.Python.CreateLanguageSetup(null)); ScriptRuntime runtime = new ScriptRuntime(setup); runtime.IO.RedirectToConsole(); ScriptEngine engine = runtime.GetEngine("IronPython"); ScriptScope scope = engine.CreateScope(); ScriptSource source = engine.CreateScriptSourceFromString("print 'Hello World'\r\na=1", SourceCodeKind.Statements); source.Execute(scope); Console.WriteLine(scope.GetVariable("a"));
I’m impressed that C# and IronPython can interact like this. The possibilities for extending applications with runtime dynamic code are intriguing – worth looking into.
There’s a few things I’ve noticed over the last week in the Rubyverse that I thought it was worth highligting. In no particular order, here we go.
In my Ruby doodlings, I’ve spent quite a bit of time with REXML. GIven that I’m focussed on learning Ruby rather than deploying code, there’s no issue. However, this post from RubyInside shows there are alternatives such as libxml-ruby.
Testing, both TDD and BDD style, are prominent in the Ruby community. This post examines the reasons to unit test, questions the emphasis placed on unit testing and highlights the importance of remembering why you test. Well worth reading and relevant regardless of your preferred language.
Finally, I came across a couple of resources that those who, like me, are learning Ruby may find valuable. The first is the news that there is a new chapter in the Book of Ruby. The second is a couple of posts about learning Ruby for C#ers. These posts also mention IronRuby, so well worth reading.