• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Are we suppose to use verbs for methods and nouns for field?

 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In reading Just Java 2, Mr. Linden states that the Java Language Specification says that method names should be based on verbs while field names should be based on nouns. I didn't see any mention of this in the Style Guide. Should we be following this standard?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Richard Boren:
In reading Just Java 2, Mr. Linden states that the Java Language Specification says that method names should be based on verbs while field names should be based on nouns. I didn't see any mention of this in the Style Guide. Should we be following this standard?


Hi Richard,
I'd say you should go with the suggestion in the book. I'm not using that book myself. But since that's the recommended text I'd go along with that. My assignments have been done like that and I've had no complaints .... Well except for not making them
descriptive enough :-)
Evi
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A good descriptive name is usually enough, but when you think about it, a method is supposed to do something while a variable just holds data, so it IS something. With that logic, a good descriptive name would be a verb for a method and a noun for a variable.
Like:
name
arguments
And:
getName()
setName()
Bill
 
Richard Boren
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies. Methods get the verbs and fields get the nouns.
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic