.NET Developments - A SearchWinDevelopment.com Blog

.NET Developments:

 

A SearchWinDevelopment.com Blog


A blog on all things .NET, with news and tips about Visual Studio, ASP.NET, Visual Basic programming, C# and .NET architecture.

NET 3.5 SP1 and VS 2008 SP1 beta appears

Microsoft released a beta of .NET 3.5 SP1 and VS 2008 SP1 releases. While devoted in great part to bug fixes, they also include new features, some that have been eagerly awaited. Versions of ADO.NET Entity Framework and the ADO.NET Data Services framework (Astoria) are included. Read more »

Anonymous Methods - Elegance or Kludge

According to Wikipedia, a kludge (or, alternatively, kluge) is a clumsy or inelegant solution to a problem or difficulty. In engineering, a kludge is a workaround, typically using unrelated parts cobbled together. Especially in computer programs, a kludge is often used to fix an unanticipated problem in an earlier kludge; this is essentially a kind of cruft.

When I first stumbled upon the concept of anonymous methods in C# 2.0 the first thing I thought of was …jeez it’s just another name for GOTO!  I’ve since changed my mind.  Have any of you ever used the Gosub…  Return programming construct from way back in the GW-Basic days?  I’m dating myself but in a former life I had the responsibility of maintaining a servo controller program that ran a servo motor (a DC motor that is capable of moving in programmed increments forward and backward) for a plant that made flour tortillas.  (yes - for Taco Bell no less!)  But I digress.  This particular brand of “Servo Basic” as it was called did not have the ability to address function calls.  It was all done with line numbers.  The program started at 10 and ended at the highest line number.  The only way to program a function in this version of basic was to use the Gosub… Return construct.  For instance “Gosub 100″ would jump to line 100 in the program and start executing code until a “Return” statement was hit then control would return to the line after the calling “Gosub” statement.  It was all very archaic but very versatile when it was all you had. 

Now I tell you that story so I can tell you this one:  I was happily coding one fine day when I encountered a problem that I needed to solve and it occurred to me that a Gosub… Return would be perfect here!  It was a function with lots of values passed in that needed to perform the same processing multiple times but I didn’t want to pass all that data around on the stack.  This, my friends, is the perfect case for an anonymous method.  You can define an anonymous method anywhere inside a function and when you call the method, it has the same scope as the code that defined the method.  The example here uses a SqlDataReader to populate an object.  The reader may or may not have some columns in it.  Since the only way to determine the columns in the reader is to use the GetSchemaTable() function and look at the results, I wrote an anonymous method to perform the search and was able to use the search to check for the existence of the questionable columns. 

Notice the placement of the definition within the function.  It is defined after the definition of the ReaderSchema DataTable.  The executing code in the function has scope at the point of definition and so it “knows” about the DataTable.  The syntax is a little funny but makes sense once you work through it.  The name of the anonymous method is “HasColumn” and can now be called from anywhere in the function after its definition.  It returns a boolean and accepts a string as designated by the delegate it is based upon.

Now I could have simply put the HasColum() in its own function and passed the table in to it along with the column name I’m searching for but then I wouldn’t have this totally cool use of an anonymous method, now would I?  However, the question remains:  elegance or kludge?

LINQ, WPF supported in Visual Studio 2008

Now that VS 2008 is out of the box, so to speak, it appears that a new era in Windows development is upon us. Language-Integrated Query is one of several game-changing technologies now supported in the Microsoft software kit. Although it is still early and there is a lot of learning to do, LINQ is poised as a whole new way of developing with data.

It is fair to say that the first rush of .NET technology was about catching up with Java, although there was much unique about .NET too. With LINQ, for now, it seems Microsoft has stolen a march on the Java opposition.

I spoke recently with Jason Beres, director of product management at Infragistics, which is one of the major third-parties in the Microsoft market. Beres said people will take LINQ very seriously. “I think it going to be the de facto way to do any real data binding or object access moving forward,” he said.

With the new Microsoft tool kit comes Windows Presentation Foundation (WPF). Is WPF game changing? That is hard to say. When it was first conceived, the ubiquitous Web interface seemed to be overstressed, and ready to be replaced by a new generation of WPF-based Smart Clients that would use something like WPF. But, before WPF made it too market, AJAX came on strong as a means to give new life to Web interfaces.

This means the plate of companies like Infragistics is pretty full. Infragistics has just rolled out NetAdvantage for WPF 2007, which is compatible with Visual Studio 2008. At the same time, according to Beres, the company has been re-tooling its frameworks around ASP.NET AJAX as well.

For Infragistics and others, Silverlight looms as another alternative interface. Watch for Infragistics and others to provide Silverlight components, especially now that Silverlight 2.0 (which, more than its predecessor, rightly bears the mantle of “WPF/Everywhere”) arrives in its first beta form.

LINQ, WPF and VS 2008 have been primary areas-of-interest for the SearchWindowsDevelopment.com site for some time. We invite you to check out our LINQ VS 2008 pages, and to stay tuned.

RELATED INFORMATION:
> VS 2008 and LINQ Topic Page
> Introducing WPF
> Introduction to Silverlight 1.0

AJAX Enabled Web sites in Visual Studio 2008

Visual Studio 2005 provides an Web site application template to create AJAX enabled ASP.NET Web sites.

However, when you use Visual Studio 2008, you will not find this template in the New Web site creation templates.  The reason for this is that  Visual Studio 2008, by default creates a .NET Framework 3.5 application.  See the .NET Framework type at the top right section of the window image below.

AJAX is now integrated into the framework.  In Visual Studio 2008 all web sites that are created using .NET Framework 3.5 are AJAX enabled.  You don’t have to create a separate AJAX enabled web pages.

Bill Gates has been popping up a lot lately

Bill Gates has been popping up a lot lately - at the Office Developer Conference, at the SharePoint Conference, and so on. An interesting leg on his journey - this is, after all, a farewell tour - was his stop at Stanford University on Feb 19.

The Stanford visit is one of many he’s made in recent years to drum up added interest in computer science among students. 

Programming seems less and less to be a career of choice, and this worries Gates. So he goes to colleges and addresses the students frankly about why he loves software.

It is not all together unlike his speeches to certified geeks. There is plenty of ‘neat’ stuff, ‘really cool’ stuff, and the funny video. But I’d recommend the Stanford transcript as a good entry point to a view on the state of computing today and over time.

Gates glosses over a few facts - there were, for example, software businesses before Microsoft. But he is right in saying his company was the major one to take the low cost-high volume approach to business software.

He discussed a dream ‘’required some heroic assumptions. ‘’

We had to believe that the cost of the hardware would come down. We had to believe that the volume would go up. And only then would the economics of being able to spend tens of millions of dollars to write a software package, and yet being able to sell it for say $100 or less, actually make sense.

Much software today is free. Microsoft does not mind that, if it is free too students who will go on to do way cool things, including perhaps becoming a Windows developer some day. At the same time Gates spoke at Stanford, the company announced its DreamSparks free software program, which Ed Tittel recently wrote about in ‘’Microsoft sparks creativity with DreamSpark student developer program'’ on SearchWinDevelopment.com.