 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
roozbeh Guest
|
Posted: Sun Mar 19, 2006 10:03 am Post subject: how do you name the controls? |
|
|
Well i made some rules for myself but was wondering how do you name the
controls you use very often also in code.
for example think of thousand of checkboxes,everyone related to specific
task.
do you preserver checkbox1,checkbox2 names or changed them.
my rule was "chk" at first of name and then their functionality afterwards
for example "chkShowTips".
i was wondering if any rules exist or something make them easier to use?
regards
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ |
|
| Back to top |
|
 |
Bryce K. Nielsen Guest
|
Posted: Sun Mar 19, 2006 10:03 am Post subject: Re: how do you name the controls? |
|
|
I never leave the default names of a component, even the never-seen stuff
like "hidden" container controls. I always name them something different,
something that makes more sense.
There's a debate between naming something "chkIsActive" or
"IsActiveCheckBox". When DotNet came out, it looked like the latter was
chosen as a defacto way of programming visually. I personally prefer then
former, since I like how it groups my controls together alphabetically.
Makes it a lot easier to search for in the Object Inspector drop down list.
If I've renamed everything properly, and I'm looking for some odd checkbox,
then I just need to dropdown to "chk..." If I follow the latter naming
convention, then I'll probably never find it...
-BKN |
|
| Back to top |
|
 |
Arthur Hoornweg Guest
|
Posted: Sun Mar 19, 2006 11:03 am Post subject: Re: how do you name the controls? |
|
|
Bryce K. Nielsen wrote:
| Quote: | then I just need to dropdown to "chk..." If I follow the latter naming
convention, then I'll probably never find it...
|
Very good point.
Maybe it would be a nice feature if the dropdown would order the
components by TYPE?
But the "structure treeview" (aka object treeview in D7) is very helpful
too
to find components and also has the advantage that it shows you which
component has which parent.
--
Arthur Hoornweg
(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.) |
|
| Back to top |
|
 |
K. Sallee Guest
|
Posted: Sun Mar 19, 2006 11:03 am Post subject: Re: how do you name the controls? |
|
|
Always rename, never use Hungarian notation.
Kevin |
|
| Back to top |
|
 |
K. Sallee Guest
|
Posted: Sun Mar 19, 2006 11:03 am Post subject: Re: how do you name the controls? |
|
|
On Sun, 19 Mar 2006 13:42:19 +0430, roozbeh <roozbehid (AT) yahoo (DOT) com> wrote:
| Quote: | Well i made some rules for myself but was wondering how do you name the
controls you use very often also in code.
for example think of thousand of checkboxes,everyone related to specific
task.
do you preserver checkbox1,checkbox2 names or changed them.
my rule was "chk" at first of name and then their functionality
afterwards for example "chkShowTips".
i was wondering if any rules exist or something make them easier to use?
regards
|
--
Software for resource managers and researchers
www.ecostats.com |
|
| Back to top |
|
 |
Ramona van Riet Guest
|
Posted: Sun Mar 19, 2006 11:03 am Post subject: Re: how do you name the controls? |
|
|
Om 10:38:26 uur, 19.03.2006, schreef Ben Hochstrasser:
| Quote: | roozbeh wrote:
my rule was "chk" at first of name and then their functionality
afterwards for example "chkShowTips".
I always rename them, name prepended with the type of control, like
cbLocation or chkActive or lstCountry. (Same with other variables such
as sFullName or iCount).
|
I like the opposite. I like names like LocationCheck, ActiveCheck or
CountryListBox. This allows me to group items together by name, and not
by type: CountryLabel, CountryCaption, CountryListBox, CountryButton;
LocationCheck, LocationEdit, LocationLabel.
--
Ramona |
|
| Back to top |
|
 |
Ottar Holstad Guest
|
Posted: Sun Mar 19, 2006 11:03 am Post subject: Re: how do you name the controls? |
|
|
| Quote: | do you preserver checkbox1,checkbox2 names or changed them.
|
I only change the name if I refer to the control in my code. So, by default
I don't change the name, but the first time i refer to it I change the it. I
put a suffix on the name, and it's usally either
- FRM (for forms - when put as a suffix the name of the unit and the form
will start the same, which is often convinient)
- EDT (for any kind of edit control, both memo's and db-aware)
- LBL
- CHK
- CBO
- QRY (any kind of database query)
- SRC (for TDataSource)
- ??? |
|
| Back to top |
|
 |
Ben Hochstrasser Guest
|
Posted: Sun Mar 19, 2006 11:03 am Post subject: Re: how do you name the controls? |
|
|
roozbeh wrote:
| Quote: | my rule was "chk" at first of name and then their functionality
afterwards for example "chkShowTips".
|
I always rename them, name prepended with the type of control, like
cbLocation or chkActive or lstCountry. (Same with other variables such as
sFullName or iCount).
There's one exception, though: when I post a code snippet here, the
procedure nearly always is "TForm1.Button1Click". :)
--
Ben |
|
| Back to top |
|
 |
Larry Killen Guest
|
Posted: Sun Mar 19, 2006 4:03 pm Post subject: Re: how do you name the controls? |
|
|
Not to get too far off topic but VB does have one thing that I wish Delphi
had. Namely indexed controls.
If you add twenty Check Boxes to a form, upon adding the 2nd, VB will offer
to index the remaining.
I have been porting multiple VB 6 apps into Delphi and have not been able to
even imatate this functionality, especially when I want to reference 2 or 3
different controls across forms, lock step. But it also mitigates the
naming issue, somewhat.
"K. Sallee" <nonomail (AT) nonono (DOT) net> wrote in message
news:ops6nnbc0by914ox (AT) ecologsoft (DOT) ecologicalsoftwaresolutions.office...
| Quote: |
my rule was "chk"
Always rename, never use Hungarian notation.
Kevin |
|
|
| Back to top |
|
 |
Robert Giesecke Guest
|
Posted: Sun Mar 19, 2006 5:03 pm Post subject: Re: how do you name the controls? |
|
|
Ben Hochstrasser wrote:
| Quote: |
Do your variables fit into that scheme too? Like "CountInteger" etc?
|
Why should it be necessary to encrypt the type into a variable name?
When reading code, in 99% it should made no difference what type a
variable is.
Of course one should use plural for containers.
For understanding the code in a method it is even uninteresting if Count
was a local var or a property. But it is most likely of a numeric type.
Your IDE will give you the exact type and declaration as a tool tip if
you really need it.  |
|
| Back to top |
|
 |
Jim Cooper Guest
|
Posted: Sun Mar 19, 2006 5:03 pm Post subject: Re: how do you name the controls? |
|
|
| Quote: | my rule was "chk" at first of name and then their functionality
afterwards for example "chkShowTips".
|
I always do it the other way around and use a proper word (eg ShowTipsCheckBox),
because Hungarian Notation is evil.
In the .NET world, compliance tools like FxCop will actually find such names and
complain about them.
Cheers,
Jim Cooper
_____________________________________________
Jim Cooper jcooper (AT) tabdee (DOT) ltd.uk
Skype : jim.cooper
Tabdee Ltd http://www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
_____________________________________________ |
|
| Back to top |
|
 |
Robert Giesecke Guest
|
Posted: Sun Mar 19, 2006 5:03 pm Post subject: Re: how do you name the controls? |
|
|
Jim Cooper wrote:
| Quote: |
my rule was "chk" at first of name and then their functionality
afterwards for example "chkShowTips".
I always do it the other way around and use a proper word (eg
ShowTipsCheckBox), because Hungarian Notation is evil.
|
Hmpf? There are really people here to share my preference for the .Net
API guidelines? :-)
| Quote: |
In the .NET world, compliance tools like FxCop will actually find such
names and complain about them.
|
The other (more important) reason might be, that a real word is faster
to read than an encrypted one.  |
|
| Back to top |
|
 |
Peter Morris [Droopy eyes Guest
|
Posted: Sun Mar 19, 2006 5:03 pm Post subject: Re: how do you name the controls? |
|
|
I used to use chk (CheckBox) cb (ComboBox) btn (Button) etc.
I find though that the purpose is much easier to find when looking through
the list in the object inspector.
NameLabel, NameEdit, NameButton - that way I can easily find components
linked to the "Name" part of my GUI. |
|
| Back to top |
|
 |
Ben Hochstrasser Guest
|
Posted: Sun Mar 19, 2006 5:03 pm Post subject: Re: how do you name the controls? |
|
|
Ramona van Riet wrote:
| Quote: | I like the opposite. I like names like LocationCheck, ActiveCheck or
CountryListBox. This allows me to group items together by name, and not
by type: CountryLabel, CountryCaption, CountryListBox, CountryButton;
LocationCheck, LocationEdit, LocationLabel.
|
Do your variables fit into that scheme too? Like "CountInteger" etc?
--
Ben |
|
| Back to top |
|
 |
Jim Cooper Guest
|
Posted: Sun Mar 19, 2006 5:03 pm Post subject: Re: how do you name the controls? |
|
|
| Quote: | I have been porting multiple VB 6 apps into Delphi and have not been able to
even imatate this functionality
|
You might be able to make use of the Controls and/or Components properties of
forms and certain other controls.
Cheers,
Jim Cooper
_____________________________________________
Jim Cooper jcooper (AT) tabdee (DOT) ltd.uk
Skype : jim.cooper
Tabdee Ltd http://www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
_____________________________________________ |
|
| 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
|
|