 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Andy Gibson Guest
|
Posted: Mon Aug 25, 2003 5:19 am Post subject: The little things that matter... |
|
|
I've been using Delphi since Version 1, and over the course of time, I've
worked on a number of projects that all do common basic things different
ways. We are looking to standardize on some of the basic techniques used to
implement these standard tasks and so I thought I'd see what everyones
opinions are on the issues. (if anyone would like to add other issues, feel
free)
Datasets on datamodules vs Forms :
For your everyday form which lets the user edit a piece of data, should
datamodules be used to host those datasets? If you use a datamodule, it
keeps things nice and clean. However, if you allow multiple instances of the
form, then you need to have more than one data module and then you have to
bind the data aware controls to the datasources at run time.
Putting datasets on forms means each instance of the form has its own
datasets at run time wihout the need for additional coding. This doesn't
really cause any problems except for the fact that it clutters the form up
at design time,
and datamodules can still be used for truly shared 'singleton' type
elements.
Persistent fields vs Dynamic Fields :
I know there was a thread recently about this, but I'll include anyways.
Without persistent fields, you can't have lookup fields or calculated fields
unless they are created at run time (not too RAD). You could push the
calculated fields into the SQL if they are static and won't change when the
row changes. Changes in the database or even using alternative databases
which result in different field types can cause problems on the
client side with persistent fields mismatching the source field datatypes.
Calling Forms to Edit Data :
Assuming you have a form which edits a particular entity given an entity ID,
where do you put the function to create and display the form? You could have
a unit dedicated to containing stub procedures whose sole purpose is to
create an editor, pass in the parameters open it up and return whether the
form was closed with an OK.
i.e.
function EditItem(AnItemID : Integer) : Boolean;
var
frm : TfrmItemEditor;
begin
frm := TfrmItemEditor.Create(nil);
try
frm.LoadItem(AnItemID);
Result := frm.ShowModal = mrOK;
finally
frm.Free;
end;
end;
You could also have a class function on the form which contains the above
code to create, load and open the form, but then this means that any item
calling the editor needs to know about the individual class of the form.
With the previous solution, any part of the application needing to edit an
item only needs to know the location of the 'EditItem' function which could
be in a unit dedicated to containing these stubs used to launch forms.
Another issue is whether the form loads its own version of the item to edit
it, or whether it is passed a datasource which points to the item to edit.
Passing a datasource/dataset to a form means that there is no need for
another trip to the server to fetch the data required for the editor. OTOH,
to create a standard editor form for a particular item means that all
datasets holding instances of that item need to have the field names exactly
the same in order for the editor to access the item from that dataset.
We are trying not to mix and match the techniques used for these basic
functions (and others as they crop up) so I'm just curious as to what the
general concensus is.
Cheers,
Andy
|
|
| Back to top |
|
 |
Alessandro Federici Guest
|
Posted: Mon Aug 25, 2003 9:06 am Post subject: Re: The little things that matter... |
|
|
"Andy Gibson" <delphi_pa (AT) hotmail (DOT) com> wrote
[...HIT THE NAIL ON THE HEAD...]
| Quote: | I'm just curious as to what the general concensus is.
|
Just wait till Wednesday and you will see what our thought on the
dataset/business-rules/events matter is
Stay tuned on the 3rd party newsgroup.
--
Regards,
Alessandro Federici
RemObjects Software, Inc.
http://www.remobjects.com
|
|
| Back to top |
|
 |
Dave Nottage (TeamB) Guest
|
Posted: Mon Aug 25, 2003 11:54 am Post subject: Re: The little things that matter... |
|
|
Andy Gibson wrote:
| Quote: | For your everyday form which lets the user edit a piece of data,
should datamodules be used to host those datasets? If you use a
datamodule, it keeps things nice and clean. However, if you allow
multiple instances of the form, then you need to have more than one
data module and then you have to bind the data aware controls to the
datasources at run time.
|
FWIW: I do that, but still link them at design time.
--
Dave Nottage (TeamB)
|
|
| Back to top |
|
 |
Ross Guest
|
Posted: Mon Aug 25, 2003 12:13 pm Post subject: Re: The little things that matter... |
|
|
Andy Gibson wrote:
| Quote: | Datasets on datamodules vs Forms :
I like to use datamodules. I get highly annoyed with a clutered form. I |
got stuck maintaining an older application where the programmer had 3
tabs of edit controls, ~600 objects, and 15 ReportBuilder reports,
another ~300 objects, all on the same form. I just finished rewriting
that one.
I like to use one datamodule/form when it makes sense. Obviously for
very simple dialogs they can have the datasets/datasource on the form,
but only very simple dialogs. IMO, it keeps the code seperated and
easier to maintain.
| Quote: |
Persistent fields vs Dynamic Fields :
I like using dynamic fields. The calculated fields issue is a bit a pain |
but worth it in the long run.
| Quote: |
Calling Forms to Edit Data :
I put the code to call the form in the same unit as the form, similiar |
to the example posted. I guess I had not thought of having a global unit
to do that kind of stuff. I have a global unit for other things but have
not used it for that. I think i will stick my keeping it in the same
unit as the form. I like to have all the code related to a form in the
unit that the form is in. At bug fix time it is all in one place.
| Quote: |
We are trying not to mix and match the techniques used for these basic
functions (and others as they crop up) so I'm just curious as to what the
general concensus is.
Cheers,
Andy
|
Just My $.02,
Ross
|
|
| Back to top |
|
 |
Buch Guest
|
Posted: Mon Aug 25, 2003 12:39 pm Post subject: Re: The little things that matter... |
|
|
| Quote: | ways. We are looking to standardize on some of the basic >techniques used to
implement these standard tasks and so I thought I'd see what >everyones
|
I used to "paint" forms with form designer, drag&dropping visual components ...
Then I learned not to write on-click code by separating code and user interface, and then I learned not no "paint", but to encapsulate behaviour in components.
All tasks that are repetitive and can be well described, such as building user interfaces, database applications etc. can be automated. That is what computers and software are all about.
So, you need components that will do this for you, the way you want it. Once you make them (or buy, note Alessandro ) ), issues that you described will become transparent to you, thus enabling you to focus on design, not implementation, and because everybody else in your group will use them, you will have standardization.
I made set of components that does insert/edit/search forms, etc.., and simple generator which uses that components by adding them to skeleton application source. I can produce VCL, CLX and Intraweb output ...
I'm now finishing generator, which I will use for my university diploma work, and for commercial product, if I can )
Anyway, I will probably translate my diploma to English, and have freeware version that uses freeware Interbase and IBComponents ... and put all to web.
But I think you should write your own set of components, because it is really not hard, once you chew into it, and you will have better understanding of what is happening, even if you purchase 3rd party with source.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|