Is there a document anywhere that indicates when to use camel casing and when to use underscores between words? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> Is there a document anywhere that indicates when to use camel casing and > when to use underscores between words?Huh? Do you mean for things like variables, methods, classes, constants? Or something else? In general... variable_name method_name ClassName CONSTANTNAME -philip -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom wrote:>> Is there a document anywhere that indicates when to use camel casing and >> when to use underscores between words? > > Huh? Do you mean for things like variables, methods, classes, > constants? Or something else? > > In general... > > variable_name > method_name > ClassName > CONSTANTNAME > > -philipThat is exactly what I meant. Thank you. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> variable_name > method_nameBut why?! Since methods don''t need (), how are we supposed to instinctively know what''s a method and what isn''t when reading someone elses code? (Or our own when we''ve forgotten what we wrote!) Matt. PS. Anyone play spot the Ruby Newbie, score 10 points! On Jul 10, 12:03 am, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> > Is there a document anywhere that indicates when to use camel casing and > > when to use underscores between words? > > Huh? Do you mean for things like variables, methods, classes, constants? Or something else? > > In general... > > variable_name > method_name > ClassName > CONSTANTNAME > > -philip-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
MattB wrote:>> variable_name >> method_name > > But why?! Since methods don''t need (), how are we supposed to > instinctively know what''s a method and what isn''t when reading someone > elses code? (Or our own when we''ve forgotten what we wrote!)You shouldn''t need to. The similarity is deliberate. (BTW, I would do CONSTANT_NAME, not CONSTANTNAME.)> > Matt. > > PS. Anyone play spot the Ruby Newbie, score 10 points!-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> You shouldn''t need to.Because... (?) (Not being facetious). On Jul 10, 2:11 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> MattB wrote: > >> variable_name > >> method_name > > > But why?! Since methods don''t need (), how are we supposed to > > instinctively know what''s a method and what isn''t when reading someone > > elses code? (Or our own when we''ve forgotten what we wrote!) > > You shouldn''t need to. The similarity is deliberate. > > (BTW, I would do CONSTANT_NAME, not CONSTANTNAME.) > > > > > Matt. > > > PS. Anyone play spot the Ruby Newbie, score 10 points! > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
MattB wrote:>> variable_name >> method_name > > But why?! Since methods don''t need (), how are we supposed to > instinctively know what''s a method and what isn''t when reading someone > elses code? (Or our own when we''ve forgotten what we wrote!) > > Matt. > > PS. Anyone play spot the Ruby Newbie, score 10 points!variable_name = something Object.method_name If you are inside a class def instance_method self.method_name = something variable_name = method_name end ^^ -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 9, 2010, at 6:21 PM, MattB wrote:> >> You shouldn''t need to. > > Because... (?) > > (Not being facetious).Because for all practical purposes they are the same thing. They aren''t of course, but only the class itself should know or care about that. Look at ActiveRecord... say I''ve got a Widget class with a title attribute... W = Widget.new w.title = "Foo" puts w.title *both* the 2nd and 3rd lines are actually methods. You''re not accessing a variable of the instance of the class. Does it matter to you? No. In the first case the method is "def title=()" and in the second it''s "def title()". Maybe. Rails probably abstracts even that. But that''s the general idea. -philip> > On Jul 10, 2:11 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> MattB wrote: >>>> variable_name >>>> method_name >> >>> But why?! Since methods don''t need (), how are we supposed to >>> instinctively know what''s a method and what isn''t when reading someone >>> elses code? (Or our own when we''ve forgotten what we wrote!) >> >> You shouldn''t need to. The similarity is deliberate. >> >> (BTW, I would do CONSTANT_NAME, not CONSTANTNAME.) >> >> >> >>> Matt. >> >>> PS. Anyone play spot the Ruby Newbie, score 10 points! >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Should have mentioned this before, but if you''re really curious about this sort of thing, the "Well Grounded Rubyist" is excellent. http://www.manning.com/black2/ (just a happy owner of said book) On Jul 10, 2010, at 10:54 AM, Philip Hallstrom wrote:> > On Jul 9, 2010, at 6:21 PM, MattB wrote: > >> >>> You shouldn''t need to. >> >> Because... (?) >> >> (Not being facetious). > > Because for all practical purposes they are the same thing. They aren''t of course, but only the class itself should know or care about that. > > Look at ActiveRecord... say I''ve got a Widget class with a title attribute... > > W = Widget.new > w.title = "Foo" > puts w.title > > *both* the 2nd and 3rd lines are actually methods. You''re not accessing a variable of the instance of the class. > > Does it matter to you? No. > > In the first case the method is "def title=()" and in the second it''s "def title()". Maybe. Rails probably abstracts even that. But that''s the general idea. > > -philip > > >> >> On Jul 10, 2:11 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> MattB wrote: >>>>> variable_name >>>>> method_name >>> >>>> But why?! Since methods don''t need (), how are we supposed to >>>> instinctively know what''s a method and what isn''t when reading someone >>>> elses code? (Or our own when we''ve forgotten what we wrote!) >>> >>> You shouldn''t need to. The similarity is deliberate. >>> >>> (BTW, I would do CONSTANT_NAME, not CONSTANTNAME.) >>> >>> >>> >>>> Matt. >>> >>>> PS. Anyone play spot the Ruby Newbie, score 10 points! >>> >>> -- >>> Posted viahttp://www.ruby-forum.com/. >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.