Mar 21 2008   4:39AM GMT

LINQ to SQL and the quest for the perfect DataContext “lifetime”



Posted by: Dilip Krishnan
Architecture, Development, LINQ

Reading posts like this from Microsoft MVP’s, it’s quite obvious that the best practices around using LINQ to SQL aren’t really evangalized well enough. Siting the post not because it is bad or un-insightful in any way; but just that even Microsoft MVP’s are struggling with how to wrap their heads around how the use the power of LINQ to SQL in a high transaction/availability web applications.

The problem here isnt with LINQ however, but its unfortunately named cousin, LINQ-to-SQL. As one of the commenters points out

The problem stems from the fact Microsoft have effectively merged two design patterns (Unit of work and Data gateway) into a single object - DataContext.

Well that too! The fundamental problem IMHO, is that there is coupling of two concerns namely object/change-tracking, and LINQ provider for SQL server. If it were properly factored/separated so that the facilities like change-tracking could be layered on top LINQ, then building n-tiers applications wouldn’t be the subject of so many posts on the web!! At the very least it wouldn’t be easy to create applications poorly architected for performance and scalability. The Datacontext not very different from DataSets, only packaged disguised and bundled with a LINQ provider to SQL Server.

  1. Datasets support change tracking
  2. Datasets can can manage relationships of entities within it
  3. Both make it easy to create database centric applications the quick and dirty way

Enough ranting! On to my opinion about what the lifetime of the DataContext should be

* For web application, Short and sweet and ignore the change tracking feature
* For a winforms application, i’d say long live DataContext! :) Can really leverage object tracking and change tracking features

This comment on the same post seemed very interesting

If we have this, of course we could use what it’s called Linq to SQL “POCO Support”, this means that we are not forced to use the auto-generated classes with its EntitySets and EntityRefs, we can use just any plain class with the appropiate attribute decoration.

This allows to create your own disconnected change tracking (there’s no Microsoft solution to this problem in current versions, either in the upcoming Entity Framework)

The commenter has a project at codeplex and it seems an interesting solution


Mar 21 2008   2:54AM GMT

Free book preview for C# 3.0



Posted by: Dilip Krishnan
Development, LINQ

C# Query Expressions and Supporting Features in C# 3.0

This is a sample of a book that I have been working on with my coauthor Jamie King. As of March 2008, the full book is not yet available. However, this sample covers C# 3.0 fundamentals, and provides a full grounding in C# 3.0 Query Expressions.

It’s become more common for authors to offer a few pages or a chapter of their text to the public as a means of marketing. Our aim is to not only provide a sample, but also a useful stand-alone text. By itself, this sample provides any C# 2.0 programmer a foundation in C# 3.0.

Very in-depth look at query expressions. Book review out by Jon Skeet


Mar 17 2008   6:12PM GMT

Weekly SOA crumbs #11



Posted by: Dilip Krishnan
SOA

SOA
Kitchen Sink Variability

WCF

Scaling WCF applications can challenge development teams
Built In ServiceHost Validation Behaviors
WCF Tips and Gotchas from Neudesic Teams
STS? Available!
SOA Future Batches
Single Sign-On scenarios with Federation (Via Sam Gentile)
WCF - Syndication Extensions
(Via Sam Gentile)

MIX’08
RestChess: MySpace + WCF @ Mix
MIX Video Wrap Up

Notes from QCon London 2008 (via Stefan Tilkov)
Stefan Tilkov on REST
Paul Fremantle on Using REST for WS-*
Steve Vinoski on Serendipity and REST
Mark Little “Diary of a Fence-sitting SOA Geek”
Jim Webber

Props to link blogs
Christopher Steen
Jason Haley
Chris Alcock
Alvin Ashcraft
Arjan Zuidhof

Technorati tags: , , , , ,


Mar 10 2008   5:56AM GMT

Enterprise architects and SOA



Posted by: Dilip Krishnan
SOA

Reading this article seems like a call to action for the enterprise architects to wake up. The one important reason that Linthicum fails to point out, IMHO, is that selling and implementing an SOA successfully is not only a technology problem. It’s a business problem and a people problem. Most enterprise architects approach a problem from one of the following viewpoints

  • Business architecture
  • Integration architecture
  • Application architecture
  • Operational architecture
  • Development Architecture

The better the architect the more holistic the architecture solution covering a large portion of these viewpoints. More often than not, the most neglected of the viewpoints is the business architecture viewpoint. As described quite nicely by this post on viewpoint flip

Nowadays, when someone asks me what SOA is all about, I don’t glibly say “loose coupling.” I say very slowly, “It’s about being s-e-r-v-i-c-e o-r-i-e-n-t-e-d, being oriented to the viewpoint of the service consumer. SOA thinking means looking at a domain from the outside in, from the perspective of a consumer and what they wish to achieve, rather than how the domain sees itself, i.e., as a set of inter-related objects.”

Having gotten the technology/business aspects worked out, now comes the most challenging of the hurdles; the people problems; and this relates to some extent to the “Fear of change”. An enterprise architect needs to work “as” the business and not “with” the business for an SOA initiative to be successful and this also involves some level of politicking.

Technorati tags:


Mar 10 2008   5:26AM GMT

Weekly SOA crumbs #10



Posted by: Dilip Krishnan
Development, SOA, Web services

SOA
SOA benefits from WCF interop, Iona CTO says
The Tao of Authentication (Part I)

REST
RESTful Data
Idempotency of PUT, and common mistakes (via Stefan Tilkov)

Architecture
The Deciding Characteristic of SOA - The Viewpoint Flip
So What Gives SOAP its RPC Flavour?
About layers and tiers
The Cost Of Breaking Changes

WCF
DataMember Best Practices

Interesting
LINQ to Life

Props to link blogs
Christopher Steen
Jason Haley
Chris Alcock
Alvin Ashcraft
Arjan Zuidhof

Technorati tags: , , , ,


Mar 2 2008   11:19PM GMT

Weekly crumbs #9



Posted by: Dilip Krishnan
SOA, Architecture, Web services, WCF

WCF
Dominick Baier has a series on Using IdentityModels

Architecture
Video of Luke Hoban’s In-Depth Look at C# 3.0
Unity IOC screen cast
Understanding Viewstate in Asp.net
Service Oriented Architecture Infrastructure Datasheet
Versioning Issues With Abstract Base Classes and Interfaces

Misc
The Art of Currying

Props to other link blogs
Christopher Steen
Jason Haley
Chris Alcock
Alvin Ashcraft
Arjan Zuidhof

Technorati tags: , , , ,