Friday, June 09, 2006

Delphi roadmap update

Borland's Developer Tools Group has published updated roadmaps for JBuilder and Delphi/C++.

Upcoming Delphi versions according the roadmap:

Delphi Highlander
Release: Early 2007
  • -Support for .NET 2.0
  • -Additional refactorings and unit testing
  • -Delphi .NET support for generic types, partial classes, and nullable types
  • -VCL for .NET 2.0
  • -ECO for .NET 2.0
  • -Seamless project conversion to .NET 2.0.
  • -IDE design surfaces for .NET Compact Frameworks (using VCL.NET on CF)
  • -64 bit .NET apps written using WinForms and VCL.NET
  • -64 bit code generation will be added to the Delphi native code compliers to support native 64 bit development and debugging. (See update belowe)
  • -IDE and VCL runtimes to support Unicode.

Delphi Longhorn
Release: 2008

  • -VCL for Avalon
  • -Indigo

The image of the roadmap shows a Delphi Vista (mid 2007) and a Delphi for Win64 (2008) which are not mentioned in the article itself. Delphi for Win64 however is mentioned in the release of Highlander so the roadmap image seems not to be in sync with the article?

11-06-2006 Update:
About 64 bit code generation which was stated in the article like this:

"In addition, 64 bit code generation will be added to the Delphi native code compliers to support native 64 bit development and debugging"

You could conclude that this would be in Delphi Highlander early 2007. But as I said this conflicts with the image.
John Kaster has updated the article, where it now says:

64 bit code generation will be added to the Delphi native code compilers to support native 64 bit development and debugging after the initial Highlander release.

IMO this means that it will not be in the initial release of Highlander, but it will be added shortly after the release. It also means that the image is still out of date!

Wednesday, June 07, 2006

Putting the act to the word

Just before the creation of DevCo I feel it is time to boost Delphi once again. Because, you know what, it still is the best development tool out there for Win32 and .NET development. (And a lot more...)
Although the blogging community is fresh and kicking, a lot of, long time existing, Delphi sites looks to me unattended and out of date. (Not all of course)
Just like a dutch Delphi portal site, delphi.startkabel.nl that I found recently. This site had a thick layer of dust on top of it with broken links and links directing to non Delphi sites or out-of-date data. In my opinion sites like this are very important for the succes of Delphi.

So putting the act to the word (a translated dutch saying I am not sure if this make sense in Englisch) I decided to become the webmaster of this portal. I have done a bit of cleaning like removing the broken links and putting in some new sections like Weblogs, ECO and AJAX. Right now I am still gathering new links and sections.
If you have any link/section suggestion please let me know here and I will add it to the portal.

Tuesday, May 23, 2006

Code smells

Great article on coding rules on Coding horror blog.
Bottom line: Keep refactoring your code.

"Working clean means constant refactoring"

Sunday, May 21, 2006

Saving TWebbrowser content with IPersistFile

With TWebbrowser it is easy to navigate URL's and files on your local disk using the Navigate method.
As discussed in this blogpost TWebbrowser implements a IHTMLDocument2 interface object which can be used to edit the document in WYSIWYG way.

Saving the changes can be done in a few different ways, I will discuss a few here below:

1. Using the innerHTML property
You could retreive the raw HTML from the browser through the WebBrowser.OleObject.Document.documentElement.innerHTML property and then save it to disk.
If you want only the text from the document, and not the HTML, you could use the WebBrowser.OleObject.Document.documentElement.innerText method.
Saving to disk could be easily done using a TStringList object.

2. Through the IPersistFile interface
Although the above method works, there is a much more elegant way to achieve this.
IHTMLDocument implements an interface called IPersistFile which is an common interface for loading and saving objects.
Save the current loaded webpage using the IPersistFiles as follows:

(WebBrowser.Document as IPersistFile).Save('c:\inetpub\wwwroot\MyWebsite\index.html', True);

Besides Save, IPersistFile offers a method for loading files (Load) and a method to find out if the current loaded page is changed compared to when it was last saved. (IsDirty)

For more information on IPersistFile visit the msdn website here.
According this page IPersistFile is new in the .NET Framework 2.0.

Wednesday, April 12, 2006

Devco's former employee shortlist

Allen Bauer talks about the returning of former Borland employee Steve Shaughnessy in his blogpost Gaining momentum...
The return of a former employee itself is not really news to me, those things happens daily in the real world. The intresting news in this blogpost is when Allen talks about a "short list", he says:

After the announcement that Borland was going to spin-off the IDE and database groups into a separate company, we started talking with several former Borland employees that had left to pursue other opportunities. Steve Shaughnessy quickly made it onto our “short list.”

In other words there is a shortlist out there, with former Borland employees on it which are in contact with the Devco's about other opportunities.

That is very good news, IMO!

Now I wonder who would be on that shortlist?
So this blogpost might have some serious points after all. ;-)

Any way encouraging stuff.

Sunday, April 02, 2006

ECO missing gallery items fix

BDS2006 Enterprise edition is missing some gallery items (New - Other) regarding to ECO applications. It misses for example the ''ECO ASP.NET Web Application".

A fix (By Jesper Hogstrom) can be downloaded here.

I just thought I let you know this because it took me a while to find it and there is know easy workaround, except by starting a normal ASP.NET application and adding the 'standard'ECO stuff manually.

Sunday, March 26, 2006

Programming the Pocket PC the easy way

While we are waiting for Delphi to support CF development officially, I found a year ago a very easy to use Form Designer application for 'programming' applications for Pocket PC's.
GrandaSoft's XSDesigner was at that time able to produce data collection forms (as they call it) in a very easy straight forwarded way which reminded me to the first 'Wows' after seeing Delphi 1 and it's way to deal with databases. :-)
XSDesigner let's you design database forms which save their data in a Pocket Access database (CDB format) . On the PDA you must install, a sort of runtime, XSForms which you can use to load your forms. One thing that was missing at that time was that you could not program button clicks and events.

Their new release (codename Matador), which is at this moment a public beta, supports now scripting languages to program logic in your applications. They support (for now) VBScript and JScript as languages and an event model. The way it is implemented is amazingly simple, but oh so effective.
Just design your form, script your logic, run it with one click on your Pocket PC, and it all works like magic!. The database is generated automaticly and data can be exported to several formats like XML and HTML.

Conclusion:
Although, it is limited to database forms, and it is limited, in its way, to work with complex datastructures, I find it extremely powerfull and recommend every one intresting in PDA development to give it try. According to their website there will be a free personal version and a professional edition with more features.

Friday, March 17, 2006

Update Delphi Roadmap

According to Daniel Wischnewski blogpost the Delphi roadmap has been updated. (14-03)
You can find it here.

Obvious changes to the previous roadmap are:
  • Release date of Highlander seems to be pushed to the end of 2006/early 2007 instead of mid 2006
  • ECO IV for VCL.NET suported by Highlander
  • Windows Vista seems to be supported by Highlander.

Wednesday, March 08, 2006

BDP, be carefull out there!

When you need database connection in a ASP.NET website you will use, of course, Borland DataProvider, because it gives you a database independent connection.
Use of the BDP components is very straight forwarded, and very much alike the 'standard' ADO.NET components.

However some things of BDP are a bit different, in the detail sence of the word, that it can make you pull your hair from your head sometimes. BDP also covers a lot that is not in ADO.NET so there is plenty to learn also.

Today such an event occured to me (again). A database-driven website that I'm building uses an Microsoft Access database to hold the content(Yes I know, not the best choice) . I use BDP to get the content from the database and on a local machine a Delphi Win32 app is used to maintain the content. So if the content changes the database must be uploaded to the website.
I noticed during developing that the Access .lck file (LockFile) stayed open, and that of course could be a connection which was not closed properly.
But I learned from the Delphi 8 times to close everything you use to get data from the database.
My way of doing this is somewhat like this:


MyConnection := BdpConnection.Create;
MyCommand := BdpCommand.Create(AQuery);
MyCommand.Connection := MyConnection;
try
MyConnection.Open;
MyDataReader := MyCommand.ExecuteDataReader;
while MyDataReader.Read do begin
Response.Write(MyDataReader.Item[0].ToString);
end;
finally
MyDataReader.Close;
MyCommand.Close;
MyConnection.Close;
end;

So believe me I don't leave database connections open lately. Anyway the lock file did not give trouble during the developement.
But now that the website has gone live my Win32 app is not able to upload a changed database because it is used by another process. And that of course is the ASP Worker process, which I can not kill at the ISP's webserver. (Oh Oh)

So after checking all my connections to close(as I told you before I do close them) I found out that it had to do with the Connection Pooling. Of course, that is default set to true and it keeps the connection 'open'. So I turned of the Connection Pooling and everything went fine even the .lck file disappeared immediately after the first refresh.
Now I only need to find a way to free the connection just-before uploading the database. I think that can easily be done following this tutorial at BDN.

So here is my small(and growing?) list of BDP tips:
  1. When using Memo fields don't forget that BDP returns by default 1024 characters as set in the property BlobSize of the connection. So if you have more you won't see it until you increase the blobsize.
  2. Don't get yourself fooled by the Connection Pooling! Connection pooling makes it look like you did not close your connection properly.
  3. Close all that can be closed and you will be fine.

More info on BDP can be found in this BDN article Borland Data Provider 2.5 features.

Bottom line Borland DataProvider rocks, but be carefull out there...

Monday, March 06, 2006

More on "DevCo"

Allan Bauer has some intresting blogposts in his xx Days After spinn off announcement series:

These post have a 'fly on the wall approach' giving some insites in what is going in the Borland meeting rooms. Although it keeps us from real facts it is good to see how everything is going down there.
So far, as far as a fly can tell, it still looks very good for the future of Delphi.

David I offers some additional perspectives on the spinn-off.

After reading all this stuff I (still) feel pretty confident that Delphi will come out as a stronger product than ever before.

Wednesday, March 01, 2006

BDS2006 evaluate and a four wheel drive

I am using BDS2006 for two months now. Time to evaluate.
I use BDS2006 Enterprise, mostly for Win32 developement and ASP.NET Development. (Delphi .NET and some C#)

BDS2006 in a nutshell:

  1. BDS2006 is awesome
  2. BDS2006 has some minor bugs or quirks (no showstoppers here!)
  3. Delphi 7 and Delphi 8 made it on the 'Uninstall list'
  4. The future of BDS2006 is...or get myself a fourwheel drive.

1. BDS2006 is awesome
In fact after two months using it, I can not think of going back to Delphi 7. The new editor features are really accelarating my production.

To name a few IDE highlights:

  • Live Templates; Great productivity accelarator!
  • Refactoring; Even more productive. (Still have not used all the refactorings)
  • Together integration; The two way source/UML diagramming gives good insight of my code. Automatic generating documentation is sweet.
  • The IDE is fast (PIV 2,4 GHz 512 Mb); Start uptime is OK! Working is OK!
  • The IDE is stable. (Must confess I manage to crash it sometimes, although a lot fewer then Delphi 7).
  • ASP.NET designer is perfect (Awesome with a capital A compared with the Delphi 8 version that I used. No more HTML disappearing.)
  • ECO, although I am still exploring the thing, it seems to be the way to build .NET applications in the future. (No more plumbing around with ADO.NET, can you imagine that?) Now if I only had the time to explore it even more. There should be a book for this...
  • Having Win32 and .NET application in one project group is cool and even better extremely usefull, no more switching between applications.

2. BDS2006 has some minor bugs and quirks
Before this post is looking like an advertisement for the new DevCo, let's look at some minor bugs, quirks and strange behaviors that I encountered. But beware nothing here is a showstopper.
IMO It is quite natural that a product as complex as BDS2006 has some quirks.

Disclaimer:
If I say bug I mean that I think it is a bug, so it could be my mistake after all. Still investigating some 'bugs' to put them in QA.
If I say annoying, I mean that it is annoying to me, so not necesserally to you also

  • Annoying: The projectmanager does not open your dfm file if you don't open the pas file first.
  • Annoying: The help is minimal. The help really needs attention.
  • Bug: Sometimes I manage to crash the thing. (When I say 'sometimes' I mean once/twice a day, but not every day) mostly when debugging. (Hard to locate although)
  • Annoying: It is hard to stop coding.
  • Annoying: Can not get the ASP.NET deployment option to work. Grrrr must be me I guess.
  • Annoying/bug: After a day working in a ASP.NET application the amount of memory has grown. (After killing the ASP.NET worker process it comes down)

These are the things that annoy's me the most. OK sometimes there is another this and another that but in general BDS2006 rocks.

3. Delphi 7 and Delphi 8 made it on the 'Uninstall list'
No need to keep Delphi 7 and 8 for downgrade anymore. Put them on the 'Uninstall list' period!

4. The future of BDS2006 is...
And then there was the announcement that Borland is spinning of the IDE business.
First thoughts after the shock:

  • WTF are they doing now????
  • There we go again...
  • Men I just bought me a Enterprise Edition for the first time in my life....

Now after a couple of weeks I think spinning of the IDE business is the best thing to happen to Delphi in ~11 years.

What if the deal succeeds with Borland's intention to get a buyer in the best intrest of Delphi?
If that happens Delphi's future will be brighter than ever before!

What if the deal fails and someone kills Delphi?
I could use Delphi for many years to come, or change to another tool (although I can not think of another one right now, but someone will jump in the gap)
Or I just good start my gardening company with a big, I mean really big 4-wheel drive!

But for now go Delphi!



Wednesday, February 22, 2006

Posting data with TWebbrower

With a TWebbrowser component it is possible to post data to a webpage. Suppose you have an application with a webbrowser and your application requires a login, and the website also uses a login. The user should now login twice. And that is just to much!

You can however post data to the website with the Navigate method of the webbrowser component.
The declaration of the method is as follows:

procedure Navigate(const URL: WideString; var Flags: OleVariant;
var TargetFrameName: OleVariant;
var PostData: OleVariant); overload;

The last parameter PostData can be used to transfer the login information to the webpage, as if the user pressed the login button of the login form.

procedure LoginWithPostData(AUserName:String;
APassWord:String; LoginUrl:String; AWebBrowser:TWebBrowser);
var
varPostData, varHeader : OleVariant ;
x : variant;
postdata : string;
arPostdata : array of byte;
i,l: integer;
bch : byte;

begin
postdata := 'UserCode='+AUserName+'&PassWord='+APassWord;
SetLength(arPostdata, Length(PostData));
for i := 1 to Length(postdata) do begin
arPostdata[i-1] := Ord(postdata[i]);
end;
varPostData := arPostdata;
varHeader :=
'Content-Type: application/x-www-form-urlencoded\r\n';
AWebBrowser.Navigate(LoginUrl,EmptyParam,EmptyParam,
varPostdata, varHeader);
end;


Step 1: Create a string with the postdata
Step 2: Fill an array of byte with the string characters.
Step 3: Assign the array to an OleVariant.
Step 4: Set the appropriate encoding to a OleVariant (varHeader)
Step 5: Navigate the browser.

You should be logged in now!

You could of course also do it the other way around, log in the webbrowser and read the postdata from the BeforeNavigate event. (Just posted by your user and on its way to the webserver)
The disadvantage with this method is that you should parse the postdata string to get the username and you should somehow find out if the user was autorised by the webpage. One way to achieve it is to check the url in the NavigateComplete event of the browser to be the protected url (Page). If the protected page is loaded the user should be logged in and you can then login your application.
The first method, posting the data to the webserver from your application is however the best one.

Friday, February 17, 2006

Wednesday, February 08, 2006

Borland Announces Plan to Divest IDE Product Lines

Read the press release here.

In summary I read it like this:
Borland is seeking a buyer to create a separate company where all the IDE stuff related products will be placed. (Delphi, C#, C++ etc) This company will stay strong related to Borland who will focus on ALM and SDO.

David I has posted an open letter to the non-technical newsgroup, read it here.
There is also a blogpost here.

As far as I can see this could be a good thing for Delphi (BDS2006) although it is also quite shocking to begin with.
I only think that the name Borland should be for the IDE company, let the ALM company come up with a new name. Borland and Development Tools is said in one breath.

Tuesday, February 07, 2006

BDS2006, BDP and memo fields

Lately I encountered some strange problems using the Borland Data Provider (BDP) in a ASP.NET project. At first I thought I had solved it, but eventually (mostly because of project scope changes) it made me change from BDP to OleDB.

The project is a database-driven website for which I use BDP to connect to the database.

Why Borland DataProvider?

Borland DataProvider has some benefits compared to the standard .NET providers (SQL/OleDB):

  • BDP is database independent (Same components for SQL and local databases)
  • Connection pooling
  • Easy data remoting components

The database is used to provide the content of the website. At first I used a SQL Server database and found out that having two text fields (memo fields) in the SELECT clause causes the text fields to be truncated to 1024 chars. This is inconvient!
[update: Problem solved, see below]

Having only one text field in the SELECT works just fine! That is strange, isn't it? [No]

In SQL Server however I could of course change one of the Text fields to a varchar with a (max) length of 4000. Not the most elegant way, I know, but it is a rather small database only holding the website content. Problem solved.
Now, for other reasons, my customer wants to use an Access database instead. No problem! As said BDP components are database vendor independent!
Except, of course, that varchar fields in Access are limited to 255 chars, so I ended up with two truncated memo fields. :-(

The only solution left was to change from BDP to OleDB. This switch was easy because the BDP components are similar to the standard .NET providers.
My project now contains two database technologies, BDP and OleDB. All works fine but I can not call it elegant. (I keep the BDP, because there might be a switch back to SQL Server in the future.)

I only can imagine that this is a bug in the Borland Data Provider so I added a report to quality central. You can find it under QC number #24314

Update 8-2-2006:
Well I imagined it wrong. It seemed to be a property of the BdpConnection called BlobSize, which is default set to 1024! Well QC report withdrawn!
Wow this one was really hard to find! :-)

Wednesday, February 01, 2006

Old papers, still up-to-date

In the 'old' days I have made a few tutorials about Delphi(4/5) for The Software Developer Pages. These tutorials and papers are still available behind my company's website. They are available in english and dutch, and not updated for ages, but some papers are still up-to-date today. The most papers are at beginner-level because, guess what, I was those days a beginner.
There is even Delphi 5 code available for download which should be working easily in BDS2006.

The main page can be found here. (Note I do not update this anymore, so it looks a bit odd now)
Some still up-to-date papers are:

I keep a permanent link to this papers on this blog.

Friday, January 27, 2006

BDS2006 small features, great impact

It is always amazing how small things can have such a great impact on your daily work. The new features in the BDS2006 editor like live templates are obviouos because you can see it immediately while working in the editor. 'Small' improvements and features are discovered along the path.

Lately I noticed a tiny red bug (in dutch we call it a lieveheersbeestje) on a tab in the editor after debugging an application.

It seems that BDS2006 opens units, necessary for debugging, on the fly and implicit closes them when the debug session ends. (This is an editor option) If you stop debugging in such a unit Delphi keeps that unit open. Ain't that great?

I remember debugging a C# project in Visual Studio 2003 where I ended up with an endless list of tabs which is very annoying in my opinion. In VS you have the tabs for design and code besides each other on top of the editor. BDS2006 (and previous versions) have an extra tab at the bottom of the editor for switching between design and code. So in BDS2006 you always have the half amount of tabs in the top tab control compared with VS2003.

So these small features in BDS2006 are great! It gets even better if you popup the context menu on the tab. If you don't want BDS2006 to close the debugged units implicit(an editor option) you can close them by yourself using 'Close all pages opened while debugging' option. Hack you can even close all pages except the one that is active.

Small things, great stuff!

Tuesday, January 17, 2006

ECO Adventures: Inheritance

Inheritance is one of the five pilars of Object Oriented Programming. In ECO inheritance is, I can tell you now, a piece of cake.
Consider this 'real world' model:


Developer and SalesMan inherit the behavior from Person. Developer and SalesMan are specializations of Person. Implementing this model in a VCL Win32 application using TDataSet would consider a lot of work. For instance the, in fact one-on-one relation must be maintained in the database. A person is either a Developer or a SalesMan, a person can not be both. (if you don't agree you should read this blogpost :-) )
Anyway implementing this becomes, even in Delphi with TDataSet, more complex. In ECO it is a very straight forward process.

Create the windows (ECO) application
Drop three datagrids(dgPerson, dgDeveloper, dgSalesMan) on the form and three ExpressionHandles (ehPerson, ehDeveloper, ehSalesMan) And oh, don't forget to compile first!

Setting the ExpressionHandles
ehPerson:
Name->'ehPerson'
Roothandle->rhRoot (Don't forget to set the Roothandles EcoSpaceType property!)
Expression->Person.AllInstances (Use the OCL Editor here)

ehDeveloper:
Name->'ehDeveloper'
Roothandle->rhRoot
Expression->Developer.AllInstances

ehSalesMan:
Name->'ehSalesMan'
Roothandle->rhRoot
Expression->SalesMan.AllInstances

Setting the datagrids
dgPerson:
DataSource->ehPerson

dgDeveloper:
DataSource->ehDeveloper

dgSalesMan:
DataSource->ehSalesMan

To make things complete drop two buttons for the Developer and SalesMan grid. Connect the roothandle property to ehDeveloper and ehSalesMan and set the for both buttons the property ECOListAction to Add.

Well this is pretty much it! You can see that the grids have all the appropiate attributes for their classes. By running the application we can test it:

Notice that adding a developer or salesman automatic means adding a person. So again the model does all the hard work in the background.
While still scratching the surface of ECO it becomes clear that ECO is very powerfull framework, taking a lot of the work load. Making this little application with TDataSets would be harder (although it can be done). For instance after inserting the Developer you would have to code to get a person in the person table.

Guess what: We did not code at all!

Monday, January 16, 2006

Refactor all the way

After using BDS 2006 for three weeks now I must say it is a real piece of art. I can not think of one reason to go back to Delphi 7. For me the most valuable new features are the improved and extended refactorings. It takes some time to get used, using them, old habbits just don't disappear that easy :-) I guess.

What I always found a bit annoying in Delphi coding was the fact that changing the parameters of an existing method, meant a lot code cruising. OK, you can't have it all but figure this:

In Delphi 7, to change a parameter of a method you should do something similar like this:

1. Change the parameter in the implementation section (iow the method)
2. Surf (Ctrl-Click) to the interface section to change the decleration
3. Ctrl + Arrow Down to go back to the implementation

Delphi 2006, and in specific Together, dramatically improved things. With refactoring you can now change the parameterlist of a method, and Together will take care of changing the declaration (or vica versa)!

The 'Change Parameters' refactor dialog:


With this dialog you can add or alter parameters in a very easy way. Other 'My favourite' refactorings are:

  • Extract method (Existed already in D2005)
  • Find unit (Helps you finding the unit for the uses clause)
  • Declare variable

The new and improved refactorings in BDS 2006 boost productivity, no doubt about that. This and the other editor improvements, like Live templates, made upgrading to BDS2006 worthwhile.

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