Fluent.Interface


Cloud computing report; Sun’s new API and DabbleDB

A recent McKinsey & Company report Clearing the air on cloud computing  reports that for companies to migrate their enterprise software platforms to the cloud:

The cost of cloud must come down significantly for outsourcing a complete data center to make economic sense

Although it is becoming cost effective for smaller ‘compute equivalent’ environment – where the total costs of assets for a typical data centre is US$45/month per CPU.

The report also suggests that:

CIOs should be working the cloud technology stack bottom up; cloud providers top down

Or in other words utilise virtualization and CDN’s available now, while waiting for the cloud service  providers to improved reliability and standardize offerings.  The recent Open Cloud initiative spearheaded by Sam Johnston from Australian Online Solutions might go someway to achieving this goal:

A common set of protocols and API’s for accessing cloud resources could be as revolutionary as HTTP was for TCP/IP.   And possibly the simplest and best implementation I have seen to date is Sun’s new cloud initiative, illustrated in this Hello Cloud example leveraging JSON over the RESTful API.  Hopefully the recent acquisition of Sun by Oracle won’t dent the enthusiasm of this project.

One of the great things about the cloud is the flexability developers/vendors have when choosing the software stack  for their implementation. DabbleDB was a recent example i came across that offers a rich database through a clever online spreadsheet-style interface.  It is built on the Squeak smalltalk engine utilising the SeaSide framework.  Avi Bryant talks to InfoQ on how his application works without the use of a RDBM instead storing virtual images of the smalltalk run-time.


Eiffel-style Code Contracts for .NET

Design-by-Contract was coined by Bertrand Meyer, the creator of Eiffel as a way for software designers to formally define pre and post conditions as well as object invariants such that the caller can know what to expect when executing code.  

This practice is applied in unit testing when Asserting the result of a function, however until now there have only been work arounds for achieving the same logic in-line; which can now be elegantly expressed like using Code Contracts like so:

public void Deposit(int amount)
{
    Contract.Requires(amount > 0);
    Contract.Ensures(Balance == Contract.OldValue(Balance) + amount);

    Balance += amount;
}

Microsoft through its DevLab site has released Code Contracts for .NET, a subset of its ongoing Spec# research project.  This consists offering consist of:

  • a stand-alone library that will in future ship as part of the BCL in .NET 4, 
  • a binary rewriter to support post-condition checking, 
  • and extensions to the Visual Studio 2008 IDE to support static checking after every compile.   

As part of the distribution it includes a number of helpful code snippets such as:

cr Contract.Requires(…);
ce Contract.Ensures(…);
ci Contract.Invariant(…);

Where the Contract.Invariant call is declared within a protected ObjectInvariant method (snippet cim) and defines the state of a property throughout it’s life cycle: 

[InvariantMethod]
protected void ObjectInvariant ()
{
    Contract.Invariant ( f ! = null );
}

I recommend watching the short channel-9 video for an introduction, or consult the manual for further details.  One feature which is not currently available will be integration with code documentation, which will be very helpful for API developers.


TDD on show with ASP.NET MVC at Mix09

Its been a long road, but ASP.NET MVC 1.0 is out and now is open source as posted on ScottGu’s blog.  Its a great milestone and one that has been paraded in front of the the Mix09 attendees in Vegas.  I can recommend setting aside the two hours required to get through Phil Haack‘s Nija preso, and Scott Hanselman‘s NerdDinner talk.

Those guys along with Rob Conery and the main man Scott Guthrie have been slaving away on a new book ASP.NET MVC 1.0 from wrox press.  

the extended forehead edition

And have been kind enough to give away from free a chapter that walks through all the steps required to create the NerdDinner sample, which includes details on:

  • Validation
  • Security tips
  • Rendering partial controls
  • Custom routing
  • Authentication/Authorization
  • AJAX (with jQuery).
  • LINQ to SQL mapping with scalar/table MSSQL functions (very cool!) 
  • Dependancy injection with MOQ

It also has 20 pages dedicated to Unit testing, and encourages using the ‘AAA’ approach: Arrange, Act, and Assert which looks like this:

[TestMethod]
public void Dinner_Should_Not_Be_Valid_When_Some_Properties_Incorrect() {
//Arrange
Dinner dinner = new Dinner() {
Title = "Test title",
Country = "USA",
ContactPhone = "BOGUS"
};
// Act
bool isValid = dinner.IsValid;
//Assert
Assert.IsFalse(isValid);
}

PhilHa and ScottHa also spend a good amount of time covering red/green/refactor in their videos, and why it is important to have the test fail first.  Great Stuff!