give me advices about method name

K

kwatch

Hi,
I'm wondering what method names are appropriate for my library.
Could you give me advices?

Background:
I'm developping Motto-mysql library (not released yet).
http://github.com/kwatch/motto-mysql/tree/master
This library will improve Mysql/Ruby driver.

Motto-mysql will add some methods to Mysql::Result class.

* Mysql::Result#fetch_one_hash() returns a hash.
* Mysql::Result#fetch_one_array() returns an array.
* Mysql::Result#fetch_one_object(klass) returns an instance of klass
* Mysql::Result#fetch_all_hash() returns an array of hashes
* Mysql::Result#fetch_all_array() returns an array of arrays
* Mysql::Result#fetch_all_object(klass) returns an array of instances

# These methods convert data into proper type (Integer, Boolean, etc)
# while Mysql::Result#fetch() returns all data as String.
# For example, they return 3.14 while Mysql::Result#fetch() returns
"3.14".

But I'm not sure these method names are appropriate and correct in
English.
Could you propose me if you have better names?
 
P

Phrogz

kwatch said:
Motto-mysql will add some methods to Mysql::Result class.

* Mysql::Result#fetch_one_hash() returns a hash.
* Mysql::Result#fetch_one_array() returns an array.
* Mysql::Result#fetch_one_object(klass) returns an instance of klass
* Mysql::Result#fetch_all_hash() returns an array of hashes
* Mysql::Result#fetch_all_array() returns an array of arrays
* Mysql::Result#fetch_all_object(klass) returns an array of instances

In English, the all* methods should pluralize their nouns...
fetch_all_hashes
fetch_all_arrays
fetch_all_objects
....or perhaps...
fetch_every_hash
fetch_every_array
fetch_every_object

I'm not sure I understand what these methods, do, though. If they
select only items of the described class, I would probably go with:
fetch_hashes
fetch_arrays
fetch_objects

However, if they take an existing results set and interpret the
entries as the described class, I would probably suggest instead:
fetch_as_hashes
fetch_as_arrays
fetch_as_objects

I hope that helps.
 
K

kwatch

Thank you, Phrogz.
Your advice helps me very much.
I'll adopt fetch_hashes() or fetch_as_hashes().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top