56 posts categorized "Whidbey & Longhorn"

03/08/2005

Longhorn Milestone Dates

Bart De Smet has some Longhorn milestone dates.

Christian

Project Green Roadmap

Microsoft outlined the roadmap for Project Green:

Wave 1: 2005-2007

  • Common role-based shared user interface with Office integration
  • Interoperability with service-oriented applications
  • SQL Server Reporting Services as the default reporting environment
  • SharePoint Portal Server as intranet or extranet environment
  • The next version of Microsoft CRM is planned for Q4 2005
  • More information about Axapta, Great Plains, Navision...

Wave 2: starts 2008

  • The second wave will build on the innovations of the first wave and bring us a model-driven approach to business processes based on Visual Studio and WinFX.

Tim Brookins was quiet with his blog lately. His latest blog entry from Sep-2004 very good explains the roads of MBF.

Christian

03/06/2005

Generic Methods

Following my blog about Generic Delegates and Anonymous Methods, here is more:

Generics and anonymous methods can make code a lot more flexible.

Following I show different ways to accumulate the balance of Account objects. The Account class is a simple class that has a Balance property to access the balance of the class.

1. Summarizing the balance of Account objects in a collection can be done with the Accumulate method:

public static decimal Accumulate(IEnumerable e)
{
   decimal sum = 0;
   foreach (Account a in e)
   {
      sum += a.Balance;
   }
   return sum;
}

Invoking the method, the Account collection is passed:

decimal amount = Algorithm.Accumulate(accounts);

2. Making this method generic that it is possible to use other than Account objects, a generic method Accumulate can be implemented. However, because the Balance property is accessed for the accumulation, all generic TAccount classes must offer this property as is defined with the constraint IAccount.  

public static decimal Accumulate<TAccount>(IEnumerable<TAccount> coll)
   where TAccount : IAccount
{
   decimal sum = 0;
   foreach (TAccount obj in coll)
   {
      sum += obj.Balance;
   }
   return sum;
}

Invoking the method is not different to before:

decimal amount = Algorithm.Accumulate(accounts);

3. The second version has the requirement that all objects that are accumulated implement the Balance property. This can be more flexible by defining a generic delegate that defines the action.

Now the Accumulate mehtod can do anything to any object of a collection. What is done to the objects is defined with the delegate Action<>(). This Action delegate defines two parameters and a return type.

public delegate TSum Action<TObj, TSum>(TObj obj, TSum sum);

public static TSum Accumulate<TObj, TSum>(
  
IEnumerable<TObj> coll, Action<TObj, TSum> action)
{
   TSum sum = default(TSum);

   foreach (TObj obj in coll)
   {
      sum = action(obj, sum);
   }
   return sum;
}

To do the same as before - adding all balances - the implementation of the Action can be defined as anonymous method calling the Accumulate method.

decimal amount = Algorithm.Accumulate<Account, decimal>(
   accounts,
   delegate(Account a, decimal sum)
   {
      return a.Balance + sum;
   });

This is really flexible as it is not only possible to use Account objects, but any object. Instead of accumulating some values anything else can be done, too.

Of course anonymous methods should only be used with very simple implementations that are not needed somewhere else. Instead of anonymous methods a normal method can be used, too.

Christian

12/17/2004

Properties with C++/CLI

C++/CLI was influenced by C#, but it also has a shorter syntax for properties.

This is the C# syntax of properties:

private string lastname;
public string Lastname
{
   get
   {
      return lastname;
   }
   set
   {
      lastname = value;
   }
}

The new C++/CLI syntax was influenced by C#:

private:
   String^ lastname;
public:
   property String^ Lastname
   {
      String^ get()
      {
         return lastname;
      }
      void set(String^ value)
      {
         lastname = value;
      }
   }

C++/CLI has another syntax for properties where just the value is set and returned that doesn't need so much typing:

public:
   property String^ Firstname;

With the property keyword a property and a field is generated automatically. This style is very useful if there's no extra verification of the value with the set accessor, and the value returned is not calculated. Let's write smaller code :-)
The variable that's behind the property is generated automatically. There's no need to know the name of the generated variable because the compiler knows when to optimize the code to use the variable instead of the property.

Some time ago we had a discussion about properties and fields in C# - this issue can be solved with the C++/CLI syntax for properties.

Christian

11/21/2004

Generics, Code Sharing and Partial Specialization

Joel Pobar has an interesting blog about CLR Generics and code sharing:

X86 code is shared with reference types, with value types a "partial specialization" is used.

Christian

11/06/2004

New Naming Guidelines for Generic Types

Krysztof Cwalina blogged about new naming guidelines for generic types.

The BCL team considers remaning several of the BCL generic types. Some provisional examples:

EventHandler<TEventArgs>

Converter<TInput, TOutput>

Dictionary<TKey, TValue>

Votes are still counted. There's a long discussion on Ladybug.

My personal vote would be as it was defined with Beta 1 - EventHandler<T>, Dictionary<K, V>. But I guess this is because of my C++ background.

Christian

10/28/2004

IComparer and IComparable might change after Beta 1

Krzysztof Cwalina blogs about a proposal to refactor these new interfaces.

Currently the interface IComparable<T> defines the methods CompareTo and Equals. Because not always all methods are needed, the new version might be two interfaces: IEquateable<T> and IComparable<T>.

I prefer multiple interfaces instead of imlementing methods that are not needed!

Krysztof is looking for feedback.

There are also some discussions at LadyBug:

Christian

10/27/2004

ASP.NET 2.0: Postback to other pages

With ASP.NET 2.0 it is easy to do a postback to a different page. The Button control has a new property PostBackUrl. This property can be set to a different Web page.

Within the new page the values from the previous page can be accessed with the new Page property PreviousPage.

A nice new feature!

Christian

10/16/2004

Edit & Continue with C#

Visual Studio 2005 will have support for Edit & Continue with C#!

See S. Somasegar's announcment: C# Edit and Continue support for Visual Studio 2005

The new community technology preview will be available next week.

Christian

09/29/2004

SOAPFormatter

Last month I've missed a important blog from Matt Tavis: he blogs about deprecating the SoapFormatter for .NET 2.0. This is a good idea! The SoapFormatter is misleading to offer platform independence with .NET Remoting.

With .NET Remoting the BinaryFormatter is a better (and faster) option. New .NET 2.0 features like version tolerant serialization and generics are not supported with the SoapFormatter anyway.

Christian