Error:- "regex literal in condition"

I tend to prefer to adopt the stylistic conventions of the language I am
working in. Rather than try to hold on to some cross-language personal
preference, I find having my code match the style of the libraries that
I am
using to be the most aesthetically pleasing.

Gabe

On 1/20/06, Bill K. [email protected] wrote:

It’s always a sinking
feeling (for me anyway) to download what might be a nice open source
Ruby library, and find the author was either unaware of the Ruby
naming conventions, or decided to disregard them, thereby putting
unnecessary burden on all users of the library. Makes me want to
scream, “Oh! You inconsiderate miserable b****rd!!!” - but that is
always tempered by, “But, thanks for the free code!”

Nicely put! I too prefer to use the conventions of the language I am
working in.
I used to use camelCase everywhere when I first got into Java. That
angered a few people. I learned :wink:

From: “Zach” [email protected]

I know the current naming standards of the language. My curiosity is
how many programmers prefer it.

Personally, I like Ruby’s naming standards. I prefer snake_case to
camelCase in general, so that helps. But an important point is, I
think,
that it’s better to adopt the naming standards of whatever language
I’m coding in. In Java, I follow Sun’s naming conventions. We’ve seen
posts from Ruby programmers who stick with their own style, regardless
of language. That’s their prerogative, but if one is writing library
code
to share with the Ruby community, I think it’s especially important to
be
willing to adopt the Ruby naming conventions. It’s always a sinking
feeling (for me anyway) to download what might be a nice open source
Ruby library, and find the author was either unaware of the Ruby
naming conventions, or decided to disregard them, thereby putting
unnecessary burden on all users of the library. Makes me want to
scream, “Oh! You inconsiderate miserable b****rd!!!” - but that is
always tempered by, “But, thanks for the free code!”

Anyway, “When in Rome, …” etc.

Regards,

Bill

hi …

James B. wrote:

If you have a variable that refers, say, to an instance of a class
representing a hotel reservation, name it as such:
current_hotel_reservation. Not hr_curr or the like.

Personally, I think that there is a place for short names as I find them
much more readable. Verbosity can be a real impediment to readability.

-mark.

James B. wrote:

Mark Probert wrote:

much more readable. Verbosity can be a real impediment to readability.

Well, readability and communication are key.

James

An interesting concept for functional apps (or system) Hungarian in
Ruby. It would be pretty easy to set up the missing_method function to
extract out certain tags from a variable name.

For example,
assume you have a model with an attribute called ‘Text’

you could set up missing_method to pick up ‘iText’ and return
‘Text.to_i’ or ‘hText’ could return ‘h(Text)’ etc…

NOTE: I’m not advocating that this is a good idea, I’m just pointing out
that you could use Hungarian notation in Ruby and actually have it do
something.

_Kevin

Mark Probert wrote:

much more readable. Verbosity can be a real impediment to readability.

Well, readability and communication are key.

James

Kevin O. wrote:

NOTE: I’m not advocating that this is a good idea, I’m just pointing out
that you could use Hungarian notation in Ruby and actually have it do
something.

David A. Black said…

Why not just call to_i or h in the first place? :slight_smile:

In most cases I expect that it would be better that way, and that would
be my preference as well. I suppose it might be useful for porting
code.

_Kevin

On Jan 23, 2006, at 12:49 PM, Kevin O. wrote:

An interesting concept for functional apps (or system) Hungarian in
Ruby. It would be pretty easy to set up the missing_method
function to
extract out certain tags from a variable name.

For example,
assume you have a model with an attribute called ‘Text’

you could set up missing_method to pick up ‘iText’ and return
‘Text.to_i’ or ‘hText’ could return ‘h(Text)’ etc…

How are you going to assign a variable (iText = …), and then
convince Ruby to treat it as a method (to trigger method_missing())?

James Edward G. II

Hi –

On Tue, 24 Jan 2006, Kevin O. wrote:

Ruby. It would be pretty easy to set up the missing_method function to
extract out certain tags from a variable name.

For example,
assume you have a model with an attribute called ‘Text’

(A class with an attribute called “text”?)

you could set up missing_method to pick up ‘iText’ and return
‘Text.to_i’ or ‘hText’ could return ‘h(Text)’ etc…

Why not just call to_i or h in the first place? :slight_smile:

David


David A. Black
[email protected]

“Ruby for Rails”, from Manning Publications, coming April 2006!

[email protected] wrote:

Hi –

On Tue, 24 Jan 2006, Kevin O. wrote:

(A class with an attribute called “text”?)

you could set up missing_method to pick up ‘iText’ and return
‘Text.to_i’ or ‘hText’ could return ‘h(Text)’ etc…

Why not just call to_i or h in the first place? :slight_smile:

Aesthetics? Encapsulation? Hiding implementation details? Amusement?

I’ve seen code that takes find_by_foo( bar ) and converts it into find(
:foo => bar ) or some such thing. Is this to save typing (he asked
rhetorically)? Expression of intent? Slickitude factor (“Ha! Try THAT,
Java droids!” )? (Still rhetorical; please, no flames.)

I showed this as part of a Ruby demo, and at least one person didn’t
see what that bought you. Fair enough. I tend to like it, though.

hText (though h_text or text_h looks more Rubyish) is just another
example of embedding code in message names.

But it can teeter toward DSL: domain-specific logorrhea.

foo.baz_then_bar_unless_bif_equals_47

James B.

http://www.ruby-doc.org - Ruby Help & Documentation
Ruby Code & Style - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools

James G. wrote:

How are you going to assign a variable (iText = …), and then
convince Ruby to treat it as a method (to trigger method_missing())?

I just tested this with a quick one and found that if you do something
like

object.iTest=5

Then method_missing will get ‘iTest=’ as the symbol, and ‘n’ as an
argument. Then it’s a simple matter of trimming the ‘i’ off the front
and returning the result of ‘(test=n).to_i’.

_Kevin

On Jan 23, 2006, at 3:20 PM, Kevin O. wrote:

Then method_missing will get ‘iTest=’ as the symbol, and ‘n’ as an
argument. Then it’s a simple matter of trimming the ‘i’ off the front
and returning the result of ‘(test=n).to_i’.

Gotcha. I thought you were talking about using local variables. I
understand now. Thanks.

James Edward G. II