Thursday, May 24, 2007

So what are generics anyway?

A lot Delphi developers 'demand' generics to be added to the Delphi language, or should I say Object Pascal. Question that pops up is, What are generics anyway?

Generics where introduced in .NET framework 2.0 in the C# language. Simply said they are collections(lists) which are type safe, i.o.w. you can detect type mismatches at compile time. With other structures (arrays etc) you must check the type in runtime and then type cast to the appropiate type. So generics will make your apps more robust in a way.

Lately I have used the C# language a lot so I learned the power of generics.
Let's take a look at it!

A generic list is declared like this:
System.Collections.Generic.List<MyItem> MyItems;

Between the brackets you specify the name of the class which will be hold by the list. The compiler expects objects of this type. If you add a different type you will get a compiler error.

An example:
Suppose you have a class MyItem which looks like this:

public class MyItem
{
string FName;
public MyItem()
{
}

public string Name
{
get
{
return FName;
}
set
{
FName = value;
}
}
}
You can now fill the collection(or should I say List?) FItems like this:

MyItem Item = new MyItem();
Item.Name = "First";
FItems.Add(Item);
MyItem Item = new MyItem();
Item.Name = "Second";
FItems.Add(Item);
We now have a list with two MyItem objects.

You can search within the list using the Find and Findall methods.
Suppose you want the second object you could find it like this:

MyItem SearchedItem = MyItems.Find(delegate(MyItem SItem)
{
return SItem.Name == "Second";
});
Through a anonymous delegate it returns the object which matches the criteria. The Findall method returns a list with objects, for example all objects where a specific attribute matches.
There is a lot more to explore, for more information look at the MSDN website.

Generics and Delphi
Generics are planned for the Delphi Highlander release, later this year (Roadmaps coming in june!). In september 2006 Nick Hodges showed at the EKon 10 / BorCon Europe conference a preview of the syntax. Bob Swart has published a few notes about it here.

Wednesday, May 09, 2007

Delphi for PHP Update 1 is out there

Delphi for PHP update 1 is out!

According to the CDN article fixes in this update are:

-Fix to the IDE to ensure correct storage of UTF-8 strings in the .xml.php
-Fix to VCL for PHP to parse .xml.php in UTF-8 mode
-Save Project As... fixed (QC 43580)
-Updated sourcecode documentation for the VCL
-Fixed problem with PHP 5.2.1. The Input Filter extension is out of beta and function for filter data was changed to a new name, so Input object now takes that into account (QC 43607)
Fixed problem with vcl-bin folder. The alias is set to be a root alias, making it easier to configure on deployment
-Added global var to specify if properties are html_decoded when read from the .xml.php
-Corrected support phone list .txt file

Go get it here.

Tuesday, May 08, 2007

A hyperdrive factory, or how to get a cat out of a tree

Steven Trefethen has very good blogpost about the endless stream of new technologies coming from Redmond.

He says:
Will there ever be some sort of stabilization period where apps can mature and the technology settles into a known state where developers are comfortable about the foundation from which their working?

It definitly is very difficult to keep up with all the new stuff, before knowing the 'old' stuff entirely.
(.NET 1.1 stuff is suddenly 'deprecated' in .NET 2.0, oh well move on...)

He asks:
What about you, how are you dealing with all of this? Or are you dealing with it?

Well not really. Although I keep an eye on the new technology and occasionaly play with it. But mostly, I think, it is better to watch the cat out of the tree. (That is a dutch saying "De kat uit de boom kijken") It basically means you can do a lot to get the cat out of the tree, but if you wait a little longer the cat may decide to come out of tree itself.

And you know what?
The more things change, the more they stay the same!'

Wednesday, May 02, 2007

It must be spring...

It must be spring, it looks like everyone (not an understatement here ;- ) ) is cleaning/pimping up their website.
CodeGear launched yesterday their new website, with their new logo. Content looks the same, but I think it looks great!

Also Delphifeeds.com changed the look of their website, providing more functionality like a new Delphi forum.

Great work guys!

Use an image as your UIBarButtonItem

Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...