Sunday, December 27, 2009

Broken Angels book review

In his first book, "Altered Carbon", Richard Morgan sets up a universe in which human consciousness has been digitized, and can be transported over inter-planetary distances, re-sleeved (placed into another human body), and backed up. Broken Angels follows the main character Takeshi Kovacs, into another "Subjective" life on another colonized planet.

The exploration of the digitized consciousness concept is great. I particularly love the graphic description of the "Soul Market". He also does reasonable job of describing the not so subtle links between greedy corporations and wars, but I feel he could have gone further. This time Aliens make an appearance (although long extinct), and there are some interesting explorations of the academic attempts to explore alien culture, and the parallels with our attempts to understand ancient earth cultures is fairly obvious.

The development of some of the characters was good enough to understand their motives, but still allowed for some surprises in the end. Other characters I feel weren't really developed as well as they should have been.

I feel that the books main problems revolve around the central character Kovacs. At times it can feel very much a "One man takes on the world", "Alpha Male" stereotype. I think this was also the first books main problem as well. It also uses the created universe of digitized consciousness and technological advances to allow for more graphic violence, but I think that is an acceptable exploration of the ideas the universe is based on.

As with the first book, the general outlook is bleak, basically accepting that technology will never be a panacea for human ills, but it does leave the reader with the slightest glimmer of hope at least for some of the characters you have met along the way.

I will definitely be reading the third in the series.

Technorati Tags: ,

Thursday, December 17, 2009

Linq2SQL Bug with derived classes and Calculated fields

Today I discovered a bug in Linq2SQL. When you define a class hierarchy in dbml, where you derive a class from a base Class, and both use the same underlying table, and a discriminator property, as shown below:

derived_dbml

If you then wish to expose a calculated field in the derived class, (and trust me I have come across situations where this is a requirement), you will find that Linq2SQL throws an exception when you attempt to insert or update items of the derived class to the database.

The exception is as follows

Test method DerivedClassTest.DerivedClassTest.TestInsert threw exception:  System.ArgumentException: Property 'System.String CalculatedField' is not defined for type 'DerivedClassTest.BaseCLass'.

This bug occurs deep within the Linq2SQL logic, and is to do with the AutoSync functionality where Linq2SQL attempts to create a select statement to return the values of AutoSync fields at the same time as it performs the insert.

You may be able to work around this by setting the AutoSync property on the Column Attribute to “Never” as shown below

[Column(Storage="_CalculatedField", AutoSync=AutoSync.Never, DbType="NVarChar(61)", IsDbGenerated=true, UpdateCheck=UpdateCheck.Never)]
        public string CalculatedField

And note that setting this in the designer doesn’t seem to work either, it just removes the AutoSync parameter all together, but still fails. You manually have to set it in the generated code (another bug perhaps?).

Of course this means that you won’t get the new value of the field after an insert or update to the table, and you’ll have to re-query the table if you need it.

The alternative workaround is to ensure that all calculated fields are placed on the base class.

Saturday, December 12, 2009

I have joined the e-Book Revolution

I have finally bitten the bullet and purchased a kindle. I had been tossing up between the kindle and the nook, and even though in many respects the nook is a superior device, there were really 2 “features” that persuaded me in the end. The first was Text To Speech, the second was availability.

The Nook does not have Text To Speech, and I could not find any evidence that they were thinking of adding it in a firmware upgrade. Also I wanted it before Christmas, and the earliest anyone can get there hands on a Nook is 15th of January.

I’ve had my kindle for 2 days now, and so far I am really happy with my purchase, but there are certainly some negatives, so here is my review.

The positives.

  • Great looking device, thin and light.
  • reasonable 3G coverage (in most major Australian cities).
  • Text to speech rocks.
  • Latest firmware upgrade (2.3) adds native support pdfs.
  • Good reading experience (eInk is cool).
  • Support for converting files of many different formats such as html, mobi pocket, rtf, etc…, although native support for these document types would be better.
  • Can sync your personal documents via your own PC.

The negatives

  • No Wifi. I have been amazed at how Amazon have actually sold this as a feature “You don’t have to hunt around for a wifi hotspot”, actually Amazon, I have one of them at home, as do many people, also many of the cafe’s I would go to read have them as well.
  • No Australian news content. This really infuriates me, I would love to get The Age delivered to my kindle, but alas I’ll have to go on killing trees to get my news.
  • Proprietary DRM format. It really annoys me that if I do eventually decide to go for another ebook reading device, I will potentially lose my entire book collection.
  • Not all books come with Text To Speech switched on. I got caught out on this on my first purchase, not checking the information thoroughly enough. I feel a bit cheated, as I feel the publisher has no right to determine how I choose to consume their content. Are they going to dictate that I cannot have another human being read it to me? No, then why draw the line at a computer?

My particular reason for wanting the Text To Speech feature is that I am a very slow reader, and Text To Speech would drastically increase the amount of books I could “read”. In future I will be making purchasing decisions based heavily on whether or not Text To Speech has been allowed by the publisher. Having said that, I wouldn’t be surprised if the problem with Text To Speech rights lies more with audio book retailers than with publishers, but that’s one for the conspiracy theorists to argue about.

Thursday, December 03, 2009

Visual Studio Help Integration Wizard and Continuous Integration

As .Net developers we are constantly using msdn and the Visual Studio help system. One of the most powerful features of Visual Studio is the ability to hit the F1 key on a class, property or method, and have it whisk you away to the correct msdn entry for the item of interest. When using third party libraries, it is great when they are able to provide you with the same ability to search API documentation from within Visual Studio. This is all possible, but I recently discovered, not necessarily trivial, and there is a really big gotcha if you want to add it to your Continuous Integration process.

To start with you need to ensure that all developers of your API are meticulous about putting XML Summary comments on ALL public facing entities. This is a good practice whether or not you intend to distribute the API.

The second step is to use a tool like sandcastle to build compile the xml comments into a usable format. Sandcastle has a number of different outputs including the classic .chm (Compressed html) output that is easy to read and can be distributed with your project, however, if visual studio integration is what you are really after, then you need the Html2 help output (*.hxs). As there are a lot of different settings for sandcastle, it is good to use the SandCastle Help File Builder that provides a nice settings based interface as well as a command line utility to aid you in building your help files.

The third step is to create an installation package (.msi or .msm) to distribute your documentation to the millions of developers who will be using your API to write the next killer application. There are a few ways of achieving this, to do this from scratch you could follow these intructions, however, in the Visual Studio 2008 SDK, there is a project type called the Help Integration Wizard that attempts to automate this process for you. This very simple project template works great right up to the point where you try to integrate it into your Continuous Integration Process.

The first problem is that the solution created contains 2 vdproj files, which means that you can’t build them with MSBuild, and are forced to pollute your build server with Visual Studio and compile it using the devenv command line. However, even after you have taken this hit, the pain doesn’t stop there.

The reason is because of 2 files that are included surreptitiously in the project path but not added to the solution. The executable FixRegTables.exe, and a merge module called MSHelp2_RegTables__RTL_---_---.msm get added to the CollectionFiles folder for the merge module project that is created. If you fail to check these in to your source control solution, your CI build will break with an error about a post build step. However, if you do add them to your source control repository, then chances are when you perform a “Get Latest” operation, these files may well be marked as “Read Only” as this is standard practice for many source control systems to ensure that source files are not modified during a build. In this case, the build will work as expected and produce an msi file, however, the resultant msi file will not install anything when run. The issue is that the Post Build step mentioned above needs to modify the merge module.

The solution is to either check the 2 files in to your source control system, and make the merge module writable as part of a pre build step, or to copy the two files from their location in the visual studio sdk into the Collection Files folder as a prebuild step.