Bart De Smet has some Longhorn milestone dates.
Christian
Bart De Smet has some Longhorn milestone dates.
Christian
Posted at 07:26 PM in Foundation, Technology, Whidbey & Longhorn | Permalink | Comments (2) | TrackBack (0)
Microsoft outlined the roadmap for Project Green:
Wave 1: 2005-2007
Wave 2: starts 2008
Tim Brookins was quiet with his blog lately. His latest blog entry from Sep-2004 very good explains the roads of MBF.
Christian
Posted at 03:40 PM in Foundation, Technology, Whidbey & Longhorn | Permalink | Comments (1) | TrackBack (0)
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
Posted at 04:16 PM in Code Snippets, Language, Technology, Whidbey & Longhorn | Permalink | Comments (14) | TrackBack (0)
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
Posted at 03:52 PM in Language, Technology, Whidbey & Longhorn | Permalink | Comments (1) | TrackBack (0)
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
Posted at 08:21 PM in Language, Technology, Whidbey & Longhorn | Permalink | Comments (0) | TrackBack (0)
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
Posted at 08:58 AM in Foundation, Technology, Whidbey & Longhorn | Permalink | Comments (1) | TrackBack (0)
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
Posted at 09:00 PM in Foundation, Technology, Whidbey & Longhorn | Permalink | Comments (1) | TrackBack (0)
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
Posted at 10:20 PM in ASP.NET, Technology, Whidbey & Longhorn | Permalink | Comments (2) | TrackBack (0)
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
Posted at 12:47 PM in Whidbey & Longhorn | Permalink | Comments (2) | TrackBack (0)
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
Posted at 05:26 PM in Communication, Technology, Whidbey & Longhorn | Permalink | Comments (1) | TrackBack (0)