Showing posts with label LINQ to Amazon. Show all posts
Showing posts with label LINQ to Amazon. Show all posts

Thursday, January 31, 2008

SD Times' "Does .NET With LINQ Beat Java?" Article Raises More Questions Than It Answers

David Worthington's Does .NET With LINQ Beat Java? Software Development Times article of January 30, 2008 has a snappy head but the article's deck, "Framework's data query capabilities give it an edge, experts claim," appears to be disputed by at least one "expert," namely Jonathan Bruce of DataDirect Technologies (see below.)

Worthington quotes Jonathan as saying:

DataDirect’s Bruce acknowledged that from a productivity point of view, LINQ combined with its tooling gives .NET shops a productivity advantage that the Java community cannot match. He credits Microsoft’s ability to “package [productivity patterns and tooling] all up into something useful."

That said, he noted that LINQ is an unproven technology that is new to the market and said that he could not imagine anyone making corporate bets on LINQ just yet. “On the Java side, data access is rounded and stable. As a technology officer, it is an easier bet to make [on] what will reduce risks from a data perspective,” he explained. [Emphasis added.]

If Bruce "could not imagine anyone making corporate bets on LINQ just yet," why has DataDirect announced their intention to provide EntityClient-enabled ADO.NET data providers for the Entity Framework? Java's "rounded and stable" data access sounds to me like an apologia for the status quo (a.k.a. JDBC).

Apparently, Bruce isn't aware of LINQ to Objects, LINQ to XML, and the widening variety of current third-party LINQ implemetations and upcoming Microsoft versions:

Another example is XQuery, a language designed to query XML data. XQuery, he said, does a better job with data from many venues because of XML’s flexibility. By contrast, he claimed, the current implementation of LINQ is very targeted to what the developer is querying and the ability to “mash up data sources” has not been delivered yet, Bruce explained.

One of LINQ's strong points is it's "ability to 'mash up data sources'." Jon Udell's LINQ 101 post of September 28, 2005 demonstrated a three-way join between an XML data source and two CLR objects with the PDC 2005's LINQ preview. You can now join generic sequences from sets of in-memory objects (LINQ to Objects), XML documents, relational databases (LINQ to SQL and LINQ to Databases), and other domains with LINQ to SharePoint, LINQ to ActiveDirectory, LINQ to Amazon, and LINQ to Streams. If this capability for joining IEnumerable<T> sequences doesn't enable mashups, I don't know what does.

I find LINQ to XML to be a much more approachable and practical method for querying and composing XML Infosets than XQuery and/or XSLT. It's interesting that Microsoft is working on LINQ to Stored XML to supplement or replace its pre-XQuery 1.0 implementation for the SQL Server 2005+ xml data type.

Note: I have some questions about Bruce's prognostications in the "Jonathan Bruce's Data Services and LINQ Crystal Ball Appears a Bit Cloudy" topic of LINQ and Entity Framework Posts for 1/28/2008+.

Sunday, November 11, 2007

SubSonic will be the "Convention-Driven Toolset for Microsoft’s New MVC Framework" for ASP.NET

Not the Entity Framework, not LINQ to SQL, but (gasp!!!) open-source SubSonic will deliver the default data abstraction and persistence layer and scaffolding for the forthcoming Model-View-Controller (MVC) add-on to ASP.NET 3.5. SubSonic's creator, Rob Conery, will start work at Microsoft next Monday, November 12, 2007, to assist with integration chores and evangelize ASP.NET developers. I missed Rob's October 26, 2007 Microsoft, SubSonic, and Me post, which announced that he was going to work for Shawn Burke, one of Scott Guthrie's direct reports in the Developer Division.

Updated 11/13/2007 and 11/18/2007: See below.

Scott announced the MVC add-on in his ASP.NET MVC Framework post of October 14, 2007. The MVC pattern for connecting the UI (View) to  business logic (Controller) and data (Model) originated in Smalltalk projects more than 30 years ago. Scott says the following about the advantages of the MVC pattern:

One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an application.  Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated. [Link added.]

The MVC pattern can also help enable red/green test driven development (TDD) - where you implement automated unit tests, which define and verify the requirements of new code, first before you actually write the code itself.

However Scott's post didn't mention how ASP.NET's MVC Framework will implement the persistence layer for the Model's business objects. In a comment, Scott says only that:

The ASP.NET MVC framework will work with any data provider.  LINQ to SQL and LINQ to Entities are both definitely fully supported (my sample at the alt.net conference was actually done with LINQ to SQL).

Update 11/13/2007: Scott Guthrie provides a very detailed demonstration and tutorial for the upcoming MVC Framework in his ASP.NET MVC Framework (Part 1) post of 11/13/2007 (3:45 AM!) LINQ to SQL provides the data access and persistence layers. I estimate the length of Scott's post to be at least 15 feet.

The problem with LINQ to SQL in a Test-Driven Development (TDD) environment is the difficulty of mocking persistent objects with in-memory objects. That's because there's no memory-based DataContext object you can easily substitute for the DataContext that's bound to the SQL Server 200x instance. The "mini connectionless DataContext" that was promised but not delivered for multi-tier use of LINQ to SQL might have served this purpose. (See the "Emulating the Phantom Mini Connectionless DataContext" section of my LINQ to SQL Has No "Out-of-the-Box Multi-Tier Story!" from October 18.)

Note: Ian Cooper says:

LINQ to SQL is usable with a TDD/DDD approach to development. Indeed the ability to swap between LINQ to Objects and LINQ to SQL promises to make much more of the code easily testable via unit tests than before. [Emphasis added.]

The preceding is quoted from Ian Cooper Takes on DDD, TDD and PI with LINQ to SQL of June 11, 2007. Ian's Being Ignorant with LINQ to SQL post of June 10, 2007, provides sample code for swapping tests of LINQ entity retrieval queries, but data retrieval is only a small part of the DataContext's feature set.

Update 11/13/2007: Frans Bouma added a comment about difficulties with mocking LINQ to SQL, particulary when you use GroupJoin.

An additional impediment with LINQ to SQL as an MVC data provider is that it's connected at the hip to SQL Server 200x and Compact Edition (SSCE), and Microsoft has no plans to extend it's reach to competitive RDBMSs. Oracle and IBM are working on EntityClient data providers for the Entity Data Model (EDM), but no one knows when Entity Framework (EF) or the alternative providers will be ready for prime time. It's equally uncertain whether mocking the EDM's heavier weight ObjectContext will be practical.

SubSonic, Scaffolding, LINQ, Migrations and the MVC Pattern

SubSonic is an open-source data abstraction layer (DAL), object/relational-mapping (O/RM) tool, and scaffolding environment that's provided under a commerce-friendly Mozilla Public License (MPL) Version 1.1. Its Scaffold server control requires only a single instruction, such as

<cc1:Scaffold ID="Customers1" runat="server" TableName="Customers"></cc1:Scaffold> 

to autogenerate fully operational GridView and details view pages for a site. Jon Galloway's October 30, 2006 Microsoft should ship SubSonic (formerly called ActionPack) with Atlas post offers a detailed review of SubSonic's capabilities by an expert third party.

SubSonic's default scaffolding closely resembles that of the ASP.NET Team's now-abandoned Blinq project and it's DAL shares "convention over configuration" terminology with Ruby on Rails (RoR) and Project Jasper, which appeared to have fallen into a black hole but now just seems to be in limbo.

Rob's SubSonic: Migrate Me post of October 3, 2007 says SubSonic will incorporate migrations (also a RoR feature) "as part of our next major release, which will also include our REST Handler and our new query tool - so it will be a few months until we can get this all tightened up." According to Rob, his "job will be to build out SubSonic as the 'sweetness' on top of ASP.NET and (more notably) the new MVC platform. SubSonic will be the convention-driven toolset for Microsoft’s new MVC framework." Presumably, this means Rob will be working full-time on the "next major release."

The new query tool presumably will substitute strongly typed, compiler-checked constructs, such as the following from Jon Galloway's post:

Query qry = new Query(Product.Table);
qry.Top = "10";
qry.OrderBy = OrderBy.Desc(Product.Columns.UnitPrice);

for the string column names in the current version. SubSonic's new query syntax appears sufficiently similar to LINQ as to make practical substitution of LINQ to SQL's expression tree for SubSonic's query processor. Limiting the persistence database to SQL Server won't please the vast majority of developers.

In his LINQ: How To Use LINQ To Query Just About Anything post of July 2, 2007, Rob says:

Recently I have been asked by a client to use LINQ for some interesting stuff (which I’ll blog about later), and one of the things I needed to do was to use it to query a REST service. Step 1 was to query Amazon (since there is an existing sample out there on how to do this), and I just wrapped up that part of it and thought I would share with you how I dove nose-first into refactoring the existing sample to work with .NET 3.5, and also some of the neat stuff I learned along the way.

Since Rob has been working for Shawn Burke's ASP.NET team "(on contract) for the past 8 months or so," it's probably a safe assumption that "a client" in the preceding quote is Microsoft. Although Rob says in the same post, "I have no plans with SubSonic and LINQ," it's reasonable to expect a definitive "LINQ to SubSonic" implementation in in the "next major release."

SubSonic shares the ActiveRecord model with RoR. Migrations are a shortened RoR term for ActiveRecordMigrations, which manage versioning of the project's underlying database schema. SubSonic's "next major release" undoubtedly will add the SubSonic MVC App template to My Templates, as shown in the video described in Rob's SubSonic: MVC Preview Video post of November 5, 2007. The eight-minute Silverlight segment includes previews of:

  • Migrations
  • MVC scaffold generation
  • Core site design (upgrades)

but no narrative on the audio track.

Rob's also tasked with "creating webcasts and writing up tutorials for MVC/ASP/SubSonic." I enjoyed the music behind the preview video, but conventional narration is probably the better approach as new SubSonic's RTM approaches.

SubSonic's Continuing Open-Source Status

Both Rob and Shawn emphasize that SubSonic will remain an open-source project under the MPL 1.1 license. Rob says:

I think it’s worth pointing out that SubSonic hasn’t been “bought”. Some might smell a conspiracy here, but I’ll leave that to the X-Files and Cap’n Crunch crowd to drum up all the evil reasons why the mothership has “beamed me up”. SubSonic will remain under the same MPL 1.1 license it always has, and will remain as completely Open Source as it always has - nothing will change at all. I’m just getting paid, essentially, to work on it :).

and Shawn goes on with:

To be clear Microsoft did NOT buy, annex, co-opt, or otherwise take over SubSonic.  SubSonic is still what it is, and a big part of Rob's job is going to be to make sure it continues to grow and provide a great platform for building data-centric apps.  Rob still has complete authority over SubSonic, it's his baby.  He'll also be pitching in to help find ways to deliver value for ASP.NET in general.

Jon Galloway explains:

[SubSonic]'s licensed under the Mozilla Public License, which is pretty simple - you can use, redistribute, and even sell software using MPL'd code, but if you modify the MPL'd code you have to publish your changes.

So it seems practical to me for the ASP.NET team to package SubSonic's "next major version" with the ASP.NET MVC Framework, as Jon recommended more than a year ago.

P.S. Rob won't be leaving Kaua'i, as he mentions in a comment. "[B]ut it’s only by virtue of the fact that there’s a dev center in Honolulu, that I’ll be flying to Redmond often, and that I wouldn’t mention it on my blog … oops."

Update 11/18/2007: Hamilton Verissimo, aka hammett, founder of the Castle Project wrote a MS MVC and the MVC Team post on November 18, 2007 about his trip to Redmond to review progress on the ASP.NET MVC Framework. Hammett concluded:

Right now, though, for folks with lot of expectations, the CTP might be a turn off. That’s because what you’re going to see is a very small framework, with a lot to be done to be useful. As they say, the CTP is mainly for feedback. I’m sure Milestone 2 would be something great, though.

And what happens to MonoRail? - you may ask. I’m not sure. I was really adamant that they should try to support all things that MonoRail support, but I’m not sure they are going for that. MonoRail 2.0 is pending their implementation. If the final MS MVC rocks, and provides so many things, I’d vote for forget the MR 2. If the final MS MVC has clearly something lacking, MR 2 could reuse the infrastructure and provide some nice extensions.

 

Monday, July 02, 2007

Third-Party LINQ Implementations Update

LINQ to SharePoint

As promised, Bart De Smet has released the LINQ to SharePoint 0.2.0.0 Alpha for download from CodePlex with the following features:

  • SpMetal tool for SharePoint list entity creation
  • LINQ query provider for runtime LINQ query-to-CAML translation
  • A set of unit tests
  • Debugger visualizer for LINQ to SharePoint queries
  • Support for both C# 3.0 and VB 9.0

SharePoint Mapping Language

Bart's working on a major update to SpMetal.exe for Alpha version 0.3. He says:

However, there's more than just a new back-end to SpMetal. The cool thing about it is its potential for reuse elsewhere, including the VS 2008 IDE. Over time, the goal is to provide entity creation as easy as dragging and dropping lists from an add-in in Server Explorer to a designer surface. We're not there yet, but an important milestone is under development right now: SPML. Designers are just overlays on top of some source definition, for example a partial class with Windows Forms designer generated code or a resx file or ... In a similar way, SPML is the source-side of a SharePoint list mapping for LINQ to SharePoint. Currently it's very minimalistic, but over time it will get more and more expressiveness to drive the mapping process (e.g. you'll be able to decide which fields to include in the entity mapping and you'll be able to control a few aspects associated with entity updating, another 0.3 feature that's under development right now).

Note: For a recent OakLeaf post on LINQ to SharePoint see LINQ to SharePoint 0.2 Alpha to Meet Major WSS 3.0 Template/Apps Surge.

LINQ to Amazon Refactored

Rob Conery a developer from Kauai and the architect of the open-source Commerce Starter Kit for .NET 2.0 and the Subsonic "no-code" data access layer (DAL) has posted LINQ: How To Use LINQ To Query Just About Anything, in which he describes how he's refactoring Fabrice Marguerie's LINQ to Amazon project to .NET 3.5. Along the way, Rob provides one of the better explanations that I've see on expression trees. The IQueryable interface and expression trees enable LINQ to SQL and third-party LINQ implementations. He also includes a pointer to Paul Kimmel's June 28, 2007 Cigars, Lambda Expressions, and .NET article for DevLife that describes anonymous methods, lambda expressions. closures and currying in plain English.

Rob promises that the source code will be available the end of this week. Check his site or here for availability.

Update 8/8/2007: Rob published on August 2 a great LINQ to SQL screencast as SonicCast 6 - LINQ, LinqToSql, and SubSonic. His demo includes a simple technique to remove data source-related code from the page's code-behind file. He's considering adding support for LINQ to SubSonic or replacing its query generator with LINQ. No word so far on source code for his refactoring of Fabrice Marguerie's LINQ to Amazon to Beta 2.

i4o (Indexing for Objects) Article

Aaaron Erickson has written "Indexed LINQ" for .NET Developer's Journal. Subtitiled "Optimizing the performance of LINQ queries using in-memory indexes," the article covers the theory behind creating indexes on in-memory collections and applying an extension method to the Where() standard query operator to enable speeding queries by up to a factor of 100 or so with the indexes. You can download the source code, runtime binary or both for i4o at http://www.codeplex.com/i4o. (Update 8/7/2007)

Third-Party LINQ Providers List

A complete list of third-party LINQ implementations that I update periodically is: Third-Party LINQ Providers.