Em 05-07-2010 04:39, [email protected] escreveu:
Hi,

This could be written using no variable as:
$('<div/>').appendTo('body')
I think this is just an example of a smart refactoring.
No it is not.


Or even as:
$('<div/>').text('content').appendTo('body').click(function(){alert('clicked:
' + $(this).text())})

There is a reason why Java is so important today in "professional
programming".

Well, that is your opinion. I don't give that much importance to Java, even though I do Java development at work most of the time.

  When you have (sometimes very large) teams of
programmers (of all types - and quality!) working on projects for
years, when code has to go through many hands (over time and through
departments or even companies), often with changing programmers, you
have to have a different style.

That is exactly what happens in my company, but Javascript is hardly the problem here and we do a ton of Javascript coding here. Usually, Java is the problem here... We develop lots of interactive UI with maps, services, etc, which results in lots of Javascript. We don't separate our JS code as you suggests and this has never been a problem at all here. But understanding other's Java code here have been a pain for new developers... We use a lot of anonymous functions here and I think it is easier for newcoming developers to understand the code that way. It smells like Ruby closures I would say...

Apart from the problem that if any one part of such a chain fails it's
harder to find out WHICH part did so compared to having it all on a
single line, it simply isn't as readable (whatever you say, that's a
psychologically proven fact)

Why do you say so? If I'm saying that my experience reading more lines per page is better, than it is certainly a matter of taste. You (or someone else) cannot prove this is not, once I don't agree... This is logical to me... You can take statistics about what most developers think about the subject, but you cannot prove all of them will think that way...

Anyway, where is the link for such affirmation proving that statement?

  - unless you have very little code.

Of course, when JS is used only for adding a little interaction to a
page - go ahead like this. However, when you write a application I'd
fire you instantly before you create even more chaos to be untangled
later by others trying to debug your code :-)
We would probably never work in the same company, then. :) Anyway, some say automated testing exists exactly for situations like that... ;)

Regards,

Rodrigo.
   For example, in such
projects I want to have the code that binds behavior to the UI in one
place - but the actual functions doing that job in quite another, so
no anonymous functions right inside the .click(....), ever.
Readability for large pieces of code would be impacted severely
otherwise.

Michael


--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to