views:

52

answers:

2

I've seen all of these:

  • is_valid

  • is_valid?

  • valid?

Is there a preferred one?

EDIT: More conditionals:

  • has_comment has_comment? comment?

  • was_full was_full? full?

Please do add more descriptive examples.

+8  A: 

I think the convention is mostly to add a '?' at the end of the method instead of 'is'

  • valid?
willcodejavaforfood
+1 - That is the standard convention :D
Levi Hackwith
+1  A: 

In favor of trying the code to be 'natural language' like, is_valid? should be most suitable for me. Lets show an example:

if @order.is_valid? @order.save end

iNecas
I agree. And what about other conditionals.. has_comment? is more descriptive than comment?.
randomguy
Using the question mark seems exaggerated, if a conditional is prefixed (IMHO).
randomguy
You are right,thinking about it again, standard convention is ".valid?" (eg .nil?, .empty?, .blank?), but I am still fan of human like code.
iNecas