Proposal: Using unregistered objects. Removing restriction from IDE.0
From: Felix Porsch (F.Porsch_at_t-online.de)
Date: 12/20/03
- Previous message: Pete Lees: "Re: creating help file"
- Next in thread: Tony J Hopkinson: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Reply: Tony J Hopkinson: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Reply: G. Allen Casteran: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Reply: Dennis: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Reply: Pavel Rogulin: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 20 Dec 2003 16:29:15 +0100
In Delphi (and others) you have to register components before you can
use them in the IDE.
As a consequence you frequently encounter statements like this:
procedure TMainForm.FormCreate;
begin
initComponentX
end;
or
procedure TMainForm.ComponentXEvent;
begin
doSomethingComponentInternal
end;
or
procedure TDataModule1.Table1FilterRecord( accept : Bolean);
begin
applySomeFilterOps
end;
Properties and procedures of the components are coded in the body of the
form or datamodule. But what you may want to have is something like
procedure TComponentX.Create(AOwner:TComponent);
begin
inherited create(AOwner);
initComponent
end;
// ComponentX is an object on its own. So why help from MainForm?
and
procedure TComponentX.Event;
begin
doSomethingComponentInternal
end;
and
procedure TTable1.FilterRecord( accept : Bolean);
begin
applySomeFilter
end;
// Who knows better how to filter than the table itself?
In fact, you can do so. Here is an example:
------------
unit CompDemo;
interface
uses SysUtils, Classes, Forms, StdCtrls;
type
// a tiny special component, not registered, not installed
TStartTimeLabel = class(TLabel)
public
constructor create(AOwner: TComponent); override;
end;
TMainForm = class(TForm)
Label1: TStartTimeLabel;
// nothing else here
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
constructor TStartTimeLabel.create(AOwner: TComponent);
begin
inherited create(AOwner);
Caption:= 'Program start at ' + DateTimeToStr(now);
end;
end.
-----------------
Here is CompDemo.dfm (I made it short):
----------------
object MainForm: TMainForm
object Label1: TStartTimeLabel
end
end
----------------
You can compile and run the application. So what is the problem?
You can’t load the form in the IDE! The IDE does not know how to handle
a TStartTimeLabel because it is not registered.
Of course, you can derive a new component, register and install it in
the IDE and use it. But this needs some extra work and care. And soon
you will have a lot of components at the Component palette with very
special tasks and only minor differences. Or you have to use the ugly
method described in the section Testing Uninstalled Components.
Therefore the code for component initialization, destruction,
properties, and event handling is scattered in the form code or the
datamodule code.
In short: The IDE hinders the early birth of new components.
My proposal is as follows:
Introduce a new IDE directive, which indicates what substitute the IDE
should use for an unregistered component. For example:
TStartTimeLabel = class(TLabel) { USE TLabel}
As far as I can see only little changes in the IDE are necessairy to
bring this in operation.
Or, as a better alternative, use ‘temporarly’ registered components,
which can grow with every compilation of the project.
What would we get?
First, right from the beginning we can place the new component on a
form/datamodule and manipulate the (inherited) properties with the prop
editor.
But we can do even more. Suppose you have some Tables on a data module.
At some time you notice that you have to implement special filter
operations (onFilterRecord) on several tables. The filter operations are
the same for all tables but the parameters are different and may change.
At present you have to implement TableFilterRecord for every such Table
and to hold the different filter parameters in DataModule. With the new
option you could declare a TFilteredTable with the parameters as
property. Than you could substitute the type of this tables by the new
type TFilteredTable without loosing the property values of the tables
already set!
I can imagine that there are more situations where this feature would
bring advantages.
At least it simplifies the birth of new components which may later
become ‘regular’ registered compomponents.
felix porsch
- Previous message: Pete Lees: "Re: creating help file"
- Next in thread: Tony J Hopkinson: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Reply: Tony J Hopkinson: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Reply: G. Allen Casteran: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Reply: Dennis: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Reply: Pavel Rogulin: "Re: Proposal: Using unregistered objects. Removing restriction from IDE.0"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|