1. Technology

Don't use Delphi components!

Use your own!

By

I'm going to be honest with you: I love Delphi! Go figure :)

The amount of power Delphi gives to a developer is amazing. Want to build a database application? No problem, just choose from many of the data access options Delphi provides (BDE, ADO, dbExpress, IBExpress, etc.) then pick your database (Paradox, Access, Interbase, SQL Server, etc). Need to build a shell extension? Again no problem! Delphi provides the easiest access to Windows API as possible. A graphical software? A multimedia application?

So why is this? How come Delphi has all the answers? The answer is the VCL - Visual Component Libarary. Delphi's VCL is a set of powerful controls/components grouped into a hierarchical library. Each control was build to provide some special functionality in an application. We've all used to drop a TButton, TEdit or any of the VCL controls on a form (and even a TForm is a component) and operate with properties, methods and events.

Being able to (easily) extend every component was one of the first things that attracted me to Delphi.

Now, here's one more truth from me: I am not using any of the standard Delphi components when building any kind of a larger application!

What?! Yes, the truth, and here's the explanation: I love to have the full control of the building blocks of my application, and since all Delphi applications are developed using various components I tend to first create my own version of every single component I add to a project. What this means is that every component dropped on a form (my version of TForm) in my applications is derived from some "standard" Delphi component - even if I don't add any new properties, methods or events. This approach gives me the power to easily add new features to components as soon as I see a need them.

Let me explain this a bit, with an example:

Every application ("data-aware" or not) needs a way for a user to edit data. Naturally, the TEdit (or a TDBEdit, in a database application) component is the first to think of. Now, suppose you have several data-entry forms in you applications, and in one point you realize that TEdit does not provide the Alignment property, for example, and that something like Alignment would come handy *now*. More or less, you are in trouble - what you need is something like TEditAligned component. But, how do you change all the TEdit components on every form in your project to a TEditAligned? You're stuck!

Convinced? Yes? So how do you create your own components? You are just a beginner/novice user? So what? It's never too late to learn something new!

You can derive a new component from any existing component, but the following are the most common ways to create components: modifying existing controls, creating windowed controls, creating graphic controls, subclassing Windows controls and creating nonvisual components. Visual or not, with or without property editor, from scratch...you name it. The Custom Component Development article provides answers to any questions you might have on custom component development.

If you need some ready made components (with source, of course) to start learning, just point to "About Delphi Programming VCL repository" and pick the component of your choice.

©2014 About.com. All rights reserved.