BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how do you name the controls?
Goto page 1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Non-Technical
View previous topic :: View next topic  
Author Message
roozbeh
Guest





PostPosted: Sun Mar 19, 2006 10:03 am    Post subject: how do you name the controls? Reply with 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
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Back to top
Bryce K. Nielsen
Guest





PostPosted: Sun Mar 19, 2006 10:03 am    Post subject: Re: how do you name the controls? Reply with quote



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





PostPosted: Sun Mar 19, 2006 11:03 am    Post subject: Re: how do you name the controls? Reply with quote



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





PostPosted: Sun Mar 19, 2006 11:03 am    Post subject: Re: how do you name the controls? Reply with quote

Quote:
my rule was "chk"

Always rename, never use Hungarian notation.

Kevin
Back to top
K. Sallee
Guest





PostPosted: Sun Mar 19, 2006 11:03 am    Post subject: Re: how do you name the controls? Reply with quote

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





PostPosted: Sun Mar 19, 2006 11:03 am    Post subject: Re: how do you name the controls? Reply with quote

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





PostPosted: Sun Mar 19, 2006 11:03 am    Post subject: Re: how do you name the controls? Reply with quote

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





PostPosted: Sun Mar 19, 2006 11:03 am    Post subject: Re: how do you name the controls? Reply with quote

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





PostPosted: Sun Mar 19, 2006 4:03 pm    Post subject: Re: how do you name the controls? Reply with quote

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





PostPosted: Sun Mar 19, 2006 5:03 pm    Post subject: Re: how do you name the controls? Reply with quote

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. Wink
Back to top
Jim Cooper
Guest





PostPosted: Sun Mar 19, 2006 5:03 pm    Post subject: Re: how do you name the controls? Reply with quote

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





PostPosted: Sun Mar 19, 2006 5:03 pm    Post subject: Re: how do you name the controls? Reply with quote

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. Razz
Back to top
Peter Morris [Droopy eyes
Guest





PostPosted: Sun Mar 19, 2006 5:03 pm    Post subject: Re: how do you name the controls? Reply with quote

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





PostPosted: Sun Mar 19, 2006 5:03 pm    Post subject: Re: how do you name the controls? Reply with quote

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





PostPosted: Sun Mar 19, 2006 5:03 pm    Post subject: Re: how do you name the controls? Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Non-Technical All times are GMT
Goto page 1, 2, 3, 4, 5, 6  Next
Page 1 of 6

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.