.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.

Microsoft LiveMesh Cloud and Yahoo

Microsoft’s recent discussion of mesh computing raises a few questions. For some details on what it is, go to the LiveMesh pages. The company has rattled about a lot of ‘Live” initatives, but this may be the first one with legs. Now, we are going to drop the mesh term immediately, and start to use ‘Cloud’ to describe whatever it is Ray Ozzie has been concocting - it is a more widely used term. Just think of it as a Grid on steroids, or rather a subset of a Grid on steroids.

Now the questions.

Who will the Microsoft Cloud effect? Seems like consumers are the target. It appears for now a way to connect one’s different electronic files and such. It may sneak into the enterprise, of course, just like Lotus 1-2-3 did.

Will it work? The answer there is yes, it will work about as well as most software; meaning, it will work much of the time, but you will come to curse it on occasion. Does IT have higher standards than individuals do on the question ‘does it work?’ - well, that is an open question.

Who is the competition? Basically, it is the nemesis called Google. Google has its own Cloud computing solution a’brewing, and Microsoft will have to meet the Valley Search Wizards of Googledom on that plain of battle because…well, because that’s what they are supposed to do. This is not mano on mano, no. It is geek-o on geek-o.

Of course, a wild card in the Cloud race is Yahoo. As you may recall, Microsoft is courting Yahoo with all the ardor of a CPA romancing a distant society deb. It is hard to guess how that will play out, but there is much about Yahoo that Microsoft will have to come to grips with. Yahoo has its own Cloud computing initiative - it has a lot of computers sitting around down on the farm, you know - which, like a lot of things at Yahoo, does not exactly work the same way as the Microsoft cloud alternative. As Blogster Par Excellance Mary Jo Foley points out, meshing these two platforms could be a real mess. Well put, Foley!

Microsoft Opens to Eclipse?

Microsoft is working to make it easier for Eclipse developers write code for Windows apps. Microsoft will provide engineering support to allow Eclipse Standard Widget Toolkit (SWT) to use Windows Presentation Foundation (WPF). Such support would make it easier to Java developers to write applications that look and feel like Windows Vista. San Ramji, director of the Open Source Software Lab explains in his blog-posting Supernova, “We’re committing to improve this technology with direct support from our engineering teams and the Open Source Software Lab, with the goal of a first-class authoring experience for Java developers.”

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?

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.

Using Master Pages in Visual Studio 2008

The way you use Master pages has changed in Visual Studio 2008.  Remember, how in Visual Studio 2005 when you add a new Web Form in ASP.NET applications - you get to choose a master page to apply to the Web form.  If you choose to use a Master page - then the page that is added, when you check the HTML code for that page - it is stripped of all the standard HTML tags - only the Page directive and the <asp:Content> tags are available.  This is a Content page.

In Visual Studio there are two types of Web Forms available - Web Form and the Web Content Form

The Web Form is a standard Web Form - without the Master page, with its HTML code like a standard HTML page.  Whereas, the Web Content Form is the one to which you can attach a Master page.

The Web Form page also has a MasterPageFile property.  But, if you create a Web Form and then set the MasterPageFile property to link to your Master page you will get a run time error.

Content controls have to be top-level controls in a content page or a nested master page that references a master page.

This is because content pages must not have another other HTML tags or controls. 

If you want to use Master Pages use Web Content Form, otherwise use the Web Form.

Another nice feature in Visual Studio 2008 - is that in that in the top right corner of the Design window of the Web content page is a link to the Master page that this page is linked to.  Also, the “Split” view is cool.. you can now see the source and the design view tiled in the design area.