Ratko Ćosić - lamentations of one programmer

srijeda, 11.02.2009.

Book Review: Pro LINQ - Language Integrated Query in C# 2008



Title: Pro LINQ - Language Integrated Query in C# 2008
Author: Joseph C. Rattz, Jr.
Publisher: Apress, 2007.

Overall mark: very good

Well, I can't give a bad mark if the book has very high review scores. It is for a reason, though.
The author is very well experienced in this topic, and very well explains it. Also, what I found intriguant and uncommon, it has some personal-style of writing, which makes the reading more smooth and sound.
And what makes the book a little bit bad is the structure of chapters.
Of course.. Actually, I didn't find any decent book lately which has that. Phew!

The book is divided into one plus four large blocks, an introduction block, following by the blocks each depicting one of the LINQ's implementations:


  • PART 1: (let's call it) INTRO

  • PART 2: LINQ to Objects

  • PART 3: LINQ to XML

  • PART 4: LINQ to DataSet

  • PART 5: LINQ to SQL


So far - so good! And, bravo for omitting the appendices!
After that, unluckily, the topics are little bit meshed up.

Part one is written very nice; it includes an everlasting HelloWorld application, and C# 3.0 language enhancements created just for LINQ. The first examples are really good, describe well in just couple of lines what is all about. Also, I'm very fond of the tought that also author has, and that is, LINQ is quite unfamiliar for the developers except for SQL usage. He follows with some tips and tricks (perhaps too early), and then with the language enhancements of C#. As I've said, this chapters are very well written and if the author just stick to this schema, he could done the terrific job...

Now comes the LINQ to Objects, actually the essence of the LINQ and therefore must-be key part of the book. It was not necessary, though, to split the chapters like they are: LINQ to Objects Introduction doesn't bring anything else but nine pages (including a table and a summary) and it is too small to take a grasp. But it is very good written indeed. After that, you are presented by the deferred operators, following by non-deferred operators. Also, very good explained. Actually, too much about it! From here goes the spreading the topics on too many pages, and therefore, becoming quite boring...
For each operator every possible prototype is explained, along with the examples. The code snippets and console printouts are not necessary. After all, the topics are self-explanatory as they are. Nevertheless, it is nice to read them and pass through them (120 pages!).

In the third part, LINQ to XML, not surprising, the introduction is the first chapter. Also, to short. It has six pages in print and it doesn't enlist all the parts of it but rather just one example. After that, significant API design enhancements are presented: XML tree construction with functional construction, element centricity, names, namespaces, prefixes, nove value extraction. All good. The LINQ to XML object model is depicted afterwards (maybe it would be good idea to put it on the very beginning of the chapter), along with deferred query execution, node removal, and the so-called Halloween problem. I must confess, really good written.
And now, unfortunatelly, comes a boring part - enumerating the XML objects and giving the examples. As with the operators, too much of explaining - it is straightforward and not necessary to explain them further (cca 65 pages).
Extension methods (LINQ to XML operators) chapter also enumerates the stuff a little bit too broad, and then we are reading Additional XML Capabilites. Queries, transformations (XSLT) with tips, validation of the schema, XPath.. thumbs up!

LINQ to DataSet was a mystery to me, but luckily, the topic is very good explained and it solves that mystery good. I never thought that LINQ to DataSet is so useful. By using a couple of added operators, such as Distinct, Except, Intersect, Union, you can make your datasets even smarter. Playing with DataRow field operators also brings joy, as well as DataTable operators, and more over, typed DataSets. Very good.

LINQ to SQL is the most interesting part because it deals with the concrete and practical implementation of the LINQ, and that is - a database. More specific, a SQL Server database. The chapters explain large scale of topics, and it is tricky to sort it out by chapters. So, I take it lightly to criticize.
The introduction is very good, it presents all the paradigm in just a few pages: connecting, updating mechanism, the DataContext class, entity classes, associations, concurrency conflict resolution, SQLMetal command-line tool, Object-Relational Designer - everything what you actually need!
And there comes the chaos. Instead of presenting DataContext class first, followed by LINQ to SQL entity classes (because they are physical part of the DataContext), then LINQ to SQL operators (that is, manipulating with the entity classes), and then other stuff at the end, the author decided to give somewhat confusing order of themata, but I must confess, all the topics are very well explained and concise:


  • LINQ to SQL Introduction

  • LINQ to SQL Tips and Tools

  • LINQ to SQL Database Operations

  • LINQ to SQL Entity Classes

  • The DataContext

  • Concurrency Conflicts

  • Additional SQL Capabilities



Up to this date, I didn't find any 'black-yellow' book (published by Appress) about ADO.NET Entity Framework.
This is sad, as I'm currently searching for some good book in that topic, and the books I've found are just too nasty for me to grasp...

Nice reading!

- 22:04 - Comments (1) - Print - #

četvrtak, 05.02.2009.

Quick Migration to Visual Studio 2008



I have just pass through this task and it seems to be very simple and practical.
So you want to migrate your (VS 2005) code to Visual Studio 2008 and want it now? No problem! Let's go!

The simplest way to start with it is that you start the studio and open a project from here. When you pick a project and try to open it with new Visual Studio, it will prompt you with the migration wizard dialog, as you can see here:



The messages are straightforward and you practically do not have to do anything except to confirm that you want to convert it to the newer version. So, let's do it!

If your solution is under source control, it will be automatically checked out, along with all the containing projects, and settings files, but, as you will see, the changes will be minor.



Let's go down to one by one change for a second:

1. The solution file (*.sln) will be changed:
- only header of file is changed to:
Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008

2. The project files (*.csproj) will be changed:
- header is changed to:
Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- a couple of tags are added:
FileUpgradeFlags
OldToolsVersion -> 2.0
UpgradeBackupLocation


3. The settings files (Settings.Designer.cs) are changed:
- only SettingsSingleFileGenerator-Version is actualized (from 8.0.0.0 to 9.0.0.0)

Thanks to "multi-target" feature of Visual Studio 2008, we now have the chance to choose between .NET Framework on which to build our projects. Migration wizard will let us stay on 2.0, but we can change it any time by selecting the proper combobox option inside project properties, as you can see from the picture below:



Problems with the unit tests

You can step into one small problem if you have some unit tests already in function from Visual Studio 2005.
Alas, migration routine does not update the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll correctly, and leaves the 8.0.0.0 which is apparently not available in VS 2008.
This brings you with some weird error when you try to fire some of the tests:

Method ....MyClassInitialize has wrong signature.
Parameter 1 should be of type Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.


Only you have to do is to remove the reference from the unit test project and add it once again, but now with the correct version (9), as you can see from the picture. Now, build the project and the test should run as they did in VS 2005.


- 09:44 - Comments (0) - Print - #

<< Prethodni mjesec | Sljedeći mjesec >>

Creative Commons License
Ovaj blog je ustupljen pod Creative Commons licencom Imenovanje-Nekomercijalno-Dijeli pod istim uvjetima.