.NET Developments


November 21, 2008  6:00 AM

News roundup: Microsoft will not buy Yahoo!, MLB won’t use Silverlight

Yuval Shavit Profile: YuvalShavit

Here’s the Microsoft news we’ve been seeing around the Web….

Steve Ballmer emphasized on Wednesday that talks of Microsoft buying Yahoo! are “finished” after speculation started bubbling up again following Yang’s resignation from Yahoo!. But the software giant also lured an executive away from the struggling search company. Meanwhile, Microsoft may sell bonds for the first time ever.

Silverlight suffered a blow on Monday when MLB said it would move back to Flash, according to Adobe. That could be especially damaging, since Microsoft’s case for the rich internet application (RIA) framework relies heavily on its video capabilities and adoption by major players like NBC.

Continued »

October 27, 2008  12:53 PM

Microsoft PDC: First keynote focuses on Microsoft’s Cloud OS, Windows Azure

Yuval Shavit Profile: YuvalShavit

LOS ANGELES — In unveiling its Web-based development platform today at PDC, Microsoft has fired a salvo at Amazon EC2, the company’s hosted development platform.  Microsoft’s version of the cloud computing platform, dubbed Windows Azure, is essentially a hosted version of its server-side .NET platform. Developers can write ASP.NET code, complete with hookups to a hosted version of SQLServer, and run it on virtual machines hosted by Microsoft.

Windows Azure is meant to be another tier of computing, addressing Web development in the same respect that Vista and Windows Server address client-side and server-side development, said Ray Ozzie, the company’s chief software architect.

For now, Windows Azure is in very early beta. Its functionalities are fairly limited, and the company has not rolled it out to the public at large yet; for now, only developers at PDC will get activation codes. Ozzie warned that when the service reaches a commercial release — at a yet-unnamed time — it will likely be very different, and possibly incompatible, with  the current version.

Developers looking for client-side news were out of luck today; the whole keynote focused on Azure, with plenty of demos to show what the cloud OS can do so far (though not a whole lot on how that’s different from what standard client-server apps already do). Tomorrow’s keynote will focus on client-side Windows development; check here for more updates.


September 26, 2008  2:50 PM

The LINQ Equation

Brein Matturro Profile: Brein Matturro

Language Integrated Query (LINQ) is a new object querying paradigm that released with Microsoft’s .Net Framework version 3.5.  It allows a programmer to write SQL-style code to access objects within lists or collections or arrays.  It is quite powerful but what about performance?  I will attempt to show an un-biased comparison of a few object list querying techniques and together we’ll look at the results and perhaps even learn something.

The collections I’m working with are dogs, owners, and vets.  Each dog has an owner and a vet.  Each collection is implemented as a generic list (List<dog>, List<owner>, and List<vet>).  I have a single routine that loads up each collection and associates dogs with owners and vets.  One of the attributes of a dog is the brand of food the dog likes.  We’re going to look at a simple count “Query” against the collection of dogs where the food brand is “Purina”.

The legacy way of counting items in a collection is the basic foreach loop where we loop through the collection looking for a particular attribute value and then increment a counter based on the check such as:
foreach (DLDog Dog in Dogs)
{
  if (Dog.FoodBrand == "Purina")
  {
  count++;
  }
}

In this case we could return the value of count thereby returning the answer.

In .NET 2.0 we discovered the concept of the generic delegate and the action and predicate delegate types.  This enables us to simplify our query for food brand as follows:
  MyActionCount = 0;
  Dogs.ForEach(MyAction);
  return MyActionCount;
.......
  private void MyAction(DLDog Dog)
  {
  if (Dog.FoodBrand == "Purina")
  {
  MyActionCount++;
  }
  }

In this example we create a function called MyAction that statisfies the Action action generic delegate and now we can provide many different implementations of our count process.  There is an assumption that we have defined MyActionCount elsewhere in the source.  We can actually simplify this even further by putting the delegate inline as follows:
  int Count = 0;
  Dogs.ForEach(
  delegate(DLDog Dog)
  {
  if (Dog.FoodBrand == "Purina") { Count++; }
  });
  return Count;

In this case, we don’t need the dependent variable MyActionCount and the function is self-sufficient.  Now some would argue that this is much less readable but I would say it is less well known.  Once the delegate syntax is understood and comfortable, this syntax is easily understood.

So what about LINQ?  Here is the same “query” expressed as a LINQ to objects query:
  var query = from dog in Dogs select dog;
  return query.Count(n => n.FoodBrand == "Purina");

This code is very readable but the syntax is extremely foreign.  Under the covers, this is represented very similarly to the inline delegate method of performing the query but it is done so using much easier to read syntax.  If we look at the IL Code generated for each of these looping structures we will notice very similar constructs being used at the lower level.  That is not to say that LINQ is just syntactical sugar – it is a compiler change that allows it but it builds on the generics and anonymous methods given to us in .NET 2.0.


September 26, 2008  2:49 PM

Silverlight 2 UI communicates through WCF

Yuval Shavit Profile: YuvalShavit

John Papa shows onstrate how to build a Silverlight 2 UI that communicates through WCF to interact with business entities and a database.

According to John, in his article on MSDN Magazine Web, the business logic, entity model, and data-mapping code can be consumed by any presentation tier. 

He’s created the WCF services to be consumed by a Silverlight 2 app, set up the server hosting the WCF services to allow cross-domain invocation, and more. 

Silverlight 2 UI communicates through Silverlight – MSDN Magazine Web


September 10, 2008  2:04 PM

Microsoft joins OMG – Muglia sees mainstream modeling

Yuval Shavit Profile: YuvalShavit

Microsoft Corp. said it will join the Object Management Group, the steward of UML and promoter of Model-Driven Architecture and other enterprise standards. Microsoft’ Bob Muglia made the disclosure as he described Microsoft’s plans to take modeling into mainstream industry use. Continued »


September 2, 2008  5:14 PM

Iterators, Lambda, and LINQ… Oh My!

Brein Matturro Profile: Brein Matturro

Since the creation of the .Net Framework, Microsoft has kept the concept of “Type Safe” at the forefront of their design goals.  When 1.1 shipped, the framework had a “generic” collection type called an ArrayList that seemed to break this goal.  Microsoft quickly went above and beyond with the 2.0 framework by adding Generics and Anonymous Methods to the mix.  Anonymous methods coupled with Generics paved the way to Lambda expressions, Extension methods,  and LINQ (Language INtegrated Query).  The topic of this paper is loosely defined as:  The path to understanding Lambda and LINQ.

What came first?

Iterating through a collection with a for-each construct has been around for a long time.  .Net has the capability and in the beginning it was the recommended way of looping through a collections of widgets to find something or count something.  The basic construct is:

        private int CountForEach()
        {
            int count = 0;
            foreach (DLDog Dog in Dogs)
            {
                if (Dog.FoodBrand == "Purina" )
                {
                    count++;
                }
            }
            return count;
        }

Nothing too earth shattering about this.  Assuming we have a collection of 10 dogs and 3 of them use “Purina”, we will return a count of 3.

How would Generics and Anonymous methods change this syntax?  In the .Net 2.0 framework we can simplify the previous code a little as follows:

        private int CountGenericDelegate()
        {
            MyActionCount = 0;
            Dogs.ForEach(MyAction);
            return MyActionCount;
        }

This is a little misleading because we still need to write the delegate method “MyAction” but it does give us some flexibility in that we can pass any method to the ForEach generic method that adheres to the Action<T> prototype which is a predefined delegate in .Net 2.0.  Here is what the MyAction needs to look like in this example:

        private void MyAction(DLDog Dog)
        {
            if (Dog.FoodBrand == "Purina" )
            {
                MyActionCount++;
            }
        }

Another predefined delegate is the Predicate<T> delegate.  This one returns a Boolean based on some condition.  The <T> is typically your List<T> type.  Here is an example that uses the Predicate<T>:

        private List<DLDog> QueryDelegate()
        {
            return Dogs.FindAll(ByTypeAndCost);
        }
        // Predicate<T> typed method for FindAll
        bool ByTypeAndCost(DLDog Dog)
        {
            if (Dog.DogType == "German Sheperd" && Dog.AnnualVet > 1500M)
                return true;
            else
                return false;
        }

Enter .NET 3.5 – SWEEEET!

In .NET 3.5 Microsoft pulled all punches and really exploited the power of delegates, generics, and anonymous methods.  Building on that technology they added extension methods, lambda, and LINQ to the system.  Now our first count example can be simplified as:

        private int CountLambda()
        {
            MyActionCount = 0;
            return Dogs.Count(n => n.FoodBrand == "Purina" );
        }

This syntax is foreign as you can see but after a short explanation it will become very natural.  The “=>” operator is loosely defined as “Goes To”.  Under the covers – the compiler is doing this:

        private int CountLambda()
        {
            this.MyActionCount = 0;
            return this.Dogs.Count<DLDog>(delegate(DLDog n)
            {
                return (n.FoodBrand == "Purina" );
            });
        }

Previous code sample courtesy of “Reflector“…

Lambda is nothing more than syntactic sugar for inline anonymous methods and the .Count method on a generic list is nothing more than an extension method provided by the .Net 3.5 framework to the .Net 2.0′s generic list class.  No smoke and mirrors here!

Now LINQ is another animal but simply exploits everything up to this point and the previous example looks like:

        private int CountLinq()
        {
            var query = from dog in Dogs select dog;
            return query.Count(n => n.FoodBrand == "Purina" );
        }

The query variable is of type IEnumerable<T> and the T in this case is a DLDog object.  The compiler ends up with the following:

        private int CountLinq()
        {
            return this.Dogs.Select<DLDog, DLDog>(
                delegate(DLDog dog)
                {
                    return dog;
                }).Count<DLDog>(
                delegate(DLDog n)
                {
                    return (n.FoodBrand == "Purina" );
                }
                );
        }

Notice the use of the .Select extension method.  The method is defined as:

      public static IEnumerable<TResult> Select<TSource, TResult>(
            this IEnumerable<TSource> source,
            Func<TSource, TResult> selector)

(In the Visual Studio help system… )

So in summary – LINQ is really syntactic sugar for the extension methods provided by the .NET 3.5 framework!  Simple! 
…and SWEEEET!

Send me an email if you want a copy of the source code used for this article.


August 13, 2008  1:56 PM

SP1 for .NET Framework 3.5 and VS 2008 boasts faster install, reduced coding

Yuval Shavit Profile: YuvalShavit

By Andrew Horne

The first service pack upgrades for .NET Framework 3.5 and Visual Studio 2008 feature faster application runtimes and a general upgrade to existing tools. The main new inclusion is a .NET Framework Client Profile, which allows for faster installations on client machines.

The .NET Framework service pack focuses primarily on speed, thanks to a sleeker download. This approach benefits both developers and end-users with faster installation times and runtimes. Among the new features are support for ASP.NET Dynamic Data and support for SQL Server 2008, opening up a new range of options for website development. Other aspects of the service pack include ADO.NET Data Services and ADO.NET Entity Framework, intended to allow greater database abstraction.

The Visual Studio service pack features upgrades to existing tools as well as the ability to work in SQL Server 2008. Upgrades are aimed at a less involved building process for both WPF and Ajax applications, while retooled features enliven both ADO.NET Entity Framework and JavaScript development.

Check out George Lawton’s article on the service pack upgrade for more information, plus commentary on the strengths of Entity Framework as opposed to those of NHibernate and other frameworks.


August 13, 2008  1:49 PM

Getting down with WCF security

Yuval Shavit Profile: YuvalShavit

By Andrew Horne

Authentication and authorization are key areas of focus in the “Improving Web Services Security” guide published by Microsoft’s Patterns and Practices Team. The guide leads you through SOA security, WCF security, and useful application scenarios for both internet and intranet.

The twin security approach of authentication and authorization assures that only trusted users use your applications. This guide runs through the decisions you have to make in setting up these security devices, such as which authorization approach to use: role-based, identity-based or resource-based. This leads to questions about user stores and transfer security, among many others. The answers you give to these questions also have an effect on authentication: for instance, do you go with username or certificate authentication? The chapter “Solutions at a Glance” gives you a neat five-step outline to keep your thoughts organized.

Patterns and Practices pooled knowledge resources with Microsoft’s WCF team and outside leaders in the field, while also comparing this knowledge with user responses. The guide reflects the increasingly important role security plays for designers in today’s technological environment. As Nicholas Allen, Program manager of WCF, writes in his forward to the book, “Security has to be treated as part and parcel of functionality.”

Download the guide here, and also check out SearchWinDevelopment’s WCF Learning Guide.


July 30, 2008  2:10 PM

Ballmer calls for push on Windows application development

Yuval Shavit Profile: YuvalShavit

By Andrew Horne
In a leaked internal e-mail following the unexpected departure of executive Kevin Johnson, Microsoft CEO Steve Ballmer outlined company objectives for the year ahead: growth of Windows, the development of software plus services, and an improved user experience.

Work on both software and software plus services is on the docket for 2009. Ballmer announced a campaign to promote Vista, now that several problems in the system appear to have been ironed out. He also mentioned the disturbed computing ‘Cloud’ architecture as a major area of interest going forward. Look for more details to coincide with October’s Professional Developers Conference.

Despite the great emphasis on new rich client interfaces like Silverlight, Ballmer promised to “redefine the meaning and value” of established Windows clients. He urged more WPF-style development. Microsoft alone will not secure the growth it hopes for in the operating system, he said. “We also have to drive developers to create rich applications for Windows.”


July 17, 2008  1:14 PM

ASP.NET Ajax Roundtable

Yuval Shavit Profile: YuvalShavit

The Ajax interface has proved an interesting animal. Many people trace asynchronous JavaScript use back to Microsoft’s early Outlook Web clients, but it was not promoted by Microsoft much until open-source AJAX [for Asynchronous JavaScript and XML] as used by Google became popular about three years ago. Then, Microsoft embraced it wholeheartedly, creating its own ASP.NET Ajax version of AJAX, and saving some trouble for its developer legions. Yet, third parties still have a role to play in moving ASP.NET Ajax forward, as SearchWinDevelopment.com’s Vendor roundtable series can attest.

ASP.NET Ajax Roundtable Part 1 – Browser Compatibility

ASP.NET Ajax Roundtable Part 2 – Resurgence in JavaScript

ASP.NET Ajax Roundtable Part 3 – Open Source


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: