March 2008 - Posts

More on DataContext in (hopefully) a realistic world
19 March 08 10:20 AM | despos | 6 comment(s)

A comment from Bigyan to my DataContext article on DotNetSlackers yesterday made me think that I probably had to put my thoughts down a little more explicitly. The question that Bigyan poses is expressed in detail in this post of his and revolves around the best way of dealing with DataContext in multi-tier apps. My experience suggests that you use a new instance of the DataContext for each unit-of-work you need. The DataContext is a lightweight object to instantiate/dispose just for this. Can't find the link but somewhere on MSDN I've found a note (documentation) along the following, quite explicit, guidelines:

In general, a DataContext instance is designed to last for one unit of work however your application defines that term.

It is not recommended to maintain a DataContext live for more such as stored in a singleton object. Likewise, you don't have to pass it around, because it is not exactly a light object once in use with data attached: data + tracking info + mapping info. If you find it cumbersome to write new DataContext at each step, you can use a bit of abstraction and perhaps a Repository pattern. One more thought about not passing it around tiers and layers. You don't reuse the data context; you'll reuse the data you attach to it. So it makes sense to cache data somewhere and using distinct data context to do manipulation. On the new data context, you just attach any desired data. Yes, again, using the DataContext should be kind of using an ADO.NET connection: you use always new DbConnection objects but reuse command text and parameters. You never keep a connection open for a long time and don't pass it around tiers.

My two (euro)cents.

Filed under:
DataContext and design patterns
18 March 08 05:46 PM | despos | 2 comment(s)

An article on the internal structure of the DataContext object of LINQ-to-SQL is out on DotNetSlackers. Enjoy.

XAP has to be a MIME Type
11 March 08 10:44 AM | despos | with no comments

I love the VS embedded Web server, but it too often makes you thinking that things are easier than in the real and bitter world. So a trivial Silverlight 2.0 sample page that works from within the auto-generated ASP.NET Web site stops working as you create an IIS application for it. The symptom? No Silverlight content shows up and any network monitor tool you use reports that no XAP resource was found. But the resource is there. It's a simple matter of configuring IIS, though.

I was going to write a post myself. But then I found out that someone already did it. And it's a great write-up.

Filed under:
Hot AJAX+Silverlight2 in Warm Mallorca
06 March 08 09:38 AM | despos | 3 comment(s)

Silverlight 2 Beta 1 is out and I just installed it on my machines. OK--we're now ready for the next stage. A key question to answer for virtually everybody planning RIA development is:

  • Should I go with a Plain New Web approach and opt for AJAX on top of ASP.NET (or whatever else)?
  • Should I go with a Silverlight 2 approach in just a few months when it'll be released?

Put down simply, it's a matter of deciding whether you may or may not afford a plug-in of approx 4 MB to be downloaded/installed on client machines. Not an issue for intranet applications and most Web sites. Possibly an issue if you want to maximize (and even more) the audience of your portal. I expect to start seeing on home pages a choice Web|Silverlight in much the same way we see today a choice among languages.

To explore the tools, to refresh the techniques, to learn patterns and models, to grab directions, may I suggest you some hot stuff happening in a warm place this Spring?

What Next Generation Web Applications
Where Mallorca, Spain
When April 9 thru 11
Details and Costs here NB: all-inclusive-but-flight!!!

If you have a strong interest in sun and beaches in the warm Mediterranian islands, now you can also have some AJAX and Silverlight training in the same package :)

People of Europe (and not just Europe), join us ...

 

Source code for ASP.NET 3.5 Core Ref
05 March 08 10:00 AM | despos | 3 comment(s)

The latest baby, Programming ASP.NET 3.5 Core Reference, is out and you can freely download the full source code (21 MB) from here. It should be noted that for sort legal reasons (sic!), the binaries of the AJAX Control Toolkit couldn't be added to the package. It's therefore up to you to download and install it separately. Then make sure you have the proper DLL in the Bin folder of the book samples application.

Enjoy :)

Next Generation Web Applications
02 March 08 06:34 PM | despos | 10 comment(s)

The Web was first instantiated in the August of 1991 in one of the CERN labs. All of it was in two machines connected to the same network and exchanging HTML documents over the HTTP protocol. The HT in both names is not surprising—it stands for HyperText. And, at the time, the Web was all about hypertext and logical linking of related documents. HTTP was a mere (and simple) transportation protocol designed to be stateless and with no security pattern in it. HTML was designed to be a basic syntax to describe documents with just a bit of formatting, images, and hyperlinks.

Two years later, in the spring of 1993, I was still engaged on a COBOL/CICS/DB2 project, but actively managing to keep my head above water (read, get another job). At the same time, CERN waived any copyrights on the Web thus making it public domain. And the ball started rolling down the slope.

In less than two years, we had browsers and then JavaScript joined the group, then new tags were added to HTML, and CSS made its debut. In 1997, Microsoft came out with something called ActiveX. Horror story. You, the giant, willing to stop us, the people, from freely enjoying the Internet. It was clear already TEN years ago, that the only way to do serious RICH Web programming was extending the browser capabilities. But ActiveX had no security model (was security really a concern TEN years ago?) and no interoperability. And it was rejected.

Then Flash came in with a sandbox, full cross-platform support, and a poor programming model. For years, Flash has been the only tool available to incorporate rich graphics and media on the Web in a cross-platform manner. It was based on a plug-in, but who ever cared about it? J

In 2005, the AJAX revolution begins. Why in 2005? Because it was probably only then that the critical mass of browser adoption triggered the reaction. More than 90% of browsers happened to support the same set of features. And this set of features was powerful enough to build pages capable of bypassing the browser and make their own calls to the server.

So the whole AJAX thing began. And it’s a process whose termination is far from arriving. Not AJAX itself, but the paradigm shift it represents is revolutionizing the Web. As the mankind history demonstrates, a paradigm shift in any context is always a dramatic change. Have you ever heard of industrial revolution? Or perhaps relativity in physics? What happened next? Everything had to be reconsidered and redone.

Just like with AJAX today. Surely emphatic, but true.

What should we rethink, exactly? The browser, the JavaScript language, the HTML markup. More in general, the interaction model and page model.

Uhm. It’s getting tougher and tougher every word I type. Is it realistic to build true AJAX applications using the SAME browser, JavaScript, HTML language invented for the OLD paradigm? It’s like wanting to explain the Einstein’s relativity with the Newton’s law.  Mechanics had to be reconfigured in light of relativity. Likewise, Web application models are to be reconfigured in light of AJAX.

Partial rendering is not the point. Script services are just one minor detail. UI extenders are only whistles and bells.

Browsers and, at least, the page model have to be reconsidered in light of the new AJAX paradigm. How can you describe it? We are transitioning from “I send you a form; you send me a page” to “I send you data; you send me data”.

To implement this new model, we have raw materials (script services, JSON), but we desperately lack technology. Building true AJAX applications is horribly hard. Which is not an excuse not to incorporate at least a bit of partial rendering just in EVERY Web page.

Desperately seeking to replenish creativity. Thoughts?

 

Filed under:
Latest and upcoming book(s)
01 March 08 03:31 PM | despos | 4 comment(s)

As per Thomas request, I'm posting here the TOC of the latest baby, that is Programming ASP.NET 3.5 Core Reference.

Chapter  Title
1 The ASP.NET Programming Model
2 Web Development in Visual Studio 2008 
3 Anatomy of an ASP.NET Page
4 ASP.NET Core Server Controls
5 Working with the Page 
6 Rich Page Composition
7 ADO.NET Data Providers
8 ADO.NET Data Containers
9 The Data Binding Model
10 The Linq-to-SQL Programming Model
11 Creating Bindable Grids of Data
12 Managing a List of Records
13 Managing Views of a Record
14 The HTTP Request Context
15 ASP.NET State Management
16 ASP.NET Caching
17 ASP.NET Security
18 HTTP Handlers and Modules
19 AJAX Partial Rendering 
20 AJAX-Enabled Web Services
21 Silverlight and Rich Internet Applications (v1.x)

With boldface, the chapters that are either new or significantly reworked from the ASP.NET 2.0 edition. All the content in Programming ASP.NET 2.0 Applications Advanced Topics is not touched by the changes to ASP.NET 3.5. So it remains valid even today, in spite of the fact it has a 2.0 label.

As per Ricky request, instead, about the upcoming architecture books, details should be finalized this week. However, we're talking about two books of some 300 pages each to be available in the Sept/Oct timeframe. More details (and an outline) to come in just a few days.

More Posts