Sunday, May 20, 2007

RailsConf Brain Dump

Here are my notes from three conference sessions. Warning - minimal formatting and editing, and any code indentation undoubtedly fux0r3d by Blogger.

GLENN VANDERBURG

def sort_header(field, label=field.titleize)
  content_tag(:th, :class => 'sort_header') do
    link_to label, :sort => field
  end
end

it is actually possible to do Seaside-style coded html rather than messy embedded templates; just build them in the helpers. could you do a components thing from there?

render partial from helper - easy enough

taking html_options (the hash) is pretty easy - just set it as an optional arg in the helper method's def.

inconsistency in built-in helper methods unfortunate - no kidding

generating javascript

filter_select method - is how NOT to do it
explicit tag attribute event handlers avoid
best approach - send it to another function which registers the change request - that way you can have multiple causes and multiple effects and still end up with whatever sequence of causes and effects you want.

rails recipes, recipe #2

learn internals of Rails helpers

use JS objects; put functions there; hack misusing objects as if they were namespaces, but hey.

learn prototype in depth

form builders - instances of TaggedBuilder
what is TaggedBuilder?
enables you to encapsulate patterns/styles of forms in your app

Slides are going to be online


. Be intolerant of messy code in views
. When you put logic in views, build helpers
. Anything more than simple conditionals
. When you see duplication in views, build helpers
. Best way to learn is to do
. Keep languages separate, even in your helpers
. Prefer generating HTML in other helpers, rather than inline
(lots of little classes)
. JS goes in app.js or other helpers
. Pick one existing convention for option transfer and stick to it
. Move them to app_helper if useful many places
. Move them to a plugin if frequently useful
. PEEK BEHIND THE CURTAIN
Read and analyze the helper-building helpers
capture, concat,
observe_field, content_tag, text_field_tag,
link_to_if

...

EZRA ZYGMUNTOWICZ

Mongrel's really an HTTP Server **Library**
Stackable Handlers - like Evan Weaver's Mongrel.Configurator() thing
Use mongrel_cluster for multiple process (Mutex lock)
Lightspeed and Apache proxies
Pen/Pound/etc. proxies

...

DAN WEBB

Peasant's language

Event.onReady / Event.observe - from low pro, but merging into Prototype
Capture standard event responses to functions to make event handlers shorter?
No!
write Prototype to programmatically apply functions (event handlers) to the HTML. much shorter, much faster; downside is potential for browser issues i.e. page loading before JavaScript prepared
Event delegation in case of too many handlers for browser to handle
Use regular script-based handling and attachment first
Inline handling (a onclick="xyz") as method of last resort
Event Bubbling
handler goes in body?
bdoy tag catches all events, events go to event dispatcher or handler
allows you to handle complex situations - would have been good for CYP
Event Bubble-catcher obtains event source (target) from Event.observe
Event B-C can decide based on event source class (in CSS sense)
dan webb winner for best slides, easy, even over DHH
href="#" bad for inline event handlers
why?
use href to pass ARGS to the inline event handler instead
3 official methods
(and 2 unofficial?)
appendChild, insertBefore, replaceChild
one unofficial from IE: innerHTML
from IE?!
used in update() in Prototype
DOM elements surgical but bulky
overburdened, XML-y

**Low Pro's DOM builder - programmatic HTML generation**

DOM = Ninja, innerHTML = Sumo
5th method - the Bastard Son - DOM and innerHTML
use DOM methods to generate HTML and innerHTML to insert
or, more rarely, the other way round

Lightning Script Style
don't use :defaults - 5 HTTP requests, ~134KB
the less JS, the better
Moo FX - smaller can be better
Browser normally only load 2 resources simultaneously (**from the same server**(I think))
JS compression inferior to GZIP
Packer implements zip algorithm in JS
madness
browser auto-decompresses gzip (?)
Faster loops - each() slow - put initialization in the for
that was weird, two vars in the var part, avoid .length
indiscriminate $$() slow on IE
Start with working HTML = get it working normally first - standard
Pro JavaScript Techniques (Dan Web tech editor) - Bulletproof Ajax
DHTML Utopia Modern Web Design (sitepoint?)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.