« first day (528 days earlier)      last day (4642 days later) » 

MT.
MT.
22:03
hi room
I am trying to implement JS with the best practices. I am not sure if I've done it anywhere near right.
Can someone help me with this
It's a very small file
and it takes little time to go through it
just put it online somewhere
on your own host , jsbin.com or pastie.org
MT.
MT.
would gist.github work?
is that ok?
of course
22:05
just a warning: I see you're using jQuery. Activate your defense shields.
there is jquery there Õo
MT.
MT.
is it that bad?
well, everyone here will tell you so
var ancestor = $(this).parent().parent().parent(); << ehh ..
first off, don't keep doing $(this).something - cache $(this) in a variable for later use
MT.
MT.
22:07
yeah I did that, ancestor is the variable
oh got it
yeah, got it.
var ancestor = this.parentNode.parentNode.parentNode;
^ no jQuery, kewl! ^
MT.
MT.
but I was told that it should not be so dependent on the DOM
yeah it looks neat too without jQuery
GGG
GGG
yeah the dom is shifty
it could go away or break at any time
jQuery depends on the DOM just as much as regular Javascript; it just abstracts the DOM
MT.
MT.
22:08
so what would be a good practice
GGG
GGG
it could just pack up and leave tomorrow
better just use jquery huh
that'd be like saying "we really shouldn't be so dependent on the foundation; let's have some other company build it for us"
i dunno even know where to begin
either way the DOM is there, at the bottom. May as well remove a layer (jQuery)
MT.
MT.
well, for DOM traversal, what would you recommend
as a good practice
22:09
you code is kinda messy to begin with , then you have also a habit of using jQuery when it isnt even useful .. and the innerHTML .. the innerHTML
var id = $(this).attr('id'); are you fucking kidding me ?!?!?
just do var id = this.id :) (regarding what @tereško just said)
MT.
MT.
okay
GGG
GGG
@tereško really, surprised?
MT.
MT.
guys I agree my code is bad. I am still learning to become a good JS dev
GGG
GGG
this is the norm in jquery land
isnt it
22:12
@MT dude, you're already way ahead by the fact that you're admitting it and trying to improve
i have been delving in high-OOP side of php development .. im not as desensitized to it as i was before
MT.
MT.
also, this is the only JS in the project I am working on right now
GGG
GGG
i mean it's freaking crazy don't get me wrong
no variable declarations, dollar signs everywhere
@MT , it's ok ( well .. at least not too bad ) to use jQuery, but you should not abuse it .. the ID example was one of the abuse cases
MT.
MT.
so, for future maintenance and easy debugging
GGG
GGG
22:13
i mean i didn't llok at the code in question here but we've all seen it a billion times
MT.
MT.
what would be better
okay. I will stop doing that.
also, i think you can do this.value instead of $(this).val ...am i right, guys?
MT.
MT.
I am actually noting down all this good stuff. So I can refactor it all
@MT do you get why the ID example was wacko?
@MT good.
MT.
MT.
correcting my mistakes at the starting stage.
GGG
GGG
22:15
yeah the problem is that this code is already out there
MT.
MT.
@ThomasShields actually, I don't. Could you tell me
GGG
GGG
probably just learning by example
and 90% of the examples suck
btw , IIRC ,then $( deocument.getElementById('signup-form')).on('blur', 'input', function(event) { is a lot faster
MT.
MT.
yeah, I have been googling since the past 2 weeks for good examples and couldn't find any
a lot faster then $('#signup-form').on('blur', 'input', function(event) {
GGG
GGG
22:16
$('# is super slow
@MT sure - this was the actual element you were working with. this.id gives you direct access to its ID. What you were doing was wrapping this into a jQuery object, then using an expensive function (.attr()) to find the attribute id. You were beating about the bush, basically.
MT.
MT.
so do I have to use an IIFE for all this code
@ThomasShields OMG! I didn't even realize that.
also, why would you do this: $('#' + id), when you have the element you got id from?
@MT ,you should initialize the $() with either complex DOM queries , or with already selected dom elements
MT.
MT.
22:18
@tereško how do I do that?
GGG
GGG
shift-490
$( document.getElementById('foo')) instead of $('#foo')
MT.
MT.
okay
before I asked you guys, I asked a friend here to help me and he spoke something I didn't understand a bit
it is proper to use jQuery for something like $('ul.menu .active > a') , that's what jquery is good at
MT.
MT.
he looked at the file and said
"theres top level functions now that are untested. even name spacing immediately called functions makes a piece of code hard to test"
22:20
he tried to sound smart
MT.
MT.
really? I thought he was helping me
:(
i would have answered to it with "English , use it, you f***er !"
well, he probably thought so too
MT.
MT.
also he said "backbone has bound delegation calls for initialization of objects, something similar im sure can be done with oojs with the functional prototype. once those delegations are call-able, they can and should be tested. and highly dependent tree traversal calls have been an achilles heel for our codebase in the pastcalls like var ancestor = $(this).parent().parent().parent(); break"
that was what he said
GGG
GGG
22:22
...oojs huh
but you're not even using backbone in that example.
why would he mention backbone when you're using jQuery?
MT.
MT.
no he is using backbone in another project he is working on
well .. @MT , you should have initialized the function with the ancestor node
oh okay
> highly dependent tree traversal calls have been an achilles heel for our codebase in the past
now that's a good point ^
do you know how to use closures and partials ?
MT.
MT.
22:23
yeah, I understood that when you guys explained it.
var ancestor = $(this).parent().parent().parent(); //blech.
@ThomasShields , we already covered that
MT.
MT.
@ThomasShields yeah now when I look at it, I feel embarrassed.
@tereško I don't know how to do that.
@tereško No I don't.
@MT , do you know how partials work ?
MT.
MT.
@tereško Do you want me to read it now or later after you're done explaning?
also guys, what does "bound delegation calls for initialization of objects" mean
GGG
GGG
22:26
that looks horrible =/
var foo = function ( data ){

     return function( bar ){
        console.log( bar + '-' + data );
    };
} , fn;
fn = foo('batman !!');
fn('nananananana');
fn('nom-nom-nom');
MT.
MT.
Guys?
@MT , run that code and look at what's in the console
GGG
GGG
yeah that's a way better example
the blog post was doing all kinds of crazy stuff
MT.
MT.
@tereško doing it
22:30
do you understand what happens ?
MT.
MT.
trying to figure out
one thing is
that
the outer function takes the param and returns a function
yuiblog.com/crockford ... here are some additional lecture , the 3rd one is the most important
yes ..
MT.
MT.
and this function is assigned to another function
thats what i mean with initializing the ancestor in your code
MT.
MT.
wow
i think I understood that code now
but one thing that I don't get is, what is the purpose
of such a style
can the closure be used as a constructor or something
?
22:32
$('#signup-form').on('focus', 'input', function(event) {
  // ancestor => div.control-group
  var ancestor = $(this).parent().parent().parent();
you have this line
right
MT.
MT.
yeah
instead you should have something like :
$('#signup-form').on('focus', 'input', function(ancestor) {
  return function( event ){ /* the rest of code */};
}(this.parentNode.parentNode.parentNode);
in my original example it would be same as :
var foo = function ( data ){

     return function( bar ){
        console.log( bar + '-' + data );
    };
}('batman !!');
foo('nananananana');
foo('nom-nom-nom');
this way you can inject any ancestor you want in your function
it's a minor change, which makes the code more flexible
MT.
MT.
wait, let me understand that
watch that 3rd lecture , and then come back =P
we will still be here
MT.
MT.
okay. will do it right away
22:37
needs tea
MT.
MT.
before I even start watching it, I want you guys to know that I am extremely thankful to you guys for helping me out. Thank you so much. Now I will watch that and get back to the room.
23:33
@tereško do you beatbox?
no
since i have no idea what it is
@tereško It's when you pretend your mouth is a drum.
not since i was 10
I just want to see some video of @tereško owning it up at the arts (dance/song/talent) etc
23:41
there are almost no pictures of me online
i tend to be on the other side of camera
My appearance changes every 6 months, it just kind of happens like that.
There are tons of pictures of me around the interwebz. Only this one since the moustache, though
Is this guy from our chat here?
@Cinsoft, Cincinnati, OH
As Seen on Television
4.7k tweets, 158 followers, following 3 users
He sounds like one of us.
user1385191
nope
user1385191
he's probably my biggest influence
user1385191
23:54
one of the most knowledgeable web devs I know
@Incognito its david mark
how you no know david mark
I don't know.
I only know people I speak to, and a hand-full of famous people.
lets say david mark is like @MattMcDonald but older
hes very heavy on the "support all the browsers ever" and "dont use third party js, every js library sucks"
23:58
Why's he well known?
@Incognito competency and aggressive public critique of libraries
he's also an old school regular from CLJ
one of the most competent javascripts of the 90s
but these days he's a bit old and cynical
So he's the intersection of the regulars here with age?

« first day (528 days earlier)      last day (4642 days later) »