top ten reasons to upgrade from delphi 7

of 15 /15
Corporate Headquarters 100 California Street, 12th Floor San Francisco, California 94111 EMEA Headquarters York House 18 York Road Maidenhead, Berkshire SL6 1SF, United Kingdom Asia-Pacific Headquarters L7. 313 La Trobe Street Melbourne VIC 3000 Australia Article Top Ten Reasons to Upgrade from Delphi 7 By Nick Hodges December 2008

Author: michael-findling

Post on 19-May-2015




3 download

Embed Size (px)


This article discusses then reasons why Delphi 7 developers should upgrade toDelphi 2009 or RAD Studio 2009.


Page 1: Top Ten Reasons to Upgrade from Delphi 7

Corporate Headquarters100 California Street, 12th FloorSan Francisco, California 94111

EMEA HeadquartersYork House18 York RoadMaidenhead, BerkshireSL6 1SF, United Kingdom

Asia-Pacific HeadquartersL7. 313 La Trobe StreetMelbourne VIC 3000Australia


Top Ten Reasons to Upgrade from Delphi 7By Nick Hodges

December 2008

Page 2: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 2

This article discusses then reasons why Delphi 7 developers should upgrade to Delphi 2009 or RAD Studio 2009.

There are still a few die hard developers out there that are using Delphi 7. They do so in the face of an overwhelming onslaught of features and capabilities of the latest version of Delphi, Delphi 2009. Below, I discuss ten reasons why Delphi 7 developers should upgrade to Delphi 2009.

Now, mind you, I am limiting this article to ten items. It could easily be way more than that. But I figure that if these ten aren’t enough, I can write “Ten More Reasons to Upgrade from Delphi 7”.

The InTegraTed developmenT envIronmenTThe Integrated Development Environment (IDE) has been drastically improved and enhanced since Delphi 7. Numerous features and a complete re-architecting have added countless productivity enhancements that puts the Delphi 2009 IDE light-years ahead of the older IDEs found in Delphi 7 and earlier versions. This section will highlight just a few of those changes.

1. lIve TemplaTes

In my view, Live Templates are one of the coolest – and one of the most under-appreciated features of Delphi 2009. They might take a bit of getting used to, but they are extremely powerful, they can really improve your productivity, and they are completely customizable. If you don’t like the way that they work, you can change any of the templates. If you want the system to do more than it does, you can easily create your own templates. In addition, you can even writing your own scripting engines to make it do almost anything you want.

Live templates are an editor feature that enables you to quickly inject and fill in any type of code construct into your code. The default set of Live Templates includes templates for all the standard language constructs like if, while, case, for, and many others. In addition, many of these templates include scripting capabilities that add further power to the Live Template feature. For instance, if you declare a known enumerated type with a case statement, the Live Template engine will fill in all the enumeration elements inside the case statement for you, saving you a lot of keystrokes and formatting.

In addition, the included templates make it very easy to create common coding constructs such as class declarations, class instantiations with a try...finally block (See Figure 1), functions and methods, as well as comments, arrays, and more.

Figure 1 - The Live Scripting template for creating a class instance, including the try... finally block.

Page 3: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 3

Live templates themselves are actually simply XML files that describe a text caption to be replaced and the text to replace it. You can create a live template to insert any code or text you want into the code editor. If you have, say, a standard header you put at the beginning of every file, you can create a live template to insert it, even creating “code points” to insert specific information at specific places. I’ve used them in demos to insert large chunks of code that illustrate the feature being demonstrated. I also have some live templates that correct some of my common typographical errors (e.g., replacing stirng with string). The possibilities are endless, and every live template can drastically increase your productivity by saving you time and keystrokes.

In addition, the XML files can specify which language the template should be used with, and which scripts should be run on the template as well. You can create your own live templates from scratch. Or even better, you can use the live template that creates new live templates!

Live templates are also completely scriptable. You can build your own scripting engine using Delphi to define almost any behavior during the use of a live template. I’ve created a set of classes that make it easy to create a custom template, including templates that make it easy to inject the date and time into your source code. You can get it here at CodeCentral. Give it a look and see how easy it is to do almost anything you want with Live Templates.

more InformaTIon

• Live Templates on the Delphi Wiki - a collection of useful live templates.• Technical Information about Live Templates on the Delphi Wiki• A video demonstrating Live Templates

2. hIsTory Tab

Sometimes you are coding, and you realize that you’ve just headed in a direction that you really don’t want to go. Sometimes you delete a whole bunch of code and a few minutes (and a few CTRL-S events) later, you think, “Uh oh”. And of course, this always happens without having a good backup or a good save point in your source control management tool. (You do backup and you do use a source control management tool, don’t you?) Enter the IDE’s history tab. The History Tab is sort of a “poor man’s source control system”. It will save physical files of your code each time you save a file, ensuring that there is a history of your changes. Set the number of files saved to a configurable value, save your code frequently, and you can be sure that any changes you make can be easily undone.

The history tab keeps track of your files by placing the backup copies in a special hidden directory. It tracks changes to any text file that is part of your project – including *.DFM files – and provides you with a nice interface that allows you to peek into any of the files from your history. It even has a simple file compare tool that enables you to do a diff on two separate files.

One side benefit I’ve found with the History Tab is that it makes me a bit “braver” when I’m coding – I feel much more inclined to try something a little “scary” because I know that I can really easily go back to a known state without having to do a check in to the source control system.

Page 4: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 4

Figure 2 -- The History Tab showing the file compare feature.

3. dockable/cusTomIzable IdeEvery developer is different, and it seems pretty unlikely that no two developers would ever want their IDE’s to be exactly the same. And Delphi 2009 certainly provides a completely customizable environment. It includes the ability to dock windows where ever you want, configure toolbars, and store customizable desktops for specific purposes.

cusTomIzable Toolbars

Quick access to IDE functionality is a critical part of a developers productivity, and Delphi 2009 provides a completely customizable set of tool bars that enable you to put whatever functionality you want right at your fingertips. Based on the VCL’s powerful action band technology, you can easily move the toolbars where you want, place any tool button on them, and even pull them off and put them as tool windows anywhere on your IDE.

Page 5: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 5

Figure 3 -- The IDE’s tool bars being customized, including the Spacing tool bar displayed as a tool window.

dockable WIndoWs

The Delphi IDE is a powerful tool, and as a result, it has a number of windows, views, and other ways to display valuable information. Organizing all of that can be difficult. So Delphi 2009 provides a completely dockable solution. Almost any window can be placed at a docking location. Windows can be docked together, creating a tab set to allow for the display of different windows. Windows can be docked to the sides of the IDE, and then “pinned” or “un-pinned” for easy access. Unpinned windows can “slide away” to tab sets, with easy access with the mouse.

Overall, the pinning and docking of windows makes for an IDE that can put a lot of functionality in convenient and easy to access locations, while still allowing plenty of room for coding and designing.

Page 6: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 6

Figure 4 -- Four Windows docked together to save space and improve accessibility

cusTomIzable deskTops

And of course, the ability to save all these customizations is important. Once you get your IDE setup in your own special way, you want to be able to save it and recreate it anytime. Delphi 2009 allows you to save any desktop configuration for later use. You can have numerous configurations for different purposes. Sometimes I want to see just code and pretty much nothing else. So as shown in Figure 5 to the left, I have a desktop layout called “CodeOnly” that unpins all the windows, slides them to the sides, and shows me just the Code Editor. All my windows are easily accessible with the mouse, but I have a screen with basically nothing but code showing.

In addition, you can set up a special desktop for debugging that will be displayed only when the IDE is placed into Debug mode. This is nice for easily moving between the layout and special windows you need for debugging and the normal desktops that you use during development.

Figure 5 -- The IDE showing different desktop layouts

Page 7: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 7

4. vcl desIgner guIdelInes

Setting up forms is no fun, especially forms with a lot of components on it. Getting things aligned and spaced just right can be challenging. And those pesky users can notice when one control is out of place by a single pixel. Previous versions of Delphi provided alignment tooling for ensuring that controls line up properly, but they often took time, and didn’t always make things as easy as they could be. Delphi 2009 solves this problem very nicely by providing VCL control guidelines.

The VCL Control guidelines provide a visual reference for seeing when controls are properly spaced and aligned. As you drag controls on a form, guidelines appear that show when a control is properly aligned with another control. The designer will even “snap” the controls into place as they are moved, making it very easy to align controls properly.

For spacing controls, the guidelines show a small line between controls when they are spaced properly according to your settings.

The VCL also has been enhanced to support this, so that controls can define their own padding and margins, ensuring that the designer knows how a control wants to be spaced away from other controls. Padding and Margin can also affect a control when it’s Align property is set.

Component designers can also make their components “guideline aware” if their controls have any special requirements for alignment.

The VCL Designer Guidelines make it almost pathetically easy to get a form set up properly. I find that I almost

never use the Align and Spacing dialogs anymore. It’s just way to easy to align the controls right as you put them on the form – a great productivity enhancer.

5. neW Tool paleTTe

Personally, I find the new Tool Palette to be my favorite features of the new IDE. It is incredibly easy to find and add a component, even when you have lots and lots of components on it. The main reason is the filtering feature, which allows you to find a component very easily by merely hitting a few keystrokes. As shown in Figure 4, the Tool Palette can filter itself based on your input. Here, I’ve entered “button” into the search filter box, and as a result, only components with button in the name are selected. At this point, you can press enter to add a button to the form, you can continue typing to refine the search, or you can use the mouse or keyboard to select an item for adding to the form. All in all, finding components is very, very fast.

In addition, the Tool Palette is completely customizable. You can select colors for the tool palette. You can easily add new categories to the existing ones, you can rearrange the existing categories, and you can copy or move components between

categories. The Tool Palette is completely flexible in how it presents the components.

In addition, the tool palette is a dockable window so you can place it wherever you like inside of your IDE. You can also set the categories to auto-collapse as you move from category to category. Overall,

Figure 6 -- The VCL Designer guidelines showing alignment and spacing

Figure 7 -- The Tool Palette showing the filtering feature.

Page 8: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 8

the Tool Palette is much more flexible and configurable than the one in previous versions of Delphi.

furTher InformaTIon

I made a video showing off the new tool palette. It is a bit dated, as it is from an older version that doesn’t have the search box, but you should get the idea.

6. refacTorIng

You pretty much have to be a genius to write perfect code the first time. I don’t know about you, but I’m constantly rewriting my code in some desperate attempt to make it look perfect. I’m yet to succeed. But at least with Delphi 2009, I have a set of tools that automates much of that code improvement process.

Figure 8 -- The Extract Method refactoring dialog.

Refactoring is the process of improving the structure of your code without changing what it does. Delphi 2009 provides a number of useful refactorings, including refactorings to declare and rename variables, extract methods, reorganize class structures, and safely delete identifiers.

For instance, far more powerful than a simple search and replace, the Rename Variable refactoring will search your code and find every instance of the variable in question, and rename the variable for you. The Extract Method refactoring can take portions of code in large routines and break them down into smaller code blocks, even ensuring that the right parameters are passed to the newly created method. Overall, refactorings provide a large and powerful productivity boost by making it very easy to improve the structure of your code.

The following table describes all the refactorings available in Delphi 2009:

Refactoring Name Description

Move Moves static methods from one class to another

Extract Interface Creates an interface based on selected methods of a class, and declares that interface as implemented by the given class.

Extract Superclass Moves selected class members to a new class that is the parent of the selected class.

Page 9: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 9

Refactoring Name Description

Pull Members Up Moves selected members to the direct parent class of the selected class

Push Members Down Moves selected members to the direct descendent class of the selected class.

Safe Delete Deletes selected item only if it is not used anywhere in the application.

Inline Variable Replaces instances of a temporary variable with an inline declaration of the literal value.

Introduce Field Moves an existing local variable to be a field on the given class.

Introduce Variable Converts a literal expression into a variable declaration with an assignment of the literal expression to the new variable name

Rename Renames a given identifier throughout the project

Declare Variable Declares as a local variable that has been used but no yet declared.

Declare Field For a selected, undeclared identifier, will properly declare said variable as a field on the given class.

Extract Method Creates a new method based on the selected code, including passing in any necessary parameter.

Extract Resource String Creates a new resource string based on the selected string, and replaces string literal with name of new resource string.

Change Params Adds, modifies, and deletes parameters for a given method.

I myself end up using the Rename Variable refactoring quite frequently. Oftentimes the first name given to a variable ends up being to simple or not clear enough. It makes it really easy to ensure that you have clear, descriptive variable names. I also use the Extract Method a lot to keep my method sizes to a minimum and to make sure that all my routines are nice, small, and focused on one thing.

In any event, Refactorings are a very cool and powerful feature that you definitely want to have.

The languageThe Delphi language has had numerous feature improvements since Delphi 7 – features that greatly enhance the power available to the Delphi developer. This section outlines the latest language features that no Delphi developer can do without.

7. generIcs

A new language feature in Delphi 2009, Generics are a powerful addition to Delphi. Generics allow you to define classes that don’t specifically define the type of certain data members. Generic classes allow you to write a single class that can act the same way on multiple types without knowing what those types will be ahead of time.

For instance, the new unit in Delphi 2009 named Generics.Collections.pas contains a generic TList<T> class that enables you to maintain a type safe list of any type at all. For example, you can declare:

type TPerson = record FirstName: string; LastName: string; Birthday: TDate;

Page 10: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 10


varPeopleList: TList<integer>;Person: TPerson;beginPerson.FirstName := ‘Donald’;Person.LastName := ‘Duck’;Person.Birthday := EncodeDate(1809, 2, 12);

PeopleList := TList<TPerson>.Create;try PeopleList.Add(Person); // Add more items, and do something with the list ...finally PeopleList.Free;end;end;

The code above uses the generic TList<T> to maintain a list of an arbitrary type, in this case a simple record. As a result, you have a single class that hold a list of anything, rather than having to create – and thus maintain – a whole bunch of specialized descendent classes to maintain lists of arbitrary types. One class means less code to worry about and fewer bugs.

Generics also allow the parameterized type to be constrained, either to a specific class, to a class that implements a specific interface, or to require that the class have a constructor or be record. For instance, you can declare the following class:

TControlReporter<T: TControl, IEnumerable> = class private FInternalType: T; public constructor Create; procedure ProcessComponent; procedure SetType(aT: T); end;

Given the above, you must pass a TControl or TControl descendent to any instance of TControlReporter<T>, and in addition, it must implement the IEnumerable interface. Any other types will cause a compiler error. In this case, generic constraints allow you to use the type internally as if it were a TControl or as if it had the methods of IEnumerable. In this way, you can create more powerful and specific generic classes. Without the ability to constrain generic types, generic members would be able to provide very little functionality.

As mentioned above, Delphi 2009 now includes the Generics.Collections.pas unit, which

defines generic lists, queues, stacks and dictionaries for use in your code.

Page 11: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 11

more InformaTIon

More information about Generics in Delphi can be found in the White Paper entitled “Using New Delphi Coding Styles and Architectures.”

8. anonymous meThods (closures)Another major language feature in Delphi 2009 is Anonymous Methods (sometimes called Closures). An anonymous method in Delphi is a mechanism to create a method value in an expression context. Anonymous methods allow you to pass code blocks as parameters, or to assign code blocks to variables. Anonymous methods are similar to method pointers, but they have one key difference noted above: variable capture. Anonymous methods can capture the state of the variables used in their code based upon the values set within the same scope as the anonymous method.

Since Delphi is a strongly-typed language, you always need to declare a type before you can actually use an anonymous method. For example:

type TIntProc = reference to procedure (n: Integer);

The above declares a simple anonymous method type that takes a single integer parameter. Given the above type declaration, you can now declare a code block of this type:

var anIntProc: TIntProc;begin anIntProc := procedure (n: Integer) begin Memo1.Lines.Add (IntToStr (n)); end; .....anIntProc(42);end;

Once the type is declared, you can, as shown above, declare a procedure that is assigned to the variable of the anonymous type. (Note the ‘anonymous’ part – the procedure doesn’t have a name.) Once the variable is defined, you can then call the anonymous method, passing the correct parameter along.

Variables of the type of an Anonymous method can be passed as parameters to any method, can be declared and assigned to as variables and properties, and can be used in any way that standard variables are used.

The real power of anonymous methods come when they do local variable capture. For an example of that, I’d recommend reading our White Paper “Using New Delphi Coding Styles and Architectures.”

Page 12: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 12

9. unIcode supporT

The Internet has broken down geographical barriers that enable world-wide software distribution. As a result, applications can no longer live in a purely ANSI-based environment. The world has embraced Unicode as the standard means of transferring text and data. Since it provides support for virtually any writing system in the world, Unicode text is now the norm throughout the global technological ecosystem.

Among the many new features found in Delphi 2009 is the imbuing of Unicode throughout the product. The default string in Delphi is now a Unicode-based string. Since Delphi is largely built with Delphi, the IDE, the compiler, the RTL, and the VCL all are fully Unicode-enabled.

The move to Unicode in Delphi is a natural one. Windows itself is fully Unicode-aware, so it is only natural that applications built for it, use a Unicode string as the default string. And for you the Delphi developer, the benefits don’t stop merely at being able to use the same string type as Windows.

The addition of Unicode support provides you with a great opportunity. You now can read, write, accept, produce, display, and deal with Unicode data – and it’s all built right into the product. With only few, or in some cases to zero code changes, your applications can be ready for any kind of data you, your customers or your users can throw at it. Applications that previously restricted to ANSI encoded data can be easily modified to handle almost any character set in the world.

Figure 9 -- The Code Editor and VCL controls displaying and using Unicode data

Page 13: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 13

You will now be able to serve a global market with your applications -- even if you don’t do anything special to localize or internationalize their applications. Windows itself supports many different localized versions, and Delphi applications need to be able to adapt and work on machines running any of the large number of locales that Windows supports, including the Japanese, Chinese, Greek, or Russian versions of Windows. Users of your software may be entering non-ANSI text into your application or using non-ANSI based path names. ANSI-based applications won’t always work as desired in those scenarios. Windows applications built with a fully Unicode-enabled Delphi will be able to handle and work in those situations. Even if you don’t translate your application into any other spoken languages, your application still needs to be able to work properly -- no matter what the end user’s locale is.

For existing ANSI-based Delphi applications, the opportunity to localize applications and expand the reach of those applications into Unicode-based markets is potentially huge. And if you do want to localize your applications, Delphi makes that very easy, especially now at design-time. The Integrated Translation Environment (ITE) enables you to translate, compile, and deploy an application right in the IDE. If you require external translation services, the IDE can export your project in a form that translators can use in conjunction with the deployable External Translation Manager. These tools work together with the Delphi IDE for both Delphi and C++Builder to make localizing your applications a smooth and easy to manage process.

The world is Unicode-based, and now Delphi developers can be a part of that in a native, organic way. So if you want to be able to handle Unicode data, or if you want to sell your applications to emerging and global markets, you can do it with Delphi 2009.

The vIsual componenT lIbrary

10. rIbbon conTrols

The VCL has always been about creating great looking user interfaces, and Delphi 2009 keeps that tradition going in a big way. Delphi 2009 includes a complete implementation of the Office 2007 user interface, commonly called Ribbon Controls. Ribbon controls are a new way of presenting functionality to the developer that in effect combines the functionality of menus and toolbars into a single entity. Instead of having a menu item and a corresponding toolbar button, a ribbon control combines the two ideas. At the simplest level, top level menu items become tabs, and each tab can have a group. Each group contains tool buttons of various sorts that correspond to what had been menu items and toolbar buttons. Ribbon controls are more flexible in that they allow for radio buttons and checkboxes and other common controls to be nested inside of them. The Microsoft specification also calls for the ribbon controls to be configurable at runtime as well. The implementation in Delphi 2009 is written entirely in Delphi and doesn’t rely on any external libraries. It also matches the entire specification as set out by Microsoft.

Page 14: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 14

Figure 10 -- The ribbon controls on an application in the Form Designer

Ribbon controls are also based on the VCL’s Action Manager technology, so if you have an existing application that uses the Action Manager, it will be very easy to adapt your application to use Ribbons. You’ll also want to use the ribbons for new applications to give them the modern look that your users and customers demand.

Page 15: Top Ten Reasons to Upgrade from Delphi 7

Top Ten Reasons to Upgrade from Delphi 7

Embarcadero Technologies 15

conclusIonSo, there you have it -- the top ten reasons to upgrade from Delphi 7 to Delphi 2009. As noted before, the hardest part about writing this article was limiting it to only ten.

On the language front, I had to leave out the statement, inlining, operator overloading, class helpers, records with methods, nested classes, among others. In the IDE section, I had to leave out Intellimouse support, the Delphi Class Explorer, the MSBuild engine including pre- and post-build events, the File Explorer, Block Completion, debugger enhancements, Code Folding, SyncEdit, Integrated Unit Testing, and who knows what else. In the VCL, I didn’t get to mention theming, Balloon hints and the new hinting system, support for the Vista dialogs, glassing, and APIs, TCategoryPanelGroup, TFlowPanel, TGridPanel, TTrayIcon, Intellimouse support, and Margins and Padding.

Overall, the case for upgrading seems pretty overwhelming to me.

abouT The auThorThis white paper has been written for Embarcadero Technologies by Nick Hodges. Nick Hodges is the Delphi Product Manager. Before becoming the Delphi Product Manager, Nick was a Delphi consultant, author, blogger and TeamB member. Nick has an MS in Information Technology Management and served in the US Navy for 12 years. Nick lives in California.

Embarcadero Technologies Inc., empowers application developers and database professionals with tools to design, build, and run software applications in the environment they choose. A community of more than three million worldwide and 90 of the Fortune 100 rely on Embarcadero DatabaseGear™ and CodeGear™ product lines to increase productivity, openly collaborate, and be free to innovate. Founded in 1993, Embarcadero is headquartered in San Francisco, California, with offices located around the world. Embarcadero is online at The company’s flagship DatabaseGear tools include: ER/Studio®, DBArtisan®, Rapid SQL®, and Embarcadero® Change Manager™.