# Give me advices about method name

**URL:** <https://www.ruby-forum.com/t/give-me-advices-about-method-name/148889>\
**Category:** Ruby\
**Created:** [September 18, 2008, 1:20am UTC](https://www.ruby-forum.com/t/give-me-advices-about-method-name/148889 "2008-09-18T01:20:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwatch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/76d3ee/32.png) [@kwatch](https://www.ruby-forum.com/u/kwatch)\
**Post date:** [September 18, 2008, 1:20am UTC](https://www.ruby-forum.com/t/give-me-advices-about-method-name/148889/1 "2008-09-18T01:20:39Z")

</div>

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).

> **[GitHub - kwatch/motto-mysql: Motto-mysql is a complementary library to enhance...](https://github.com/kwatch/motto-mysql/tree/master)**
>
> 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?

---

<div class="post-metadata">

**Author:** ![kwatch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/76d3ee/32.png) [@kwatch](https://www.ruby-forum.com/u/kwatch)\
**Post date:** [September 18, 2008, 4:55am UTC](https://www.ruby-forum.com/t/give-me-advices-about-method-name/148889/2 "2008-09-18T04:55:30Z")

</div>

kwatch wrote:

> 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.

---

<div class="post-metadata">

**Author:** ![kwatch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/76d3ee/32.png) [@kwatch](https://www.ruby-forum.com/u/kwatch)\
**Post date:** [September 18, 2008, 7:13am UTC](https://www.ruby-forum.com/t/give-me-advices-about-method-name/148889/3 "2008-09-18T07:13:31Z")

</div>

Thank you, Phrogz.  
Your advice helps me very much.  
I’ll adopt fetch\_hashes() or fetch\_as\_hashes().

–  
regards,  
makoto kuwata
