Author: Tim Patrick
Publisher: Microsoft Press, 2010
Aimed at: Primarily targeted at C# and VB.NET programmers new to ADO.NET
Pros: Good overview of MS data centric technologies
Cons: Does not benefit its primary target group
Reviewed by: Nikos Vaggalis
Although intended for those new to ADO.NET, this book may suit those with some familiarity rather better.
Database application development is catch-all terminology encompassing working within the application and within the database, not to mention n-tier architecture and web services; hence a book on database application development is always a challenge. It has many aspects to cover and at the same time needs to maintain a balance between getting into too much depth and baffling the reader and merely scratching the surface, risking quickly losing the reader's interested.
Such aspects could be normalization, referential integrity and constraints, business rules and validation, concurrency and transaction isolation, SQL and stored procedures, developing GUI's, forms and data binding, statefull, stateless architecture and Web services, tabular format vs ORM, and the list goes on.
So what does this book cover?
I will start by saying that I did benefit from this book. At some time in the past I had used ADO.NET version 2.0 of the library but, because it is not my primary tool and scarcely used, I'd lost track of the evolution of the library. I couldn't easily follow the all the updates and revamps it had undergone and the overwhelming growth in terminology flying around on the subject, like ADO.NET 3.5, Linq to entities, Linq to SQL, Entity framework (EF). Then, there was the hype and discussions online on ADO.NET 2.0 vs EF, that ADO.NET 2.0 is obsolete and EF is the way to go; all of that could only add to the aforementioned confusion.
Thus I needed a quick, concentrated, no fuss, hands-on guide to get me up to date, and if I look at this book in this way I could say that I was spot on.
It provided me with a refresher and overview of the evolution of the MS data centric technologies by comparing them and explaining each part's mission, and hence reason for existence and the advantage of using one over the other. This overview was further solidified by zooming in on the various parts/classes of each model, their interconnections and hierarchies and by going through the code samples demonstrating their use, acting like a reference guide; for example looking at the definition of a method or a property and how it is used,
That is, one target group for this book is the programmer who needs to get a quick, no-nonsense, overview of the MS data access facilities, getting acquainted with the environment quickly without going into depth.
In that sense it could also be suitable for a technical manager trying to evaluate various technologies suitable for the enterprise.
As far as the other target group goes, the C# or VB programmer who has no experience on ADO.NET, I do not think that it would be of much help.
The book focuses on Visual Studio which is an integral part of building database application with ADO.NET. It is also an IDE rich in wizards, ready-made, data-bound controls and code generators. All these facilities not only help the novices to get an easy and effortless start but also allow experienced developers to save time and automate tasks (I think anyone who has used an ATL wizard to build a COM application in C++ would agree). This therefore makes the wizard the novices' favorite tool, enabling them to get a head start by exploiting its capabilities. Afterwards they can start drifting into the internals, start learning in depth and begin to customize and parameterize the automatically generated code. A good metaphor would be looking at things from a bird's-eye view and then slowly zooming in.
However although the book primarily targets novices, does not follow this approach.
It starts off in Chapter 1 with a good explanation of what ADO.NET is and its extensions and then directly moves on to hand coding data tables, columns, setting column types, adding rows and inserting values into the rows, in Chapters 2 and 3. It certainly does a good job of explaining classes, properties, events, hierarchies and interrelationships, but again the novice would prefer to look at a ready-made Binding Navigator control which encapsulates all the needed behaviour; add new rows, navigate through master-detail relationships etc with just a button click.
Saying that, data binding is not explored until Chapter 21 and one of the most powerful controls for data presentation, the DataGridView, is only glanced at. Also wizards are presented as a side feature with their use not being fully discussed.
The same holds true for the Chapter on grouping tables together in the disconnected database (the Dataset) and coding relationships between them. A novice would be better advised to start with a wizard, connect to a data source, get the schema from the database and let VS automatically map the table relationships and constraints into the dataset. Then if the need arose he would customize it by tweaking the generated code or adding his own extensions.
Furthermore, throughout the book special mention is given to the strongly typed dataset and its importance, but there is no attempt to show how you could turn a generic dataset into a typed one. It is acknowledged that Entity Framework has additional features that make it a better alternative than the strongly typed dataset, but it does not take into consideration that you might not want to use EF after all. It comes as a surprise since it is very easy to do by just dragging and dropping tables on the Dataset Designer's surface. The table will also carry its own Typed Table Adapters. This procedure was added to Visual Studio to eliminate the typing problem and as a matter of fact there is a brief demonstration on page 32, but with the sole purpose of just showing how you can drag and drop a table visually. There is no coverage of the typed dataset, the typed adapter and its CRUD properties. I would have preferred this example to be used as the basic template and be built on.
You also don't get to build an application step by step, hence getting familiar with a guided workflow, but you are constrained into using an already made application where you copy and paste code examples into routines , subsequently trying to learn by observing the newly added behaviour.
Chapters 4 to 6 are concerned with manipulating data on the disconnected cache by filtering ,sorting and aggregating while Chapter 7 is concerned with XML and dataset serialization / deserialization, completing Part I of the book
Part II is the interesting stuff. Connecting to the database, Querying the database, and Guaranteeing Data Integrity. Personally I think this part should have come first because that is what primary concerns the developer - connect to the database, fire queries and get to the data.
Chapter 12 on Data Integrity makes a brief introduction on the ACID transaction properties and pessimistic and optimistic locking. There is no mention of the various ANSI and Snapshot isolation levels, MVCC, and the code examples use the default isolation level which I guess should be Read Committed. Then it goes on to distributed transactions. Instead of that I would like to have a few pages dedicated to the phenomena the isolation levels seek to remedy and their relation to concurrency, just to raise the awareness of the reader.
Chapter 12 concludes Part II and we move on to the Entity Framework part. It gives a good overview of what it is, why is different to its predecessor and its advantages, and goes on to show how to use it. At last we find a good solid example of using a wizard to visualize the data and do the OR mapping; the Wizards 'magic' shines and in the ORM case it is not just an alternative but an essential part.
Part IV is dedicated to Linq. I think this part is the best of the book, going through its various flavours and giving a crisp explanation of the syntax, plus this is the part where you get real value from the code examples.
Part V is the final one and briefly looks at web services utilizing REST and Data binding. I think that the data binding facilities (especially Visual Studio's very rich ones) and the data binding Interfaces should have been a primary focus of the book with more coverage.
Since it only focuses on MS products (VS studio, SQL Server,.NET platform,C#,VB.NET) I would also want a brief introduction to CLR's integration with SQL Server which could help the .NET programmer take advantage of their existing OOP knowledge in moving to the database
To sum up, this book left me with mixed feelings. The author is technically savvy and well equipped to talk on the subject but I think his intentions are not getting through because of the approach employed.
However, as I have already said , I did benefit from it since I fall into the non-novice, somewhat familiar, target group. It provided me with a solid overview of the MS data technologies and acted as reference guide on the various classes comprising the library. If you belong to the same category as me, then I think that you will find that you will benefit as well.