From: Michael Neumann Date: 2004-10-21T19:01:06+09:00 Subject: Re: CamelCase issues On Thu, Oct 21, 2004 at 06:34:20PM +0900, Robert Klemme wrote: > > "Michael Neumann" schrieb im Newsbeitrag > news:20041021091218.GC983@miya.intranet.ntecs.de... > > Hi, > > > > For method names that contain up to two words, I really prefer the > > underscore-case (e.g., has_key?, method_missing). But if the method name > > contains more than two words that starts to look ugly IMO. It even looks > > strange (IMO) if you use underscore-case very often in your program > > (everything is small, no contrast for your eyes): > > > > c.form.url("foo").with { > > c.table { > > c.table_row.id("myrow").with { > > c.table_data.align_top.col_span(3).with("Hello world") > > } > > c.table_row_with_data { > > c << "Foo:" > > c.text_input.value(myobject.foo).callback(myobject, :foo=) > > } > > } > > } > > > > Versus: > > > > c.form.url("foo").with { > > c.table { > > c.tableRow.id("myrow").with { > > c.tableData.alignTop.colSpan(3).with("Hello world") > > } > > c.tableRowWithData { > > c << "Foo:" > > c.textInput.value(myobject.foo).callback(myobject, :foo=) > > } > > } > > } > > > > (and if you know that there's a class TableData, shouldn't the method be > > named tableData instead of table_data ?) > > > > I know that underscore-case is the perfered way in Ruby. > > > > Some more examples: > > > > render_content_on <-> renderContentOn > > render_table_header_on <-> renderTableHeaderOn > > > > Which one would you prefer? Thanks. > > I'd stick with underscore style. IMHO readability is not really improved > with camel case (might depend on screen, font and coloring though) and the > only advantage is that you save some chars. I usually agree. Hmm strange, now the example with underscores starts to look better ;-) > It might be different for you but I have to use more than three > identifiers separated by a dot very rarely; so from my personal experience > the example you showed seems to be rather exceptional than regular - YMMV > though. I don't know the classes of your example so I don't know whether > these chains *have* to be there because all invocations create new > instance. If not, i.e., if some of those methods just return self, I'd > rather resort to multiple lines with individual invocations. No, these chains are not exceptional! And yes, they return self most of the time. It's a port of Seaside2's new Html rendering scheme. > My 0.02EUR... Thanks. Regards, Michael