Page 1 of 1
words
Posted: Wed Sep 21, 2011 3:33 am
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
Re: words
Posted: Wed Sep 21, 2011 1:03 pm
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().
Re: words
Posted: Thu Sep 22, 2011 2:04 pm
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.
Re: words
Posted: Mon Sep 26, 2011 7:45 am
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".
Re: words
Posted: Tue Sep 27, 2011 5:28 pm
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.