Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Naming Convention(s)

Reply
Thread Tools

Naming Convention(s)

 
 
Roedy Green
Guest
Posts: n/a
 
      09-03-2005
People usually feel very passionately about matters such as this one.
I have not seen any official pronouncement on it:

Do you prefer singular or plural names for:
1. arrays
2. collections
3. directories

In other words do you prefer goats[i] or goat[i], HashSet goats or
HashSet goat, the C:\goats directory or the C:\goat directory.

By the way, what brought this on was the discovery that I can't have
an icons directory on my website since Apache reserves that name for
its own purposes. I had to rename to the icon directory.


for ( goat : goats ) is an argument for plural names.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      09-03-2005
On Sat, 03 Sep 2005 08:44:00 GMT, Roedy Green wrote:

> In other words do you prefer goats[i] or goat[i], HashSet goats or
> HashSet goat, the C:\goats directory or the C:\goat directory.


I prefer ..

// slightly tongue in cheek..
HashSet goatHerd;

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Your eyes, no surprise, are open wide.."
Divinyls 'Good Die Young'
 
Reply With Quote
 
 
 
 
Skip
Guest
Posts: n/a
 
      09-03-2005
"Roedy Green" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> People usually feel very passionately about matters such as this one.
> I have not seen any official pronouncement on it:
>
> Do you prefer singular or plural names for:
> 1. arrays
> 2. collections
> 3. directories
>
> In other words do you prefer goats[i] or goat[i], HashSet goats or
> HashSet goat, the C:\goats directory or the C:\goat directory.


I, for one, stick to this:

Goat[] goat = ...;
Collection goats = ...;

Because
goat[x].getParent();
feels like: "goat X -> get parent", and
goats.get(x).getParent();
feels like: "out of all goats, pick X -> get parent"

goats[x] feels very unnatural IMHO.

Besides that, whenever it's "goats", I know it's a collection
(list,map,set).

>
> By the way, what brought this on was the discovery that I can't have
> an icons directory on my website since Apache reserves that name for
> its own purposes. I had to rename to the icon directory.
>
>
> for ( goat : goats ) is an argument for plural names.
> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Again taking new Java programming contracts.



 
Reply With Quote
 
jan V
Guest
Posts: n/a
 
      09-03-2005
> goats[x] feels very unnatural IMHO.

It will never cease to amaze me how any two intelligent people can use
rational thought to arrive at completely opposite conclusions.

goats[x] feels the only right choice to me, with goat[x] being the approach
I cringe at. Whether it's a primitive array or a Collection, the two are
logically equivalent, so the use of plural applies to both.



 
Reply With Quote
 
Skip
Guest
Posts: n/a
 
      09-03-2005
"jan V" <(E-Mail Removed)> wrote in message
news:OKdSe.184918$(E-Mail Removed)-ops.be...
> > goats[x] feels very unnatural IMHO.

>
> It will never cease to amaze me how any two intelligent people can use
> rational thought to arrive at completely opposite conclusions.
>
> goats[x] feels the only right choice to me, with goat[x] being the

approach
> I cringe at. Whether it's a primitive array or a Collection, the two are
> logically equivalent, so the use of plural applies to both.


for(int i=0; i<n; i++)
{
// A
goats[i] = new Goat();
// pronounce "goats at i = new goat"

// B
goat[i] = new Goat();
// pronounce "goat at i = new goat"

// C
goats.set(i, new Goat());
// pronounce "set new goat at i, in goats"
}

That would be my "rational thought", which I realize from another POV is
easily breakable. Matter of taste I think.


 
Reply With Quote
 
Tjerk Wolterink
Guest
Posts: n/a
 
      09-03-2005
Skip wrote:
> "jan V" <(E-Mail Removed)> wrote in message
> news:OKdSe.184918$(E-Mail Removed)-ops.be...
>
>>>goats[x] feels very unnatural IMHO.

>>
>>It will never cease to amaze me how any two intelligent people can use
>>rational thought to arrive at completely opposite conclusions.
>>
>>goats[x] feels the only right choice to me, with goat[x] being the

>
> approach
>
>>I cringe at. Whether it's a primitive array or a Collection, the two are
>>logically equivalent, so the use of plural applies to both.

>
>
> for(int i=0; i<n; i++)
> {
> // A
> goats[i] = new Goat();


Ok were dealing with an array of goats

> // pronounce "goats at i = new goat"
>
> // B
> goat[i] = new Goat();


Ok were dealing with a array that represents a goat.

> // pronounce "goat at i = new goat"
>



What if i want to represent a goat with an array?
Then you have a problem.

For example

Object[] goat={
new GoatSound(),
new GoatTeeth()
}


??

So use the plural form to be sure your dealing with an array of goats.
 
Reply With Quote
 
Skip
Guest
Posts: n/a
 
      09-03-2005

"Tjerk Wolterink" <(E-Mail Removed)> wrote in message
news:dfbsen$841$(E-Mail Removed)...
> Skip wrote:
> > "jan V" <(E-Mail Removed)> wrote in message
> > news:OKdSe.184918$(E-Mail Removed)-ops.be...
> >
> >>>goats[x] feels very unnatural IMHO.
> >>
> >>It will never cease to amaze me how any two intelligent people can use
> >>rational thought to arrive at completely opposite conclusions.
> >>
> >>goats[x] feels the only right choice to me, with goat[x] being the

> >
> > approach
> >
> >>I cringe at. Whether it's a primitive array or a Collection, the two are
> >>logically equivalent, so the use of plural applies to both.

> >
> >
> > for(int i=0; i<n; i++)
> > {
> > // A
> > goats[i] = new Goat();

>
> Ok were dealing with an array of goats
>
> > // pronounce "goats at i = new goat"
> >
> > // B
> > goat[i] = new Goat();

>
> Ok were dealing with a array that represents a goat.
>
> > // pronounce "goat at i = new goat"
> >

>
>
> What if i want to represent a goat with an array?
> Then you have a problem.
>
> For example
>
> Object[] goat={
> new GoatSound(),
> new GoatTeeth()
> }
>
>
> ??
>
> So use the plural form to be sure your dealing with an array of goats.


While I see your point, I think representing a goat with an array is poor
design.


 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      09-03-2005
Roedy Green wrote:
> People usually feel very passionately about matters such as this one.
> I have not seen any official pronouncement on it:
>
> Do you prefer singular or plural names for:
> 1. arrays
> 2. collections
> 3. directories


Plural. Sets are potentially obscure enough to have a "Set" suffix.
"Map" suffix for a map.

Singular for SQL tables and packages. With SQL you are refer to tables
when in fact you are just after individual rows (if you see what I
mean). java[x].* packages are inconsistently names, but you don't give
class plural names, in general.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
Hemal Pandya
Guest
Posts: n/a
 
      09-03-2005

Roedy Green wrote:
> People usually feel very passionately about matters such as this one.
> I have not seen any official pronouncement on it:
>
> Do you prefer singular or plural names for:
> 1. arrays
> 2. collections
> 3. directories
>
> In other words do you prefer goats[i] or goat[i], HashSet goats or
> HashSet goat, the C:\goats directory or the C:\goat directory.


I personally like plural form. I have even come across the goatS style,
with capital S.

I have a follow-up question. If you do prefer the plural form, what do
pluralize nouns that have irregular plural forms in English? wolfs or
wolves? geese or gooses? deers or deer?

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      09-03-2005
On 3 Sep 2005 03:51:12 -0700, Hemal Pandya wrote:
> Roedy Green wrote:

...
>> In other words do you prefer goats[i] or goat[i], HashSet goats or
>> HashSet goat, the C:\goats directory or the C:\goat directory.

...
> I have a follow-up question. If you do prefer the plural form, what do
> pluralize nouns that have irregular plural forms in English? wolfs or
> wolves?


pack.

>..geese or gooses?


flock.

>..deers or deer?


herd.



--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Tell 'em a hooka smokin' caterpillar, has given you the call.."
Jefferson Airplane 'White Rabbit'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Javax.naming Exception: name not found in naming service. Harman Java 1 07-28-2006 08:51 AM
Network Naming John Williams Wireless Networking 4 10-01-2005 01:18 PM
Naming bookmark folders Petey the Wonder Dog Firefox 0 08-17-2005 09:48 AM
WS C3550 naming convention question frishack@gmail.com Cisco 2 02-23-2005 07:29 PM



Advertisments