Pages

Wednesday, 12 November 2008

Tuesday - Designing for Testability

ARC307 - Designing for Testability: Bridging the Gap between Design and Testing in Object-Oriented Software Speaker: Roy Osherove Probably the most inspiring session so far. It struck a chord because I recently gave some serious thought to coding unit-tests and using TDD. What has been holding me back so far is that most unit-testing frameworks seem to be targeting the .NET framework as opposed to native C++. For each piece of coded logic says Roy Osherove you should follow the PC-COF rules:
  • Partial runs possible
  • No need for Configuration
  • Consistent pass/fail
  • Order does not matter
  • Tests must be Fast
Dependencies between objects should be based on interfaces (to enable creation of mock objects), which then raises the problem of dependency injection: how and when do you pass a concrete object A to an object B that expects interface A? You can do injection in various ways:
  • Constructor (forces you to pass a concrete object)
  • Property (passing the concrete object is optional)
  • Factory (passing the concreate object is done as part of a factory method)
It can become very clunky to do code injections for all objects unless you use inversion of control containers. Those containers hold associations between abstract interfaces and concrete objects. Inversion of control frameworks:
  • Spring.net (I met one of the authors of Spring.net at TechEd Orlando)
  • Castle.Windsor
  • StructureMap
Unit-testing tools:
  • MSTest (the one integrated in Visual Studio Team System)
  • Nunit
  • TestDriven.NET
  • Typemock isolator
Slides

Tuesday, 11 November 2008

Tuesday - Schema Compare in VSTS2008

TLA313 - End-to-End Database Development Using Microsoft Visual Studio Team System 2008 Database Edition Brian Randell talked about how to manage change with SQL Server. That was a useful session! I've been struggling with this problem for years with Oracle and SQL Server: you have to manually write DDL scripts when doing database upgrades. Those scripts make visualising changes difficult and reversing changes impossible unless you write undo scripts. DBPro (VSTS 2008 Database edition) generates those DDL scripts automatically: you edit your schema offline within your solution (all under source control) then when you need to deploy the schema, DBPro compares the target DB model to the offline model and generates the scripts automatically. So no need to store the DDL scripts in source control any more (ALTER statements to add a column for instance). What you store in source control is the declarative model (i.e. the CREATE statements for the successive versions of the table). If a DBA makes a change in production, you can have DBPro compare the schemas and highlight the differences. You can then select an individual difference and bring it back into the offline model to keep it in sync. Sounds brilliant. By the way, this is available in VSTS2008 but works against SQL Server 2005. Brian did the whole demo against 2005 to make a point that there is nothing specific to SQL Server 2008. Resources:

Monday - Agile Development in VS2008 and VS2010

DVP03-IS - Agile development with Visual Studio Interactive session with Stephanie Saad who demonstrated some features of VS2008/2010. There are very interesting things for database development in the DB edition of Visual Studio Team System:
  • DB refactoring: changing a table name automatically updates all dependencies
  • DB deployment: you can generate a script that contains all differences between the current schema and the production schema.
  • DB testing: C# Unit-tests for T-SQL stored procedures where you define setup, test and teardown Test data generation (that's really handy for the setup part of the unit tests)
Apparently the dev and db versions of Visual Studio Team System have been merged into one license for 2008 so if you buy one, you get the other one for free. Other notes: VSTS 2008
  • see author/changes directly in code
  • define check-in policies (to force you to pass unit-tests for instance)
  • define triggers such as on check-in build
  • setup build notifications popups (through powertools)
  • code metrics: show the number of lines, cyclomatic complexity
  • all of the above present in VSTS for DB, Team System Server is not required
Coming up in VSTS 2010
  • Planning, task management: creation of user stories / tasks hierarchy, capacity planning, reports to show test results per user story / task.
  • Gated check-in: define check-in conditions, for instance you can't check-in if it doesn't build or if the unit-tests don't pass

Monday - Keynote

The CCIB got much busier after lunch, delegates with orange badges running everywhere, and the auditorium was packed for the keynote. The Keynote Session Although Christopher Lloyd didn't appear on stage in a De Lorean as happened in TechEd 2007 in Orlando, this keynote was a pretty good one. Nothing about adding-business-value-by-leveraging-customer-statisfaction bs: Jason Zander knew his audience so he did a demo-based presentation, going through some of the new features of Visual Studio 2010, changing, building and running code. To show that VS still provides support for unmanaged C++ he imported a VC6 implementation of Pong into VS2010 then
  • sexed-it up with the MFC C++ ribbon classes,
  • parallelised a lengthy for loop across 8 cores with parallel_for
  • and eventually showed off the multi-touch capabilities of Windows 7 by moving both pong racquets with his fingers simultaneously, under a round of applause.
video of the keynote

Monday, 10 November 2008

Monday - Silverlight 2.0

I am in Barcelona for TechEd. The keynote is planned for the afternoon, no sessions until after the keynote so my morning will be spent at the self-paced labs. I had planned to do some labs about multithreading in Visual Studio but it looks like they've gone from the schedule! Nevermind, I just did a lab on Silverlight Foundations lab (WUX11-HOL) Notes from the lab: • Silverlight projects produce xap files, wich are just zip files that contain dlls and a manifest. • When you create a Silverlight project in Visual Studio, it generates a new ASP.NET project by default to host the silverlight control. • Layout: VS contains some sort of read-only designer to preview the results of changes to the XAML file. Editing the layout WYSIWYG-style is done in Expression Blend. • Blend much more powerful than Winforms editor: add rectangles, ellipses, bezier curves, clever resize/skew commands... Apparently you can switch back and forth from Blend to Visual Studio using the same solution/project files. • Expression Design is used to build vector graphics that produce a XAML file. I'm considering Silverlight to build business apps so I also started the Communications and Data with Microsoft Silverlight 2.0 (WUX14-HOL)

Tuesday, 4 November 2008

Free Wifi in Istanbul

It seems that in Istanbul, many coffee/restaurant chains provide free Wifi access.
  • Palladium shopping center:
Cafe Nero
Midpoint restaurant
SushiCo restaurant
  • Capitol shopping center:
Kitchenette

Monday, 3 November 2008

Sugar Sync

Currently visiting a friend in Istanbul who showed me a useful on-line storage tool: for $50 a year you can store 26GB of data online.
  • your data is encrypted with AES, which is the least you should ask for, really.
  • the really nice thing: it comes with a client that automatically syncs your PC folders with the remote storage.
  • the sync works accross many PCs, which is cool as well.
That means you don't need to schedule back-ups of your important files, this is an automatic instant off-site backup (much more useful than my daily incremental Vista-based on-site backup).
An there's more:
  • you can access your files online over the web.
  • you can, and that's really convenient, send links to large files per email to other people. The recipient doesn't need to login to retrieve the file, he just clicks it. You get notified when he receives it.

Monday, 13 October 2008

Timezone conversion

How to convert a local time from a given time zone into UTC?
For instance how to convert the time in New York (Time zone: Eastern Standard Time) into UTC time, taking into account the fact that daylight saving is currently active in New York (until November 2)? Sounds trivial? Well it's not, at least not until .NET Framework 3.5.
The standard time zones are listed in the Windows registry: each time zone string is a key. The values under that key describe the timezone. For instance the "Eastern Standard Time" key contains info such as UTC offset and daylight saving start/end dates. Unless you use 3.5, you have to write code yourself to retrieve that info from the registry. It looks like the simplest way to do it is to use System.TimeZoneInfo in .NET 3.5. Example:
DateTime time = new DateTime(2008, 11, 7, 11, 46, 0, 0); TimeZoneInfo info = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"); DateTime utcTime = TimeZoneInfo.ConvertTimeFromUtc(time, info); Console.WriteLine("New york time: " + time.ToString()); Console.WriteLine("UTC time : " + utcTime.ToString());
Some resources:

Sunday, 28 September 2008

Wednesday, 3 September 2008