Clicky

Sunday, 30 June 2013

BranchedMigrator : A Database Schema Management Tool

NB: Owing to YouTube's policy of trying to force Google+ on YouTube members, I no longer
        host content on YouTube. Apologies for the inconvenience.

I recently got round to doing a bit of work on an open source project of mine called BranchedMigrator. Inspired by Sean Chambers’ wonderful FluentMigrator, it’s a database schema versioning tool for use in continuous integration environments. 

You can download a copy here. 




Saturday, 2 March 2013

A Guide to The Cloud, Part 1 - For Muggles


In recent years, I’ve been involved in a number of cloud computing projects. Most recently, this included a very enjoyable project working for a forward-looking games company based in Glasgow. This blog post is intended to dispel some of the myths that linger about the various technologies that enable cloud computing projects to work. The content in this first part is primarily aimed at non-technical managers looking to get an understanding of what the cloud can do for them. In Part 2, aimed at a more technical audience, I’ll delve more deeply into the underlying technologies.


Let's Make Lots of Money


“The Cloud” is one of those buzzword phrases that’s been bandied around an awful lot. In the process, it’s had its meaning stretched and diluted a great deal. There’s been a lot of misinformation about what does and does not constitute a cloud computing project / platform. Common aspects of the various definitions I’ve encountered have included:

  • Applications that are web-based.

  • The hosting of those web applications, and the databases that underlie them, on remote hardware that isn’t located in the same building as the development team.

  • Lower hardware maintenance costs.

  • The ability to scale applications as an application’s user base grows.

A difficulty with some of the discussion that has fallen under the “cloud” umbrella, is that some or all of these qualities are also found in projects that are not true “cloud” applications, and never will be.

For the avoidance of doubt, when I speak of cloud computing projects, I am talking specifically about projects that encapsulate all of the following discrete qualities:

  • They are web applications that are accessible across the open internet, and are designed from the ground up to be deployed to dedicated cloud-computing platforms. This involves considering scalability, security and ease of deployment (discussed below) as primary design goals. It is not simply taking an existing Java EE 6 or ASP.Net application that was once hosted on internally-managed hardware and deploying it to a small number of servers in a single data centre.

  • Projects where the hardware to which the above solutions are deployed is not directly managed by the party that owns/writes the software. That is, an organisation that deploys a solution ‘to the cloud’ typically doesn’t know or care about where the physical server upon which their application runs resides, beyond broad geographical considerations. So, whilst it’s often possible to choose between “Asia”, “Europe”, “North America”, etc, when deciding roughly where your application will be hosted, if your hardware management is any more fine-grained than that then you are not using cloud technologies at all; you’re simply remotely-managing hardware that you are still heavily-invested in maintaining yourself. 

  • Solutions where you can scale your application to serve a greater number of users quickly and reliably. This typically involves a combination of leaving managing any physical hardware up to the third party you purchase cloud hosting services from, and an awareness within the development team of scalability issues as they apply to software design.


In Part 2 of this blog post I’ll get into some specific technical implementation details involving one particular set of cloud technologies: Windows Azure and ASP.Net MVC, in conjunction with SQL Azure. But first, let’s have a look at some general design considerations that apply whichever cloud platform you are using, and that should be clearly understood by technical and non-technical managers of cloud computing projects alike:


Security

I’ve worked on a range of types of application that have been used for a wide variety of purposes, from the very most trivial you can think of to mission-critical applications that needed to work every single time. An example of the diverse range of problems I’ve been involved in solving includes:

·        Automating precision engineering manufacturing processes for producing delicate parts that keep satellites in orbit
·        National power utility infrastructure management
·        DV-cleared national government work
·        A national police project
·        Investment banking applications aimed at Anti Money Laundering
·        A system for designing custom zombies for use in online games (seriously)

All of which is to say, I fully appreciate the need for security and I have a wide enough grounding in a diverse range of applications that required same to be able to make an informed judgement about whether cloud technologies are sufficiently well-protected to be able to use for each of the above discrete applications. I get it. Really I do. (Hey, there’s nothing more important than protecting society against the ever-present threat of a zombie apocalypse, right?)

I suspect that most if not all of the Public Sector and banking organisations with whom I’ve worked would be horrified at the idea of storing their sensitive data on hardware they didn’t physically control. (Even though many organisations in those sectors experience very serious problems anyway, even when working solely with hardware they get to fully manage in ways with which they are more comfortable.)  There’s something falsely-comforting to the uninitiated about having physical control of actual touchable hardware. It’s the same misguided illusion of security that makes some people store all their life savings under a mattress rather than putting it in a bank for safekeeping.



As well as the psychological difficulties some organisations/managers have in letting go control of physical hardware, in Europe specifically there are also some rather ill-conceived and as yet legally-untested rules concerning the processing of data outside the EU. So, if you operate there you might be forgiven for wondering whether you are allowed to store sensitive customer information on physical hardware that may be located outside Europe, even if you might wish to do so. Like the EU cookie law, it’s nonsense that’ll get over itself soon enough. But still, misguided and vague concerns like these allow people with a predilection to do so to spread worry and doubt about the security and legality of using cloud technologies they don’t fully understand, to solve problems they’d rather would just go away.

Without getting into the technical details too deeply at this juncture, in summary it is possible to easily encrypt data to a level where even the most sophisticated state/non-state actors can’t access it. If desired, it’s possible to encrypt all of the data you store on cloud servers, or just those parts that are particularly sensitive like passwords. Implementation details aside, most of the encryption schemes in use today use the same public key cryptography principle (though new approaches can and are being developed all the time). It’s the same process that allows you to safely access your bank account online, and make purchases from online retailers without risk of a third party being able to intercept and misuse your details. It’s safe: if it weren’t, there would be a lot more online fraud than there is.

Some organisations that operate in the cloud include: Amazon, Google, Microsoft and the National Security Agency. So, if anyone ever tries to tell you that you shouldn’t use a cloud solution purely on the grounds of security, I suggest you point them at the above links and invite them to come up with a more supportable rationalisation for their preferred approach.


Scalability

Aside from security, this is probably the second most important concern for cloud applications. Scalability is the ability of a given application to be able to adequately and reliably serve the needs of users under a diverse range of conditions. This involves several discrete design considerations, some or all of which may affect your project, depending on its nature:

The ability to support many concurrent users

First and foremost, your application must have the ability to support many thousands of concurrent users equally as well as supporting individual users in isolation. This design consideration is very easy to overlook when you’re working on a Proof Of Concept, where you’re mainly focused on providing features and the only people developers need to satisfy are the rest of their peers in the development team (hopefully augmented by some independent testers that will have the luxury of working on a version of the system that has not yet gone live and where they are consequently not using the system under stress). To be able to have confidence that systems work under the stress of heavy concurrent use, it’s important to test for that specific design goal using appropriate methods. There are various ways to do so that typically involve using a test harness to simulate such use; more on the technical implementation details of that in Part 2.

Considering the strengths of multi-tenancy vs single tenancy

Most software that’s used today tends to be written with a single end-user organisation in mind. If that’s the type of project you’re working on, you can dispense with this consideration altogether, since it doesn’t affect you. However, for some types of application, it’s the case that the same basic application gets delivered to multiple end user organisations, each of whom will have their own user base and subtle usage considerations. In these circumstances, an assessment must be made about the relative benefits and drawbacks of allowing different organisations to share instances of your application (known as multi-tenancy solutions) vs allowing each customer to have their own instance (known as single tenancy).

There’s no ‘right’ or ‘wrong’ answer that fits every situation. However, some things to consider include: Will different customers want to use different versions of your application at the same time? E.g., if customer ‘A’ buys version 1 of your application, and some time later customer ‘B’ comes along and purchases your latest improved version with additional features (version 2), are you going to move every customer that is presently on version 1 up to the latest version for free to satisfy the desire of your latest customer to buy the latest version? And if so, are your existing customers going to be happy to make the move?

The answers to these questions will dictate whether you should provide everyone with their own instance of your application, or attempt to cater to the needs of multiple organisations using one dedicated version.


Deployment

As new customers of your cloud-hosted solution come on board, you’ll need to consider how you are going to cater for providing them with the service they will be paying for. Whether you’re going to take a multi- or single- tenancy approach is a separate consideration. You also need to consider how you are going to get from the point of a customer requesting the ability to use your service, and that service being up and running. This typically involves, but is not necessarily limited to :

  • Setting up a database to contain the end-user organisation’s information.

  • Providing an instance of the web application that is specific to the end user organisation. E.g., you might provide the exact same stock management solution to a supermarket as you do to a company that makes metal parts. If you do, the supermarket is unlikely to want to direct their customers to www.shinymetalparts.com to check the price of milk at their local superstore.

  • You don’t want to get too deeply into managing physical hardware (not having that headache is one of the advantages that cloud computing is meant to bring you). However, you may still want to take an interest in the general geographical area that your solution will be deployed to. If you acquire a customer that has a large user base in Asia, for reasons of bandwidth management you’re unlikely to want to route all the traffic to that customer’s instance of your solution via the North American cloud hub that you used to develop and test your solution.

Most importantly, as an organisation that provides a cloud-hosted Software As A Service solution to others, you do not want to waste a great deal of time and effort getting developers involved in the above matters at the time of deployment. Planning and preparation for deployment needs to be done in advance if it’s to be executed efficiently.

Ideally, you’d like it to be the case that your salespeople can speak with potential new customers, and for those customers to be up and running with a minimum of fuss as soon as a contract for service has been signed. You shouldn’t need a DBA to set up the database, a developer to create a copy of the web application, and a tester to make sure it all still works as intended, just to supply something to customer ‘B’ that you’ve already supplied to Customer ‘A’.

Fortunately, there are solutions to the deployment process that involve minimal work at deployment time. I’ll get into the technical details more in Part 2, but for now I’ll just note that there are tools that, provided they’re used correctly, make the process as simple as running a single script to achieve All Of The Above goals.

In Part 2 I’ll discuss in detail how you can use a combination of Powershell, NAnt, and FluentMigrator to automate the deployment process. Key to the success of these is one final piece of the puzzle…


Continuous Integration and Version Control

The Joel Test has been kicking around for quite a while now, and whilst it is showing its age a little, many of the most savvy developers ask questions from it when deciding where to work. (Side note: yes, believe it or not, the best developers do still get to do that. Even in this economy. Think of the number of businesses that don’t use the internet or IT in some way; that’s the number of places good developers can’t find work, and those organisations are consequently who you’re competing against for the best talent). There aren’t too many organisations still operating today, thank goodness, that don’t provide basic tools like bug tracking and source control. Rather fewer have testing teams that are completely independent from the development team. Fewer still ensure quiet conditions for developers, and in my experience almost no organisation has been capable of doing daily builds or builds in one step at will.

The ability to deploy easily and at will is covered above. Related to that, however, is the consideration of how you will support multiple versions of your solution, some of which may be being used by different customers simultaneously. Part of the reason that most organisations aren’t able to deploy different versions at will is that, as noted earlier, most software today is simply written for one group of users and will only ever been used by and updated for that one specific group of users. If that’s the category your project falls into, then you don’t need to read any further. For those organisations that produce solutions for use by more than one customer at a time, sooner or later you’re going to have to delve into the topic of version control and continuous integration.

Continuous Integration is the process of managing features that are being developed by your R&D / development team, and determining which version(s) of your product will be benefactors of new features / bug fixes that are continually being developed. One day your R&D team might be working on Super Duper feature ‘X’ that is only going to be made available to new customers or ones that upgrade to your latest version. Another day those same developers might be addressing a critical bug that’s been discovered, the fix to which will be rolled out to users of all versions as soon as it’s been through development and testing.

There are tools available that automate and manage this process as a separate activity to development. I’ll discuss one of these tools – TeamCity – in detail in Part 2.


Friday, 4 January 2013

Turning Coffee Into Code : Delonghi Magnifica ESAM04.110.S Espresso Maker


OK, you got me. This blog is neither about software development in general, nor .Net in particular. But it is about a topic that's close to many developers' hearts: coffee.

______________________________________________________________________________


I'll prefix this by saying that I'm not a coffee snob, though I do have some pretty specific ideas about what I enjoy in a good cup. I don't like the stuff they sell at Starbucks, for example, and I find Costa's brew is way too bitter for me. The nicest store-bought coffee I've tasted actually comes from McDonalds fast food restaurants – their blend tastes really nice. If I didn't have to stand in a line six people deep, all trying in vain to order the food they actually want whilst some poor underpaid student embarrassedly tries to upsell them Things They Don't Want, I'd probably grab a coffee at McD's more often.

My usual brew at home until recently has been Gold Blend instant coffee. That said, I've been working in the centre of Glasgow with a great bunch of guys in a games company for the past couple of months (the first time I've been back there to work in a while). Being in a location that's surrounded by every conceivable type of coffee outlet imaginable, including all of those mentioned above within 100 yards of my office door, has got me to thinking about coffee seriously again. That's led me to invest in a good bean-to-cup machine, so that I can enjoy my coffee just how I want it whilst working at home once my present contract has finished.

After some research, I chose the following machine; the Delonghi Magnifica  ESAM04.110.S espresso maker :




I've tried other coffee machines that use pre-ground coffee in the past. To be honest, the results were not at all good. As mentioned above, I find some brands of instant coffee to be very nice. However, if you are going to grind the beans and attempt to make the real thing, then buying pre-ground beans is frankly a step backwards rather than forwards from instant coffee. Coffee beans lose their flavour very quickly indeed: within seven days of being ground. So, unless you're grinding your own as part of the processs, you're probably not getting anywhere like the intended flavour. Pre-ground coffees tend to have been sitting in a warehouse for anything up to six months by the time consumers get them, so they're already well past their best, however they've been packaged, and whichever temperature or atmosphere they've been stored in.

Other unfavourable aspects of those machines I'd tried in the past (which typically cost less than £50) included the fact that they just didn't get the water hot enough to make a great cup. So, even if the ground coffee going in had been right, the results would still have been mediocre. So, I thought I'd invest in a 'proper' bean-to-cup machine this time, to see if better results were achievable at home


The Good Stuff

1) Takes the grind out of grinding

The model above alleviates the issue of ground beans quickly losing their flavour by having an internal grinder that you can fine tune to your own taste. You can set it to grind the beans more finely if you want a smoother brew. (In practice, I've found that leaving it at the median factory setting has achieved just the right balance between a quick brew and a fine enough grind that you get all the flavour). Because the coffee is ground only in the right amount to make each cup and right before it's used, the resulting flavour is generally excellent.



With this particular model, you can also use pre-ground coffee if you really want to. However, since whole coffee beans are generally cheaper or the same price as pre-ground coffee, and tastes very much better, there's really no incentive to.

2) Hot stuff

As it only makes one or two cups at a time, the coffee produced is always piping hot. You can also adjust that setting to suit your own tastes: for me, the hottest setting felt about right.

You can also adjust the strength of the coffee itself. I quite like mine about 25% of the maximum possible strength: strong enough to get a nice caffeine buzz, but without being overpowering or resulting in too bitter a brew à la Starbucks or Costa!

3) Lots of choice, and beans are inexpensive

For beans, I've tried two varieties thus far: Italian Lavazza espresso beans, and a blend called Lazy Sunday by Taylors of Harrogate. 




They're both nice and give a mild, creamy coffee. However, Lazy Sunday just edges it for me. I've also bought some Illy beans to try in the coming weeks; we'll see how that goes. I'm looking forward to trying some other blends after that to compare and contrast: that's all part of the fun.

In essence, there are two types of bean: Arabica and Robusta. There are also lots of different types of roast, typically graded from 1 (Mild) through to 5 (Dark).

Arabica beans (which as the name suggests come from high-altitude regions within the Arabian Peninsula) are the oldest and probably more mild of the two, with chocolaty tones. If your tastes are anything like mine, they'll probably suit your palate best. Robusta beans are grown further afield, in places like South America, the Caribbean and Africa, at the same high altitudes. Robusta beans taste earthier and stronger than Arabica. Some blends use a mixture of the two types: Lazy Sunday is in that category. 

The roast gradings of 1 (Mild) to 5 (Dark) are a little easier to get a handle on. Counter-intuitively, the middle grade of 3 (Medium) is actually the most flavourful, and the one I like the best. If the bean is roasted less than 3 then the cup will be very mild indeed, and will contain a lot of caffeine. If it's roasted very darkly then it'll taste very smoky, but won't contain as much caffeine since it'll have been burnt up during the roasting process. A medium blend preserves that caffeine kick with a nice, mild flavour: a winning combination for me!

4) Easy to clean

The Magnifica machine itself has proven easy to clean and maintain. The coffee grounds are condensed into little discs during the brewing process: one for each brew made.






It's easy just to empty the container out whenever the appropriate warning light comes on (about every fifteen cups or so), then give the container a rinse out and dry it ready for the next brew.

The instructions advise cleaning out the internal filter around once a month, and not to use a dishwasher or any form of soap for cleaning (as soap can jam the very fine metal filter the machine uses). In practice I find it easiest just to give the filter a rinse under the tap and then dry it with a paper towel whenever the grounds container needs emptying, and you're set to go for the next few days' worth of coffee. 

The Bad Stuff 

1) Price 

The machine itself costs in the region of £350. There are various models in the Delonghi range that go down to about £275, and as a beginner to using espresso machines it's not that easy to see what the benefits of one model against another are. And it's not just as simple as choosing the newest, whizziest-bangiest option either: some of the older models in the same range are more expensive and give better results in terms of reliability/performance/features than newer ones.

I found this site to be quite useful for providing an independent guide, and for allowing you to directly compare and contrast the different models that are available.

In the end, I chose the model I did mostly because other Delonghi models in the same range had a lot of very good customer reviews on Amazon, and because it happened to be the model in the Delonghi range that was available from my local electrical retailer. With Christmas approaching, and consequent delays in the post, I wanted to enjoy my machine whilst I had a couple of weeks away from my current contract over Christmas and New Year, rather than having to wait for an item to be delivered from Amazon (which I'd have been quite happy to do at other times in the year).

I've been very happy with the model I got, though I'm sure the cheaper one available through Amazon would have been just as good.

2) Designed by committee

When I was researching which machine was right for me, I noticed a lot of variety in the options that were available. The cost ranged from between about £250 and £900. The main thing that seemed to differentiate the more expensive models were that they had digital controls, and the ability to store and retrieve different settings. That didn't seem particularly important to me, since once I'd found the settings I liked I intended to keep them that way. However, if you're buying a machine for an office where each person has their own individual taste, the ability to store and replicate multiple different preferences rather than fiddling with the controls manually each time might make more sense.

The unintuitive way that machines in the £250-£500 bracket work is my only real quibble about the Magnifica. It appears to have been designed by the same guy that was responsible for Windows Vista: the controls are horrible, and it's very easy to get confused about how to use the machine at first, particularly for accessing the type of features you'll only set infrequently, such as the water hardness setting.

These are the controls:




I won't go on ad infinitum about each individual feature, but describing just one in detail may help demonstrate the issue.

The coffee comes out of the two nozzles marked 'A' in the photograph above. These  nozzles are also where water comes out around twenty seconds after you switch on the machine, as it goes through a cleaning cycle. That same cleaning cycle is repeated (with attendant unexpected hot water flow) when the machine turns itself off after two hours on standby. There's a drip tray on the machine, but it still makes a bit of a mess when a full flow of water is deluged into it unexpectedly. So, I've taken to having a cup positioned under those nozzles at all times when I'm not making a brew, just in case it catches me unawares. The cleaning cycle can be sort of useful as you can use the water to pre-heat your cup(s), provided you remember to position them under the nozzles before turning the machine on!

So far, so good.

Then we come to the milk frother 'wand' (labelled 'B' in the photo above). This device is meant to provide steam to froth milk for making cappuccinos. And it does. Provided you master the magical ritual for making it work first (I suspect that's how it came to be known as a "wand").

The process for getting frothy milk involves first pressing the button marked 'C', then turning the knob marked 'D' anti-clockwise. But don't go putting your milk cup under the wand straight away or anything crazy like that, because what comes out of that 'wand' at first is - yes, you've guessed it - boiling hot water!

To get the process to work properly, you need to get that same cup that you use to catch unexpected water flows from the coffee nozzles, and place it under the wand. Then you turn the knob and let the boiling water turn to steam over the next ten seconds or so. Only then do you switch over to your pre-prepared cup of milk (which should only be about a third  full, since it expands in volume as you steam/froth it). If you forget to press the button marked 'C' before you turn the knob 'D' you'll be waiting a long time for that flow of boiling water to turn to steam. I personally found that a little pointless initially: if knob 'D' had been dedicated to the function of producing steam there would have been no need for button 'C' at all.

When you're done steaming the milk, naturally you're going to want to make some coffee to put that freshly-frothed milk into. However, Cappuccino By Vista has thwarted you once again. Because it's at this juncture you'll find that the machine is too hot to make coffee, and needs to be left alone for ten minutes or so to cool down (by which time your milk will be flat and cold).

There is a solution that doesn't require access to a Tardis to be able to go back in time and make sure you prepare the coffee first. That solution is to press button 'C' again until the light next to it goes out. This causes knob 'D' to stop being able to produce steam and puts it into "hot water" mode. Whilst in this mode, you place a cup under knob 'D' and turn it until steam stops flowing and boiling water resumes once again (takes about ten seconds again). This has the corollary effect of cooling the machine down enough to make coffee once more. See?, I knew there must be a 'logical' purpose to requiring two controls (a button and a knob) to control the frother wand when at first it seemed that only one should be needed.

I think you'll agree the above isn't entirely logical or user-friendly. It has the feel of a Beta Version about it. When researching which machine to buy, I read a lot of opinion to the effect that "coffee makers just do what it takes to make great coffee, whether they're easy or intuitive to use is a secondary consideration ". I don't agree with that outlook: great tools don't just need to produce great results, they also need to be user-friendly in order to make the power they facilitate available to us mere mortals. So, whilst the sometimes-obscure controls on the Magnifica may well double-up as a useful test of debugging skills for new developers should you decide to install one in the office (see, I'm getting back on topic now), it is still a pretty inexcusable limitation in a machine that costs £350.

_______________________________________________________________________________


Bottom line, I'm glad I got one. It's nice to be able to enjoy a decent cup of Joe or two in the morning before heading out to face the day. And, minor quibbles aside, it is actually pretty easy to use to get a normal cup of coffee once you've got it set up. All-in-all, I'm pleased with the results and would recommend it.





Thursday, 12 July 2012

Amazon Kindle: One of the Best Tools in a Technical Pro's Arsenal

As any professional knows, you can't get by in technology without constantly keeping your skills up to date with emergent technologies. Of the various ways to do this, one of the best is to choose some detailed technical books in those fields that are presently of interest. Preferably ones that have been written by people that are actual hands-on developers themselves, rather than those by authors that merely have an academic interest in the subject under discussion. Wrox Press does an excellent line of books called Programmer to Programmer, which are very useful in this regard.

Once you've absorbed the material, and have used the technologies concerned on a few live projects, these books become an excellent source of reference material, which you can refer back to time and time again. If you're anything like me, you'll have a bookshelf at home that looks something like this:


RP's old technical library

The only downside to Wrox books (and any other type of reference manual) is their weight. It's typically handy to have those books that are relevant to the discrete areas you're working in at a given time to hand as you tackle a real project. Given that even a few books combined generally weigh around 2-3kg, that can be a real strain on your back, especially if you're already carrying a laptop and other bits and pieces around too. 

Around about two years ago, I bought an Amazon Kindle, for the express purpose of carrying around these tomes without dislocating my spine. The passive e-ink display of the basic Kindle device is great for reading in bright sunlight:

Physical Kindle Device

And there's a handy little management tool on the Amazon website that allows you to keep your books safe and available at all times, wherever you may be:


Amazon's "Manage Your Kindle" tool
(View full size here)


The battery on a physical Kindle device lasts for a very long time (at least a month of continual use between charges), and the device itself has room for loads and loads of books. There's also a free PC-for-Kindle application that allows you to view the e-books you've purchased on any PC. And for Android users, there's a nifty free Kindle-for-Android app that allows you to view your books on your tablet:

Kindle for Android tablet, Library View
 or on your Android phone:

Kindle for Android phone
  
These latter applications are particularly useful if a book you happen to be using utilises colour to convey meaning:


Colour-Coded Keywords
Coloured Graphics
                    (View full size)                                                  (View full size)


However, the best thing about using Kindle as your technical library, which all technical departments should take heed of, is that you need only buy each book once. If you've got a department full of 20 developers (within which there will undoubtedly be a huge overlap of skillsets), it makes sense to buy one copy of each book, and allow each developer access to that library of virtual books via their own PC. An organisation that wants to make effective use of technology will also probably find it profitable to fork out for a few Tablets and physical Kindle devices for taking into meetings. In terms of increased profitability for individual developers, they'll pay for themselves in no time.