Greetings,
I am posting this message to both the SQL Server and C# news groups
because this inquiry is more of a theoretical question that applies to both
database and code naming conventions.
I have currently been prefixing boolean object properties and database
columns with Is .. for example (defining a CAT being declawed): IsDeclawed.
Well, the prefix of Is doesn't always work ... for example: IsHasWiskers ..
well, that doesn't really sound all that great. Also, IsUsesLitterBox .
that doesn't sound good either.
So what I'm asking the development community is what are the standard naming
conventions for boolean fields?
Thanks for your time. 38 12862
why not leave the "question" out of the name.
IsDeclawed goes to Declawed <True-False> <1-0>
DoesHaveWiskers goes to HasWiskers <True-False> <1-0>
DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0>
am i missing something? why imply datattype in the name?
news.microsoft.com wrote: Greetings, I am posting this message to both the SQL Server and C# news groups because this inquiry is more of a theoretical question that applies to both database and code naming conventions.
I have currently been prefixing boolean object properties and database columns with Is .. for example (defining a CAT being declawed): IsDeclawed. Well, the prefix of Is doesn't always work ... for example: IsHasWiskers .. well, that doesn't really sound all that great. Also, IsUsesLitterBox . that doesn't sound good either.
So what I'm asking the development community is what are the standard naming conventions for boolean fields?
Thanks for your time.
I generally name bit fields in sql as Yes Or No Questions
IsDeadAsAStick
NeedsToBeSlapped
HasToBeDeaf
MustBeRotten
etc etc etc
Greg Jackson
PDX, Oregon
Josh,
What I'm trying to achieve is to get a set few prefixes that can address
all boolean scenarios. Try to keep everything clean.. One person told me
to try to use just:
Is
Has
but that doesn't address them all. Trying to keep things standardized.
"Josh Golden" <jo***@wachovia.com> wrote in message
news:40***********************@news.twtelecom.net. .. why not leave the "question" out of the name.
IsDeclawed goes to Declawed <True-False> <1-0> DoesHaveWiskers goes to HasWiskers <True-False> <1-0> DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0>
am i missing something? why imply datattype in the name? news.microsoft.com wrote: Greetings, I am posting this message to both the SQL Server and C# news groups because this inquiry is more of a theoretical question that applies to both database and code naming conventions.
I have currently been prefixing boolean object properties and database columns with Is .. for example (defining a CAT being declawed): IsDeclawed. Well, the prefix of Is doesn't always work ... for example: IsHasWiskers .. well, that doesn't really sound all that great. Also, IsUsesLitterBox . that doesn't sound good either.
So what I'm asking the development community is what are the standard naming conventions for boolean fields?
Thanks for your time.
"Josh Golden" <jo***@wachovia.com> wrote in message
news:40***********************@news.twtelecom.net. .. why not leave the "question" out of the name.
IsDeclawed goes to Declawed <True-False> <1-0> DoesHaveWiskers goes to HasWiskers <True-False> <1-0> DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0>
am i missing something? why imply datattype in the name?
I like implication of boolean types in the name as it allows one to ask
a question of an object:
if (......)
Cat.UsesLitterBox
Cat.IsDeclawed
Cat.HasWhiskers
So: if Cat Uses Litter Box, do X... if Cat Is Declawed, do Y... etc.
It would make no sense to ask:
if Cat.LitterBox //Is this a reference to a litterbox object?
or if Cat Declawed //was this written by someone who is just learning
English? :)
Finally, is not in the same form as UsesLitterBox (verb-noun or
verb-adjective); in my opinion the most important aspect of any naming
scheme is consistency. So if you're going to prefix one boolean with a
verb, prefix all of them with a verb.
ok. do you prefix every database column with the data type?
text_comments
varchar20_customer_name
string_customer_name
intGreaterThanZero_customer_number
it seems weird to me.
customer_number
shipping_comments
balance_due
room_id
employee_extension
currently_employed
married
pack_slip_number
pack_slip_code
all are fairly clear on the data type without saying it. i don't know. i'm
not picking on you. i don't like to do that with names.
i don't like to say
t_customer
table_customer
tblCustomer
v_customers
view_customers
etc.
for a view maybe - "customers" where the underlying table is "customer"
news.microsoft.com wrote: Josh, What I'm trying to achieve is to get a set few prefixes that can address all boolean scenarios. Try to keep everything clean.. One person told me to try to use just:
Is Has
but that doesn't address them all. Trying to keep things standardized. "Josh Golden" <jo***@wachovia.com> wrote in message news:40***********************@news.twtelecom.net. .. why not leave the "question" out of the name.
IsDeclawed goes to Declawed <True-False> <1-0> DoesHaveWiskers goes to HasWiskers <True-False> <1-0> DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0>
am i missing something? why imply datattype in the name? news.microsoft.com wrote: Greetings, I am posting this message to both the SQL Server and C# news groups because this inquiry is more of a theoretical question that applies to both database and code naming conventions.
I have currently been prefixing boolean object properties and database columns with Is .. for example (defining a CAT being declawed): IsDeclawed. Well, the prefix of Is doesn't always work ... for example: IsHasWiskers .. well, that doesn't really sound all that great. Also, IsUsesLitterBox . that doesn't sound good either.
So what I'm asking the development community is what are the standard naming conventions for boolean fields?
Thanks for your time.
ok - you are singling out OOP it looks. and the OP is trying to apply a
consistent naming convention across the db and a programming language. i
don't view them the same. i was more targeting sql naming convention.
in OOP i do just as you have explained. in sql, i do as I have explained.
Adam Machanic wrote: "Josh Golden" <jo***@wachovia.com> wrote in message news:40***********************@news.twtelecom.net. .. why not leave the "question" out of the name.
IsDeclawed goes to Declawed <True-False> <1-0> DoesHaveWiskers goes to HasWiskers <True-False> <1-0> DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0>
am i missing something? why imply datattype in the name?
I like implication of boolean types in the name as it allows one to ask a question of an object:
if (......) Cat.UsesLitterBox Cat.IsDeclawed Cat.HasWhiskers
So: if Cat Uses Litter Box, do X... if Cat Is Declawed, do Y... etc.
It would make no sense to ask:
if Cat.LitterBox //Is this a reference to a litterbox object?
or if Cat Declawed //was this written by someone who is just learning English? :)
Finally, is not in the same form as UsesLitterBox (verb-noun or verb-adjective); in my opinion the most important aspect of any naming scheme is consistency. So if you're going to prefix one boolean with a verb, prefix all of them with a verb.
> if Cat.LitterBox //Is this a reference to a litterbox object?
Well, when you map this column in the resultset to a variable in an OOP
language, okay.
But as a column name, I don't think the Is or Has adds anything. You still
can't say WHERE Cat.IsDeclawed, you have to say WHERE Cat.IsDeclawed = 1.
So it's not even really a boolean / true/false / etc. At best, to be a
truly compatible boolean, you would have a function that returns True or
False, and use it like WHERE IsTrue(Cat.Declawed)???
-- http://www.aspfaq.com/
(Reverse address to reply.)
Adam,
So basically, as a rule of thumb, all boolean fields / proerties /
columns should be able to fall in to IS, HAS, or USES ...
I think I posted this question all goofy because a lot of reponses are
referring to T-SQL syntax. This was more of a theroritcal naming convention
question.
Thanks for all of the reponses.
Jay
"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
news:uK**************@TK2MSFTNGP11.phx.gbl... "Josh Golden" <jo***@wachovia.com> wrote in message news:40***********************@news.twtelecom.net. .. why not leave the "question" out of the name.
IsDeclawed goes to Declawed <True-False> <1-0> DoesHaveWiskers goes to HasWiskers <True-False> <1-0> DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0>
am i missing something? why imply datattype in the name?
I like implication of boolean types in the name as it allows one to
ask a question of an object:
if (......) Cat.UsesLitterBox Cat.IsDeclawed Cat.HasWhiskers
So: if Cat Uses Litter Box, do X... if Cat Is Declawed, do Y... etc.
It would make no sense to ask:
if Cat.LitterBox //Is this a reference to a litterbox object?
or if Cat Declawed //was this written by someone who is just learning English? :)
Finally, is not in the same form as UsesLitterBox (verb-noun or verb-adjective); in my opinion the most important aspect of any naming scheme is consistency. So if you're going to prefix one boolean with a verb, prefix all of them with a verb.
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:OG**************@TK2MSFTNGP12.phx.gbl... But as a column name, I don't think the Is or Has adds anything. You
still can't say WHERE Cat.IsDeclawed, you have to say WHERE Cat.IsDeclawed = 1. So it's not even really a boolean / true/false / etc. At best, to be a truly compatible boolean, you would have a function that returns True or False, and use it like WHERE IsTrue(Cat.Declawed)???
I agree, it doesn't add anything to a column name. I was referring to
class member naming...
In SQL, were there a boolean datatype, I would actually like it to be
able to resolve to true without a function, so you'd be able to just write:
SELECT *
FROM Cat
WHERE Cat.IsDeclawed
That would create a much nicer mapping between the two worlds in terms
of boolean... And in that case the 'Is' would add something to the column
name :)
"Jay Douglas" <ja****************@squarei.com> wrote in message
news:Oc**************@TK2MSFTNGP12.phx.gbl... Adam,
So basically, as a rule of thumb, all boolean fields / proerties / columns should be able to fall in to IS, HAS, or USES ...
While its possible, if your using code that will have to exist with thh
greater .NET community, you should *not* use Is on properties(the general
consensus seems to be that Is fits methods, not properties) and should use
Has or Can only when nessecery; for the most part no prefix is used at all.
For internal code you can probably get away with prefixing your properties,
but it doesn't stand up to the standards imposed by the framework or design
guidelines. I think I posted this question all goofy because a lot of reponses are referring to T-SQL syntax. This was more of a theroritcal naming convention question.
Thanks for all of the reponses.
Jay
"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message news:uK**************@TK2MSFTNGP11.phx.gbl... "Josh Golden" <jo***@wachovia.com> wrote in message news:40***********************@news.twtelecom.net. .. > why not leave the "question" out of the name. > > IsDeclawed goes to Declawed <True-False> <1-0> > DoesHaveWiskers goes to HasWiskers <True-False> <1-0> > DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0> > > am i missing something? why imply datattype in the name?
I like implication of boolean types in the name as it allows one to
ask a question of an object:
if (......) Cat.UsesLitterBox Cat.IsDeclawed Cat.HasWhiskers
So: if Cat Uses Litter Box, do X... if Cat Is Declawed, do Y... etc.
It would make no sense to ask:
if Cat.LitterBox //Is this a reference to a litterbox object?
or if Cat Declawed //was this written by someone who is just learning English? :)
Finally, is not in the same form as UsesLitterBox (verb-noun or verb-adjective); in my opinion the most important aspect of any naming scheme is consistency. So if you're going to prefix one boolean with a verb, prefix all of them with a verb.
> I agree, it doesn't add anything to a column name. I was referring to class member naming...
Oh, I didn't know we were talking about that. Suppose I shouldn't jump in
mid-thread. ;-)
In SQL, were there a boolean datatype, I would actually like it to be able to resolve to true without a function, so you'd be able to just
write: SELECT * FROM Cat WHERE Cat.IsDeclawed
Yes of course, ideally. But there's not, so you wouldn't name your column
that way. ;-)
-- http://www.aspfaq.com/
(Reverse address to reply.)
"Jay Douglas" <ja****************@squarei.com> wrote in message
news:Oc**************@TK2MSFTNGP12.phx.gbl... So basically, as a rule of thumb, all boolean fields / proerties / columns should be able to fall in to IS, HAS, or USES ...
For objects, use verbs. As other posters have pointed out, it's probably
better to not use verbs/imply data type in a database (I was referring only
to objects in my post).
I believe that the following list of verbs would be sufficient for all
possible cases:
CAN
COULD
DID
DOES
IS
HAS
HAD
MAY
MIGHT
MUST
SHALL
SHOULD
WAS
WILL
WOULD
Daniel,
Do you have a link for Microsoft's suggested C# naming conventions?
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:eV**************@TK2MSFTNGP10.phx.gbl... For internal code you can probably get away with prefixing your
properties, but it doesn't stand up to the standards imposed by the framework or
design guidelines.
I think that giving the name something meaningful to suggest Yes/No values
has merit.
he is not suggesting naming these things blnHasChoppers That would TRUELY
Suck
GAJ
Daniel,
You have spawn an interesting concept ... has the FCL uses Is and Has in
various different properties .. (i.e. a DataTable has a property of HasRows
which is a boolean property) .. This is some awesome information and I would
like to adhear to the standards ... whatever those may be. As Adam
requested, I would be very interested in looking at a link or Microsoft
provided document.
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:eV**************@TK2MSFTNGP10.phx.gbl... "Jay Douglas" <ja****************@squarei.com> wrote in message news:Oc**************@TK2MSFTNGP12.phx.gbl... Adam,
So basically, as a rule of thumb, all boolean fields / proerties / columns should be able to fall in to IS, HAS, or USES ... While its possible, if your using code that will have to exist with thh greater .NET community, you should *not* use Is on properties(the general consensus seems to be that Is fits methods, not properties) and should use Has or Can only when nessecery; for the most part no prefix is used at
all. For internal code you can probably get away with prefixing your
properties, but it doesn't stand up to the standards imposed by the framework or
design guidelines.
I think I posted this question all goofy because a lot of reponses are referring to T-SQL syntax. This was more of a theroritcal naming convention question.
Thanks for all of the reponses.
Jay
"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message news:uK**************@TK2MSFTNGP11.phx.gbl... "Josh Golden" <jo***@wachovia.com> wrote in message news:40***********************@news.twtelecom.net. .. > why not leave the "question" out of the name. > > IsDeclawed goes to Declawed <True-False> <1-0> > DoesHaveWiskers goes to HasWiskers <True-False> <1-0> > DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0> > > am i missing something? why imply datattype in the name?
I like implication of boolean types in the name as it allows one to
ask a question of an object:
if (......) Cat.UsesLitterBox Cat.IsDeclawed Cat.HasWhiskers
So: if Cat Uses Litter Box, do X... if Cat Is Declawed, do Y...
etc. It would make no sense to ask:
if Cat.LitterBox //Is this a reference to a litterbox object?
or if Cat Declawed //was this written by someone who is just
learning English? :)
Finally, is not in the same form as UsesLitterBox (verb-noun or verb-adjective); in my opinion the most important aspect of any naming scheme is consistency. So if you're going to prefix one boolean with a verb, prefix all of them with a verb.
"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl... Daniel,
Do you have a link for Microsoft's suggested C# naming conventions?
Here are a few. I'm pretty sure there is a single page with a table
containing most of these suggestions, but I can't remember what it is.
relevent to properties specifically: http://msdn.microsoft.com/library/de...guidelines.asp
Note that it suggests naming properties with nouns or noun prhases, not
verbs or verb phrases. Keeping verbs out of properties is generally
prefferable(I would break the is rule, for example, only to keep from naming
a field one of the reserved words, ie instead of Short I'd probably call it
IsShort). Some examples in the BCL use Can and Has, though I can't think of
an instance of Is.
This is only a smattering of the preferences, there is quite alot of
community discussion over proper conventions. I'll post links when I come
across them, dont have time right now to crawl blogs and newsgroups to find
them, ;).
The general guidelines: http://msdn.microsoft.com/library/de...guidelines.asp
Hopefully someone will be able to provide a link. I'm pretty sure atleast
one person here has the tinyurl memorized by now.
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in message news:eV**************@TK2MSFTNGP10.phx.gbl... For internal code you can probably get away with prefixing your
properties, but it doesn't stand up to the standards imposed by the framework or design guidelines.
This isn't directed towards you Josh, just an expansion on your comments.
We don't use bit fields, to signify a boolean value, we use varchar(1) with
Y/N. (char(1) would also work...)
For example:
IsDeclawed goes to DeclawedFg (true-false) (Y-N)
DoesHaveWiskers goes to HasWiskersFg or WiskersFg (true-false) (Y-N)
DoesUseLitterBox goes to UsesLitterBoxFg or LitterBoxFg (true-false) (Y-N)
Basically the "Fg" signifies a Y/N field. Might not be the best way but it
works.
But of course the database doesn't care about what it is named. It is only
for the programmers.
"Josh Golden" <jo***@wachovia.com> wrote in message
news:40***********************@news.twtelecom.net. .. why not leave the "question" out of the name.
IsDeclawed goes to Declawed <True-False> <1-0> DoesHaveWiskers goes to HasWiskers <True-False> <1-0> DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0>
am i missing something? why imply datattype in the name? news.microsoft.com wrote: Greetings, I am posting this message to both the SQL Server and C# news groups because this inquiry is more of a theoretical question that applies to both database and code naming conventions.
I have currently been prefixing boolean object properties and database columns with Is .. for example (defining a CAT being declawed): IsDeclawed. Well, the prefix of Is doesn't always work ... for example: IsHasWiskers .. well, that doesn't really sound all that great. Also, IsUsesLitterBox . that doesn't sound good either.
So what I'm asking the development community is what are the standard naming conventions for boolean fields?
Thanks for your time.
"Jay Douglas" <ja****************@squarei.com> wrote in message
news:OG*************@TK2MSFTNGP10.phx.gbl... Daniel, You have spawn an interesting concept ... has the FCL uses Is and Has in various different properties .. (i.e. a DataTable has a property of HasRows which is a boolean property) .. This is some awesome information and I would like to adhear to the standards ... whatever those may be. As Adam requested, I would be very interested in looking at a link or Microsoft provided document.
Is, Has, and Can are pretty common I think. There was a discussion about it
at [1], and I seem to recall a few other instances(I"ll have to look it up).
Is is an example of things that are not covered in the guidelines but by
more community consensus. When I wrote my original response I did think that
Brad Abrams had mentinoed a modification to the design guidelines, but I
can't seem to find that anywhere, so it seems I was mistaken in that
respect.
1. http://blogs.msdn.com/brada/archive/.../16/74563.aspx "Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in message news:eV**************@TK2MSFTNGP10.phx.gbl... "Jay Douglas" <ja****************@squarei.com> wrote in message news:Oc**************@TK2MSFTNGP12.phx.gbl... > Adam, > > So basically, as a rule of thumb, all boolean fields / proerties / > columns should be able to fall in to IS, HAS, or USES ...
While its possible, if your using code that will have to exist with thh greater .NET community, you should *not* use Is on properties(the general consensus seems to be that Is fits methods, not properties) and should use Has or Can only when nessecery; for the most part no prefix is used at
all. For internal code you can probably get away with prefixing your
properties, but it doesn't stand up to the standards imposed by the framework or design guidelines.
> > I think I posted this question all goofy because a lot of reponses are > referring to T-SQL syntax. This was more of a theroritcal naming > convention > question. > > Thanks for all of the reponses. > > Jay > > > "Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in > message > news:uK**************@TK2MSFTNGP11.phx.gbl... >> >> "Josh Golden" <jo***@wachovia.com> wrote in message >> news:40***********************@news.twtelecom.net. .. >> > why not leave the "question" out of the name. >> > >> > IsDeclawed goes to Declawed <True-False> <1-0> >> > DoesHaveWiskers goes to HasWiskers <True-False> <1-0> >> > DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0> >> > >> > am i missing something? why imply datattype in the name? >> >> >> I like implication of boolean types in the name as it allows one >> to > ask >> a question of an object: >> >> if (......) >> Cat.UsesLitterBox >> Cat.IsDeclawed >> Cat.HasWhiskers >> >> So: if Cat Uses Litter Box, do X... if Cat Is Declawed, do Y... etc. >> >> It would make no sense to ask: >> >> if Cat.LitterBox //Is this a reference to a litterbox object? >> >> or if Cat Declawed //was this written by someone who is just learning >> English? :) >> >> Finally, is not in the same form as UsesLitterBox (verb-noun or >> verb-adjective); in my opinion the most important aspect of any naming >> scheme is consistency. So if you're going to prefix one boolean with >> a >> verb, prefix all of them with a verb. >> >> >> > >
"Daniel Jin" <Da*******@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com... While its possible, if your using code that will have to exist with thh greater .NET community, you should *not* use Is on properties(the general consensus seems to be that Is fits methods, not properties) and should use Has or Can only when nessecery; for the most part no prefix is used at all.
if you look at BCL, there are quite a few examples of bool properties prefixed with is. If MS uses it, it's good enough for me. :)
They make mistakes too. I think Is probably was one, especially inlight of
languages like VB where IsXxx() fuctions are exceedingly common. There are
just to many uses of the word. IsXxx functions, IsXxx Properties, IsXxx
methods, etc.
I could probably spend the rest of the month picking about minor bits in the
BCL that don't fit the naming guidelines if I wanted to. That doesn't mean I
would use any one of them just because Microsoft did.
I use all of these except
MIGHT
MAY
MUST
SHALL
WOULD
Might is too non-deterministic, May is replaced by Can (although
gramatically this is backweards) and Must is replaced by Will or Should
JIM
"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl... "Jay Douglas" <ja****************@squarei.com> wrote in message news:Oc**************@TK2MSFTNGP12.phx.gbl... So basically, as a rule of thumb, all boolean fields / proerties / columns should be able to fall in to IS, HAS, or USES ... For objects, use verbs. As other posters have pointed out, it's probably better to not use verbs/imply data type in a database (I was referring
only to objects in my post).
I believe that the following list of verbs would be sufficient for all possible cases:
CAN COULD DID DOES IS HAS HAD MAY MIGHT MUST SHALL SHOULD WAS WILL WOULD
Yuck ! why not simply use bit. ?? I mean if it is only for the
programmers then a bit 1 or 0 makes more sense
Theoretically a Char(1) can contain other characters beside Y or N so now
you need all kinds of overhead to verify data integrity
JIM
"Steve Beach"
<(RE-M0V3)steveb@path(RE-M0V3)guide.com(RE-M0VE--THE-REST)no****@sp4m.com>
wrote in message news:ux**************@TK2MSFTNGP12.phx.gbl... This isn't directed towards you Josh, just an expansion on your comments.
We don't use bit fields, to signify a boolean value, we use varchar(1)
with Y/N. (char(1) would also work...)
For example:
IsDeclawed goes to DeclawedFg (true-false) (Y-N) DoesHaveWiskers goes to HasWiskersFg or WiskersFg (true-false) (Y-N) DoesUseLitterBox goes to UsesLitterBoxFg or LitterBoxFg (true-false)
(Y-N) Basically the "Fg" signifies a Y/N field. Might not be the best way but
it works.
But of course the database doesn't care about what it is named. It is
only for the programmers.
"Josh Golden" <jo***@wachovia.com> wrote in message news:40***********************@news.twtelecom.net. .. why not leave the "question" out of the name.
IsDeclawed goes to Declawed <True-False> <1-0> DoesHaveWiskers goes to HasWiskers <True-False> <1-0> DoesUseLitterBox goes to UsesLitterBox <True-False> <1-0>
am i missing something? why imply datattype in the name? news.microsoft.com wrote: Greetings, I am posting this message to both the SQL Server and C# news groups because this inquiry is more of a theoretical question that applies to both database and code naming conventions.
I have currently been prefixing boolean object properties and database columns with Is .. for example (defining a CAT being declawed): IsDeclawed. Well, the prefix of Is doesn't always work ... for example: IsHasWiskers .. well, that doesn't really sound all that great. Also, IsUsesLitterBox . that doesn't sound good either.
So what I'm asking the development community is what are the standard naming conventions for boolean fields?
Thanks for your time.
> Yuck ! why not simply use bit. ?? I mean if it is only for the programmers then a bit 1 or 0 makes more sense
It's NOT always for the programmers. Bean-counters, slack-jaws, etc. don't
know what 1 and 0 mean. Y or N (or T or F) often make more sense to them.
And yes, you could do this with views, but that might mean a lot of extra
code, depending on how many such columns you have.
Theoretically a Char(1) can contain other characters beside Y or N so now you need all kinds of overhead to verify data integrity
You also need this on BIT if you don't want to allow NULL; I don't see a
huge difference here, except the constraint is slightly different.
-- http://www.aspfaq.com/
(Reverse address to reply.)
A CHECK (val in ('Y', 'N')) constraint won't cause much overhead.
BIT has other issues, e.g. it can't be included in an index.
"james" <no****@hypercon.net> wrote in message
news:Ol**************@TK2MSFTNGP09.phx.gbl... Yuck ! why not simply use bit. ?? I mean if it is only for the programmers then a bit 1 or 0 makes more sense
Theoretically a Char(1) can contain other characters beside Y or N so now you need all kinds of overhead to verify data integrity
JIM
>> why not simply use bit. ?? <<
Because in t-SQL, bit datatype has nothing in common with a univeral boolean
datatype. Bit has numeric values while boolean has logical values.
Implication operations require explicit assignments when a numerical value
is treated like a logical value. so now you need all kinds of overhead to verify data integrity <<
In t-SQL, simple CHECK constraint would do.
--
Anith
> BIT has other issues, e.g. it can't be included in an index.
It can (Enterprise Manager won't allow you to choose a BIT column in its
cumbersome index gui, but Query Analyzer will allow you to run a manual
CREATE INDEX).
However, due to cardinality, it would be no more useful than an index on a
CHAR(1) column, where the values must be IN ('Y', 'N').
-- http://www.aspfaq.com/
(Reverse address to reply.)
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl... BIT has other issues, e.g. it can't be included in an index. It can (Enterprise Manager won't allow you to choose a BIT column in its cumbersome index gui, but Query Analyzer will allow you to run a manual CREATE INDEX).
Thanks for the clarification. I stopped implementing BIT columns around
the same time I stopped using EM :)
However, due to cardinality, it would be no more useful than an index on a CHAR(1) column, where the values must be IN ('Y', 'N').
Even an index on a CHAR(1) column could be useful if either the number
of 'Y' or 'N' occurrences was fairly sparse...
> > However, due to cardinality, it would be no more useful than an index on
a CHAR(1) column, where the values must be IN ('Y', 'N').
Even an index on a CHAR(1) column could be useful if either the number of 'Y' or 'N' occurrences was fairly sparse...
Right, about the same (or "no more useful") as an index on BIT, if either
the number of 0 or 1 occurences was fairly sparse.
I didn't say the index would always be useless, just that in most cases it
is, and that even if BIT couldn't take an index, that wouldn't be a con in
most cases, because the index would only be used in very extreme
circumstances.
A
"Daniel O'Connell [C# MVP]" wrote: "Daniel Jin" wrote:
if you look at BCL, there are quite a few examples of bool properties prefixed with is. If MS uses it, it's good enough for me. :) They make mistakes too. I think Is probably was one, especially inlight of languages like VB where IsXxx() fuctions are exceedingly common. There are just to many uses of the word. IsXxx functions, IsXxx Properties, IsXxx methods, etc.
Well, this is an interesting issue for me. I'm designing a .NET
tookit, and I want to get things right since it will hopefully be
used by a large number of .NET programmers.
My take on this is the following: IsXXX is a query about an object's
state. You are not accessing an object's state directly, rather you
are asking the object to tell you about its state. That doesn't feel
like a property to me. It would seem more natural to make the query
into a method, IMO.
On the other hand, I've seen lots of IsXXX properties in the .NET
framework. For example, the TextBox class has the IsAccessible,
IsDisposed, and IsHandleCreated properties. So I'm torn as a
designer from doing what seems most elegant and natural to me, to
doing what seems to be standard within .NET, at least the parts of
..NET I'm familiar with.
That doesn't mean I would use any one of them just because Microsoft did.
Your point is well taken. I will give this some thought.
Wavemaker, no you are not only asking its state you are setting its state.
i.e. Get IsActive, and Set IsActive
i.e. Employee.IsActive = false
and
if ( Employee.IsActive ) ...
JIM
"Wavemaker" <ja**********@BiteMeHotmail.com> wrote in message
news:QO********************@comcast.com... "Daniel O'Connell [C# MVP]" wrote: "Daniel Jin" wrote:
if you look at BCL, there are quite a few examples of bool properties prefixed with is. If MS uses it, it's good enough for me. :)
They make mistakes too. I think Is probably was one, especially inlight of languages like VB where IsXxx() fuctions are exceedingly common. There are just to many uses of the word. IsXxx functions, IsXxx Properties, IsXxx methods, etc.
Well, this is an interesting issue for me. I'm designing a .NET tookit, and I want to get things right since it will hopefully be used by a large number of .NET programmers.
My take on this is the following: IsXXX is a query about an object's state. You are not accessing an object's state directly, rather you are asking the object to tell you about its state. That doesn't feel like a property to me. It would seem more natural to make the query into a method, IMO.
On the other hand, I've seen lots of IsXXX properties in the .NET framework. For example, the TextBox class has the IsAccessible, IsDisposed, and IsHandleCreated properties. So I'm torn as a designer from doing what seems most elegant and natural to me, to doing what seems to be standard within .NET, at least the parts of .NET I'm familiar with.
That doesn't mean I would use any one of them just because Microsoft did.
Your point is well taken. I will give this some thought.
Ok, so then what if your target audience is non-English, maybe they
understand Da and Nyet ? So now they are all confused aboiut this Y / N
thingy when it really should be D and N, duh ! I guess in my opinion if
people can't understand 1 and 0 they probably shouldn't be accessing the
database at all. As a db Admin that would make me very nervous.
JIM
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:Oq**************@TK2MSFTNGP12.phx.gbl... Yuck ! why not simply use bit. ?? I mean if it is only for the programmers then a bit 1 or 0 makes more sense It's NOT always for the programmers. Bean-counters, slack-jaws, etc.
don't know what 1 and 0 mean. Y or N (or T or F) often make more sense to them. And yes, you could do this with views, but that might mean a lot of extra code, depending on how many such columns you have.
Theoretically a Char(1) can contain other characters beside Y or N so
now you need all kinds of overhead to verify data integrity
You also need this on BIT if you don't want to allow NULL; I don't see a huge difference here, except the constraint is slightly different.
-- http://www.aspfaq.com/ (Reverse address to reply.)
> Ok, so then what if your target audience is non-English, maybe they understand Da and Nyet ? So now they are all confused aboiut this Y / N thingy when it really should be D and N, duh ! I guess in my opinion if people can't understand 1 and 0 they probably shouldn't be accessing the database at all. As a db Admin that would make me very nervous.
I don't think anyone said you have to use Y or N, or T or F, or D or N, or 1
or 0. I was merely trying to explain to you *WHY* some people shy away from
1 and 0.
Aaron, my response was actually more meant for Steve and the rest but I just
hit reply on your message :-) Everyone has their opinions on these things
and that's OK I suppose, as long as people understand who they are working
for and what they can get away with it all works out in the end. Its kind
of like the dangling barcket issue. I cannot stand reading code with the
opening bracket on the same line as the statement, but many if not most
developers do it that way.
JIM
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Ok, so then what if your target audience is non-English, maybe they understand Da and Nyet ? So now they are all confused aboiut this Y / N thingy when it really should be D and N, duh ! I guess in my opinion
if people can't understand 1 and 0 they probably shouldn't be accessing the database at all. As a db Admin that would make me very nervous. I don't think anyone said you have to use Y or N, or T or F, or D or N, or
1 or 0. I was merely trying to explain to you *WHY* some people shy away
from 1 and 0.
I actually don't care about which method is used; we use both Y/N and 1/0,
depending on where the flag is used. I was just giving the OP an example on
how we do it.
For example, system flags (to control behavior) that are stored in our
"database registry" that can only be changed in the registry are typically
stored as Y/N. To change one of these flags, the user changes the value
from Y to N (or reverse). Flags that can be changed via a form (checkbox)
are stored as 1/0 (vbChecked / vbUnchecked) because we read the value
direcly from the checkbox control.
As you said, whatever works (or whatever you can get away with!). Using 1
and 0 works just as well as (Y or N) or (T or F) or even (D or N)!
As for the opening bracket, I do it both ways, depending on how saucy I feel
that day. :)
Also, one reason that I don't use BIT datatype is because of Joe Celko's
unending hatred of bit fields. I believe that he calls the BIT datatype a
proprietary, non-portable datatype that is designed to suck the soul out of
the body and in order to recover you have to pay him a lot of money to
perform an exorcism. I might have paraphrased a little but I think I got the
main point across.
Steve
"james" <no****@hypercon.net> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl... Aaron, my response was actually more meant for Steve and the rest but I
just hit reply on your message :-) Everyone has their opinions on these things and that's OK I suppose, as long as people understand who they are working for and what they can get away with it all works out in the end. Its kind of like the dangling barcket issue. I cannot stand reading code with the opening bracket on the same line as the statement, but many if not most developers do it that way.
JIM
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Ok, so then what if your target audience is non-English, maybe they understand Da and Nyet ? So now they are all confused aboiut this Y /
N thingy when it really should be D and N, duh ! I guess in my opinion if people can't understand 1 and 0 they probably shouldn't be accessing
the database at all. As a db Admin that would make me very nervous. I don't think anyone said you have to use Y or N, or T or F, or D or N,
or 1 or 0. I was merely trying to explain to you *WHY* some people shy away from 1 and 0.
;-)
"Steve Beach"
<(RE-M0V3)steveb@path(RE-M0V3)guide.com(RE-M0VE--THE-REST)no****@sp4m.com>
wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... I actually don't care about which method is used; we use both Y/N and 1/0, depending on where the flag is used. I was just giving the OP an example
on how we do it.
For example, system flags (to control behavior) that are stored in our "database registry" that can only be changed in the registry are typically stored as Y/N. To change one of these flags, the user changes the value from Y to N (or reverse). Flags that can be changed via a form (checkbox) are stored as 1/0 (vbChecked / vbUnchecked) because we read the value direcly from the checkbox control.
As you said, whatever works (or whatever you can get away with!). Using 1 and 0 works just as well as (Y or N) or (T or F) or even (D or N)!
As for the opening bracket, I do it both ways, depending on how saucy I
feel that day. :)
Also, one reason that I don't use BIT datatype is because of Joe Celko's unending hatred of bit fields. I believe that he calls the BIT datatype a proprietary, non-portable datatype that is designed to suck the soul out
of the body and in order to recover you have to pay him a lot of money to perform an exorcism. I might have paraphrased a little but I think I got
the main point across.
Steve
"james" <no****@hypercon.net> wrote in message news:uA**************@TK2MSFTNGP09.phx.gbl... Aaron, my response was actually more meant for Steve and the rest but I just hit reply on your message :-) Everyone has their opinions on these
things and that's OK I suppose, as long as people understand who they are
working for and what they can get away with it all works out in the end. Its
kind of like the dangling barcket issue. I cannot stand reading code with
the opening bracket on the same line as the statement, but many if not most developers do it that way.
JIM
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... > Ok, so then what if your target audience is non-English, maybe they > understand Da and Nyet ? So now they are all confused aboiut this Y
/ N > thingy when it really should be D and N, duh ! I guess in my
opinion if > people can't understand 1 and 0 they probably shouldn't be accessing the > database at all. As a db Admin that would make me very nervous.
I don't think anyone said you have to use Y or N, or T or F, or D or
N, or 1 or 0. I was merely trying to explain to you *WHY* some people shy
away from 1 and 0.
"james" wrote: Wavemaker, no you are not only asking its state you are setting
its state. i.e. Get IsActive, and Set IsActive
i.e. Employee.IsActive = false
and
if ( Employee.IsActive ) ...
JIM
Well, you can do this, of course. But my comments were based on the
assumption that you wouldn't want to. :-) In your example, IsActive
indicates whether or not an employee is active. When you test this
property with the following:
if(anEmployee.IsActive)
You are saying if this employee *is active*, then do the
following...
The "Is" implies a query about the object's state. Naming a property
IsActive and making it writeable seems odd, like telling a question
what the answer is rather than asking a question to find the answer.
It doesn't seem semantically natural to me.
I would prefer something like this:
anEmployee.Activate();
anEmployee.Deactivate();
anEmployee.IsActive; // Read only property.
If you agree that what I've said above makes sense, then the issue
becomes whether or not to make IsActive a property or a method. I
haven't made up my mind on this, but I'm leaning towards the method
route because asking an object about its state is an action and is
better represented by a method (possibly). But I'm still thinking
about this...
A minor issue, but when you are writing a library that will possibly
be used by a lot of programmers, you find yourself giving a lot of
thought to these small nuances.
Well, if you look behind the scenes, a property is really two methods, a
GetIsActive() and a SetIsActive(). So you could just remove the Is part and
simply use Active, but for readability I like the Is. I guess it's like my
old mentor always says, stop thinking and start doing ;-)
JIM
"Wavemaker" <ja**********@BiteMeHotmail.com> wrote in message
news:ke********************@comcast.com... "james" wrote: Wavemaker, no you are not only asking its state you are setting its state. i.e. Get IsActive, and Set IsActive
i.e. Employee.IsActive = false
and
if ( Employee.IsActive ) ...
JIM
Well, you can do this, of course. But my comments were based on the assumption that you wouldn't want to. :-) In your example, IsActive indicates whether or not an employee is active. When you test this property with the following:
if(anEmployee.IsActive)
You are saying if this employee *is active*, then do the following...
The "Is" implies a query about the object's state. Naming a property IsActive and making it writeable seems odd, like telling a question what the answer is rather than asking a question to find the answer. It doesn't seem semantically natural to me.
I would prefer something like this:
anEmployee.Activate(); anEmployee.Deactivate(); anEmployee.IsActive; // Read only property.
If you agree that what I've said above makes sense, then the issue becomes whether or not to make IsActive a property or a method. I haven't made up my mind on this, but I'm leaning towards the method route because asking an object about its state is an action and is better represented by a method (possibly). But I'm still thinking about this...
A minor issue, but when you are writing a library that will possibly be used by a lot of programmers, you find yourself giving a lot of thought to these small nuances.
>> Also, one reason that I don't use BIT datatype is because of Joe
Celko's unending hatred of bit fields. I believe that he calls the
BIT datatype a proprietary, non-portable datatype that is designed to
suck the soul out of
the body and in order to recover you have to pay him a lot of money to
perform an exorcism. I might have paraphrased a little but I think I
got the main point across. <<
Actually, that is nicer than I phrased it :)
:)
"--CELKO--" <jc*******@earthlink.net> wrote in message
news:18**************************@posting.google.c om... Also, one reason that I don't use BIT datatype is because of Joe
Celko's unending hatred of bit fields. I believe that he calls the BIT datatype a proprietary, non-portable datatype that is designed to suck the soul out of the body and in order to recover you have to pay him a lot of money to perform an exorcism. I might have paraphrased a little but I think I got the main point across. <<
Actually, that is nicer than I phrased it :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Cristof Falk |
last post by:
I wanted to get a feel. The documentation gives naming conventions for
public/protected members. Is this truly widely adopted?
And what about using the same conventions for private members and...
|
by: cmiddlebrook |
last post by:
Hi there,
I keep finding myself getting inconsistent with naming conventions for
things like member variables, class names etc and I just want to find
something that suits me and stick to it. I...
|
by: clintonG |
last post by:
Does the use of DTD, XML Schema and similar constructs adopt
the use of C# naming conventions? If so how do I make the distinction
of how to apply C# conventions with XML elements, attributes and...
|
by: Mark Broadbent |
last post by:
stupid question time again to most of you experts but this is something that
continually bothers me.
I am trying to get into the habit of naming variables and controls in an
assembly as per...
|
by: clintonG |
last post by:
Does the use of DTD, XML Schema and similar constructs adopt
the use of C# naming conventions? If so how do I make the distinction
of how to apply C# conventions with XML elements, attributes and...
| |
by: rastaman |
last post by:
Hi all,
I know of the existence of Object Naming Conventions for Visual Basic 6.
Now I'm reading some books about VB .NET, but the names used for the
objects are button1, picturebox1, etc.
I...
|
by: Patrick |
last post by:
what are the general naming conventions for vb.net controls.
esp txtUserName, lblPassword, btnSubmit
What are the prefixes for the controls????
I've tried to search hi and low on the net, but...
|
by: kevininstructor |
last post by:
Greetings,
I am in the process of creating naming conventions for VB.NET controls i.e.
CheckBox -> chkShowThisOnStartup
ListBoxt -> lstSomeList
What I am looking for other developers...
|
by: Philipp Post |
last post by:
Marcello,
Not a big surprise as naming conventions have a lot to do with
personal prefernces. There are a lot of threads in comp.databases and
the other database groups. Just do a search for...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |