Nov 20, 2013 21:33
so tl,dir; avoiding static methods helps us to work around one of Java's defects. but it comes at a price of course
Nov 20, 2013 21:29
sorry for all the socratic questions -- looking back, I really sound like an ass
Nov 20, 2013 21:27
and so whether one chooses to use statics or to inject everything -- the solution will be unnecessary complicated, due to Java
Nov 20, 2013 21:27
because of the way java forces us to use statics and methods, things get complicated -- that would otherwise be much simpler
Nov 20, 2013 21:26
something which maybe I didn't do a good job of explaining is that I feel that the Java language is part of the problem
Nov 20, 2013 21:17
@bstempi I have to apologize, but I no longer think I get what you're asking -- and I haven't mentioned testability a single time. ... ??? Given the paragraph I quoted, I thought your question was something along the lines of what are some of the issues involved with using static methods in a factory; I have tried to answer that. Again, sorry if that's not what you're looking for.
Nov 20, 2013 21:17
@bstempi I'm sorry, but I can't help feeling that you're moving the goalposts (again, I apologize if you're not). If those extra details are important to the question, I would recommend adding them to the OP.
Nov 20, 2013 21:17
@bstempi it seems we simply don't agree on the points I've made -- I guess I just place more importance on coupling and higher-order code than do you. Which is not to say in any way that you're wrong. Just that we disagree.
Nov 20, 2013 21:17
@bstempi why do you think they didn't play a part in your answers? Looks to me like they did. Why do you think they would say something like "it's good to inject everything"?
Nov 20, 2013 21:17
@bstempi but it seems you've missed my points about coupling and passing methods around.
Nov 20, 2013 21:17
@bstempi I was going for a bit of Socratic method there. I guess I suck at it.
 
Jun 24, 2013 23:25
@JimmyHoffa no problem, good luck :)
Jun 24, 2013 23:16
haven't tried it yet
Jun 24, 2013 23:16
Jun 24, 2013 23:14
@JimmyHoffa exactly, you can't assign inside a single function because the assignment won't get executed until later ... when the outer variable has already changed to a different value
Jun 24, 2013 23:10
@JimmyHoffa yeah -- so there's really just one kk variable, and all of the closures point to it by reference
Jun 24, 2013 23:08
@JimmyHoffa right, you can only create variables in a function scope or in the global scope
Jun 24, 2013 23:06
@JimmyHoffa but where is j ?
Jun 24, 2013 23:02
yes? is that similar enough? making sure that we're on the same page
Jun 24, 2013 23:01
but without the jquery dependencies
Jun 24, 2013 23:01
var fs2 = [], k = 0;
while (k <= 4) {
    var kk = k;
    fs2.push(function() {
        return kk;
    });
    k++;
}
Jun 24, 2013 23:01
this is similar to your example: