words

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
ooppoo
Forum Newbie
Posts: 2
Joined: Wed Sep 21, 2011 3:18 am

words

Post by ooppoo »

Hi

i am from austria and sometimes i have problems with english. I program in english but sometimes i don´t know which words i should use. e. g. names of methods.

- get
- retrieve
- fetch

When do you use these words? for example "fetch" is used in mysql_fetch_array. "get" is used in getter-methods.
Are there any rules which defines when i have to use one of these 3 words as prefix of a method-name?

thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: words

Post by Christopher »

Since you are discussing very fine distinctions between words in English, I think you are more sophisticated than most English speakers! :)

Some of the differences in naming are personal preference. I think get() and set() and other methods like getName() and setName() are usually used to access object properties. The words retrieve and fetch mean essentially the same thing. Like many concepts in English there is a word from German (fetch) and a word from French (retrieve). Thanks the Normans for conquering England in 1066 for that! I think fetch is probably more commonly used that retrieve -- especially for database methods. So retrieve might only be used for some other sub-system to make it clear that it is not a standard database access method. I know that some of the data access patterns, such the Gateway patterns, use the word find() instead of fetch(), so you may want to use that instead. I prefer find() for higher level methods like findAllProducts(). To me, fetch() implies a simpler operation like fetchRow().
(#10850)
ooppoo
Forum Newbie
Posts: 2
Joined: Wed Sep 21, 2011 3:18 am

Re: words

Post by ooppoo »

Thanks for reply.

That´s correct. "fetch" is used in mysql_fetch_array or mysql_fetch_assoc. I think "fetch" means, that the method gets just some specific data, a subset(!) of database-data. "get" gets exactly 1(!) specific data.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: words

Post by Mordred »

For me, it's about the locality of the data.

"get" = "See this thing you are holding, or is located just near you? Give it to me please."
"fetch" = "See that thing over there, behind that rock? Will you go there and bring it here please."

That's why member variables (local) are obtained with "get", while data from the database (remote) is "fetch".
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: words

Post by greyhoundcode »

Mordred wrote:For me, it's about the locality of the data.

"get" = "See this thing you are holding, or is located just near you? Give it to me please."
"fetch" = "See that thing over there, behind that rock? Will you go there and bring it here please."
It's all personal preference I suppose, but I do like this mode of thought.
Post Reply