« first day (1496 days earlier)      last day (3447 days later) » 

3:01 PM
@Demorus Well, text.match(/Daniel(\s|$)/g), but it's probably not what you're after in your lesson thingies. What kind of solution are you after?
(and why do you care to ask here :P)
 
its more alive D
Oh well, I will just post a question
 
I didn't say that.. you asked a question to get some solution to a problem. You've got one, but I'm pretty damn sure it's not what you are learning now. So my question really was, what kind of solution are you looking for? What technique? What are you after? What do you want to learn by this?
 
fuck
 
geez. You're no help at buying a mattress...at....alll
 
do the best mattress come from the free section on craigslist?
 
3:10 PM
@jpavlov Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
Caprica Six....really?
so has anyone actually used backbone.js around here?
 
@MetroidFan2002 I've only used it long enough to develop an irrational hatred for it.
 
@Re
dammit
no autocomplete
@Retsam so what about it specifically drives the hatred?
 
There is autocomplete, you use tab, not enter to do it.
 
ah thanks
 
3:14 PM
@MetroidFan2002 Heavily at work.
It enforces no paradigms, to the point of confusion, but does the job once you figure out how you want to do it.
3.5/5 framework score
 
my problem with it, without having used it extensively, is that the set method always requires json - it should also expose a put method to have a key/value pairs (unless it does this - I haven't used it in anything important yet)
 
Set on which object? Models?
 
to me, obj.put("key", {"hey" : "values can still be json"}); is a better syntax
yeah
 
We have enough business logic that all our models have getters and setters.
 
like you always have to do model.set({"let's build some json" : "ok"});
yeah, at least backbone sorta has that concept
 
3:16 PM
@MetroidFan2002 Not sure; it just seemed ugly to me. Like I said "irrational" hatred.
 
Both to abstract the literal representation (which doesn't quite match the model, the services have changed a bit) and to enforce business rules.
I don't think we use set anywhere.
 
at work I get to fix bugs with dojo code provided to us by a third party, because they don't object orient worth a damn.
so basically things are all over the place. it's a frickin mess, it's very WET.
problem is I'm only responsible for the backend code, which rarely changes (it has to change sometimes to accomodate the frontend changes, but that's rare)
do you guys do any coding for tablets/mobile?
what's the preferred framework?
 
@MetroidFan2002 All our UIs are based on Bootstrap with a corporate theme, so that.
We do have some interesting code that checks a global mobile flag and swaps the backbone view classes.
Each view type has an Interface, essentially, and a desktop impl and mobile impl for it.
 
does bootstrap provide device feature detection? Or do you have to incorporate some other library (yes, I'm a bootstrap n00b - forgive me for stupid questions that could probably be googled)
 
3:19 PM
It worked well, but not great.
Bootstrap (and most responsive stuff) uses media queries to size things appropriately. It's only for flow, not interaction.
 
oh that's pretty neat. interfaces in javascript
 
We used a small browser detection snippet to pick the views.
@MetroidFan2002 Obviously not strictly enforced, but the app would break if you didn't implement something, so it worked.
 
hahahaha
what?
you mean you CAN'T just specify interfaces?!
MADNESS!
 
You can't do anything that might warn you of errors before running the code.
It's incredibly practical for large projects.
I'd like to see obvious mistakes before even getting to unit tests.
 
is there any good javascript compiler/validation framework thing? I've only ever tried the Eclipse js plugin, and it chokes on the dojo code we're provided.
like - it's like, "This isn't even javascript - WTF?"
 
3:22 PM
Google's closure compiler, Typescript provides strong typing, Facebook recently released Flow...
Listed by slowest to fastest.
 
hmm. so Flow is faster then.
 
They do different things, though.
TS is a language extension for EC6 features and type annotations (like the opposite of coffeescript, where everything becomes a pile of mush).
Closure compiler takes inline docs and enforces them, plus minifying and doing some static analysis.
Flow is mostly static analysis with type annotations, I believe (haven't used it yet).
 
Hmmm.
 
Good morning
 
I'm not a fan of having to annotate things. Hello @SterlingArcher
 
user1596138
3:24 PM
@SterlingArcher Good morning
 
I mean, I'm just not in general a fan of having to have code follow a set structure in order for tooling to work.
I understand that most tools do work that way.
 
If it's not built into the language, what other choice do you have?
 
but a lot of developers just aren't disciplined enough to cross the i's and dot the t's all the time haha
 
Then make them do their job properly.
 
yeah, like I have that kind of power. I wish.
 
3:26 PM
Simple incompetence is not an excuse for not using tools.
 
@BenjaminGruenbaum how do you feel about Java's abstract class/varargs capability? I just read about that last night in a book my boss gave me and I'm kind of impressed with how inheritance works/the ability to declare varargs like it does (though the ambiguity of varargs is kind of confusing)
 
"Oh, they can't be arsed to write tests, guess we won't have any." Three days later in the NYT: "Company X goes under because of dipshits."
 
hahaha
 
user1596138
 
@SterlingArcher Varargs are impressively ambiguous all over.
 
3:27 PM
well yeah I can enforce it on my team as much as possible. but unfortunately I don't really get a say in their makeup
@SterlingArcher Have you ever seen the @SafeVarArgs annotation? That is the definition of WTF
"It's safe to use...trust me, I'm a developer!"
 
Nay, I'm pretty new to Java. Haven't touched it since my sophmore year in college
 
Bascially, when you have varargs it creates an array
but any array can be an object array
 
Java sucks
 
I didn't do well in Java then, but that was because I was struggling to learn the concepts of programming. Now that I'm reading it with a bit of professional experience, it makes it easier to understand
 
so you can put in things that aren't the type of the object inside of the array and pass it back to the caller, if you want.
 
3:29 PM
Java is good at enforcing everything OO concept around, and showing you how they all can be used.
 
@MetroidFan2002 right, but I don't really understand why one would need method overrides with varargs
 
It's even better at showing you how they can be abused.
 
What's a use case where varargs are actually good?
 
PatternAbuseProviderFactoryAdapterFactory
@SterlingArcher Logging mostly.
 
hahahaha
yeah, logging is the best example. Honestly I don't know why you'd override in practice a method with varargs
 
3:30 PM
@copy lol I was of the same opinion. I'm sure I'll come to hate it once I come across a nasty issue
 
What's confusing/wrong with varargs?
 
Or List.toList<T>(T... items).
 
but I try to avoid varargs and just use List / Collection
 
@ssube I haven't gone over generics yet :(
 
It's just syntactic sugar over having the last argument be a list
 
3:30 PM
generics are awesome in that you can abuse the hell out of them
 
@SterlingArcher Generics are fun. I enjoy using them here and there, to make things stricter.
 
@Retsam well, mostly why it can throw ambiguous calls
 
but the problem is that they'll send you a null array
if the argument isn't specified
 
@SterlingArcher Example?
 
Just don't go all Boost.Spirit with generics.
 
3:31 PM
and, you can also send in an array with no elements.
 
That's a bad time.
 
I once had an interface with seven generics in the type!
 
@Retsam just a moment
 
@MetroidFan2002 s/an interface with [4-9] generics in the type/a poorly designed system/
 
static void example(int ... v) {
   //...
}
static void example(boolean ... v) {
   //...
}
example(); //ambiguous?
 
3:33 PM
no
 
How does Java know that an empty method call is ambiguous, but a boolean param will be accepted as the second override
 
compilation error
 
static void example(int[] vs) {
   //...
}
static void example(boolean[] vs) {
   //...
}
example({}); //ambiguous?
 
@FlorianMargaine let's assume the calling method is in the public static void main method, of course
 
3:35 PM
@SterlingArcher still
 
It is ambiguous, at compile-time.
 
^ Just worth pointing out that varargs doesn't introduce anything new; any issue with varargs is also equivalent with arrays, I think.
 
since there is no argument, the compiler won't find the correct overload (i.e. the suitable method with no argument)
 
@someDoge What's with the URL? It's not representative of the content.
 
@FlorianMargaine what's the error? This is basically verbatum from the book
 
user1596138
3:35 PM
@Shmiddty good question
 
@sstube it was for the idiots who didn't understand WSDL, and that we didn't have a version tag...sigh
 
@SterlingArcher no idea
 
so, let's have a different WSDL for each upgrade! yay
 
but if java can't find that... ugh
@dystroy ^ ?
you're our java expert :D
 
@ssube yes, but why?
 
3:36 PM
i.e. does this compile in java?
3 mins ago, by Sterling Archer
static void example(int ... v) {
   //...
}
static void example(boolean ... v) {
   //...
}
example(); //ambiguous?
 
@SterlingArcher Because no argument is provided, so there is no argument type.
 
^ that wont compile, because example() should be in the public static void main method,
 
I don't think it does, because yeah it doesn't know which one to use.
 
This is trying to key off the type of the first argument.
 
3:37 PM
@ssube so because it has no arguement, it doesn't know which method override to use?
 
@SterlingArcher not talking about this...
 
If the first arg is an int, it's obvious which overload to use.
 
@FlorianMargaine ok
 
that's not an overridden method
it's an overloaded method
 
With no args, both could be applied, so it errors out in the compiler.
 
3:37 PM
overridden = subclassing
 
overload sorry
I see
 
@SterlingArcher Correct. If you provide an empty alternative, that should clear it up.
 
with Java 5 rules, anything that was legal prior to Java 5 takes precedence
so providing an empty alternative took precedence over the varargs
and that would be used, even if you might want to use one with varargs
 
I guess one way to avoid ambiguous calls is to have the default method an abstract method, so that the subclass (if applicable) is forced to overload the method?
 
Yeah; I just tested it and it fails: java: reference to example is ambiguous, both method example(int...) in Main and method example(boolean...) in Main match
 
3:39 PM
@SterlingArcher If possible, avoid the ambiguity in the first place.
 
or...don't design the system in a dumb fashion
right
 
(If anybody has a problem with discussing Java I'll happily stop btw, I'd just rather discuss it here with people I know (ish))
 
I'm extremely bored, so it's cool with me. Can't speak for anyone else here of course.
 
@Retsam ok cool, it was supposed to fail, but I was just having trouble understanding why
@MetroidFan2002 I know many regulars here dislike Java, and I don't want to annoy them with nooby Java topic
 
the thing is, varargs are ok, but by the time they got added people were using List / Collection instead of arrays
 
3:40 PM
#Respect
 
@SterlingArcher Consider the function rewritten with Logger.log<T>(T... args). What is the type of T if you have no args?
 
@SterlingArcher I haven't heard anyone say "get off my lawn" yet so I think it's ok ;)
 
There's really no way to tell, so it just says no and tells you to go sort your shit out.
 
There isn't one
 
On the other hand this compiles:
    public static void main(String[] args) {
        example();
    }

    static void example(int ... v) {
        //...
    }
    static void example(boolean ... v) {
        //...
    }
    static void example() {
        //...
    }
 
3:41 PM
@ssube I.. I really don't know. Is that a generic? (I remember struggling with generics in college, and I haven't gone over them again yet)
 
sure
yeah, that's a generic
 
@Retsam right, because you have defined the no-param method?
 
it says that the type T is a wildcard type that's applied to the type of argument passed into the method that has a type of T.
 
@SterlingArcher Yes. T is a type parameter, based on the first arg, and all other args must be the same type.
 
@SterlingArcher You mean like String...?
 
3:42 PM
@SterlingArcher Right. There's a method that exactly matches your arguments, so it can be called safely.
 
Here's some generics for you:
interface ImplementMeWithAnEnum {
boolean doesHaveStuff();
}
 
Enum? Interface? D:
 
boolean whatever<T extends Enum<T> & ImplementMeWithAnEnum> (T hello);
not quite sure if it's allowed in a method call
 
Anyone able to help me here? Google recently updated to APIv3, so I've had to update my code. I'm rubbish with JavaScript so I'm not sure why I'm getting these errors? chat.stackoverflow.com/rooms/139/java
 
pretty sure I screwed that up.
 
3:44 PM
@SterlingArcher You should get a basic java book and go through the OO concepts, if you haven't.
 
boolean <T extends Enum<T> & ImplementMeWithAnEnum> whatever(T hello);
 
^ reading one now :)
 
there, that's the more proper syntax
 
@MetroidFan2002 there's a bit too much there I haven't learned yet, so I'll ask more questions when I get to generics and interfaces :)
 
@SterlingArcher Good. Make sure to find the part (or an article) where they explain inheritance in a reasonable way.
 
3:45 PM
anyways...the intent of the method is that the object type is only an Enum which also implmenents the "ImplementMeWithAnEnum" interface.
 
The whole interface X and class Y implements Y means X is-a Y
 
that way - you can force methods to accept only enums with an interface
and the dangers of subclassing
 
@TaylorWilliams not entirely sure why yuo linked to the Java chatroom there
 
I recommend Josuha Bloch's book "Effective Java Programming Version 2"
 
Dog implements Mammal, Mammal implements Animal, etc. Interface is a contract, each step down makes the contract more strict.
 
3:46 PM
Taylor we'd need to see the errrors?
@Tay
 
You can do the same in JS (_.extend and such), but Java enforces it with the compiler.
 
@TaylorWilliams tab complete. We need to see the errors to help I think
 
@ssube Sometimes. That's often what X implements Y means, but not always.
 
Java is also the only programming model I know of that has both checked and unchecked exceptions.
 
3:49 PM
checked exceptions are used improperly most of the time, which is probably why they've been abandoned
 
Sorry guys! Got so many tabs open, I don't know what I'm copy and pasting!
 
The quintessential example where "X extends Y" doesn't mean "X is a Y" is:
public class Square {
    public int width;
}

public class Rectangle extends Square {
    public int height;
}
 
@Retsam it actually is a classic (text-book, even) example of "you are doing inheritance wrong"
 
But since Rectangle inherits from Square, they are of the same type, no?
 
@SterlingArcher As far as Java is concerned, a Rectangle is a Square, yes, but that's not how we understand it.
@tereško Feel free to elaborate on that point.
 
3:52 PM
I have to agree with @tereško here - A square is a rectangle, but a rectangle is not a square.
 
@Retsam quadrilateral
 
it should be an inverted relationship
 
@MetroidFan2002 And what would "Square extends Rectange" code look like?
 
And, if you were doing this properly in Java, you'd just have a static method "createSquare" that took the height and gave you a rectangle with both the same
 
also read the commens
 
3:53 PM
because there'd be no need to have an actual Square class.
public static Rectangle createSquare(int height) { return new Rectangle(height, height); }
 
@Retsam Square extends Rectangle enforces that height == width.
 
Wouldn't it be better to have a vague superclass like Shape.. then Square extends Shape?
 
@SterlingArcher Yes.
 
Really, it just overrides setHeight(int height) { this.width = this.height = height; } and equiv for width.
 
@SterlingArcher Maybe. If there's a use for such a thing.
 
3:54 PM
@SterlingArcher No.
 
THESE ARE VERY CONFLICTING ANSWERS GUYS
xD
 
@SterlingArcher Probably, if you need other types of Shape.
 
@MetroidFan2002 Is a rectangle a square?
 
@SterlingArcher If you don't know what a Shape is, you shouldn't make a vague superclass.
 
Fun fact: there's not a single correct way to write Java, unlike what some would have you to believe.
 
3:55 PM
@Sippy If you program such that you accept rectangles, you don't care.
 
@MetroidFan2002 I didn't know a rectangle was a square, thanks.
 
@SterlingArcher You should start with an AbstractConflictingAnswerFactory to provide you with answer, then an AbstractConflictingAnswerVisitor to check if they're true.
 
@ssube Ehh, there are downsides to just enforcing height == width.
 
@Retsam True, but there are better ways than having arbitrary subclasses just to try to illustrate an argument.
 
@Retsam There are, but that's the simplest addition to Rectangle to make a Square.
 
3:55 PM
There are also downsides to "there are no squares, just rectangles, we've always been at war with eastasia", too.
@ssube Ehh, define "simplest"
I actually think my original code is quite "simple".
 
@Retsam Shortest.
 
@Retsam also, extends actual means "is a special case of", which means that the superclass can be used in place of subclass with no errors
 
Not necessarily best, but shows how Square can enforce additional restrictions on top of Rectangle.
 
But it doesn't define the contract though. A square is a rectangle, but a rectangle is not a square.
 
@ssube In a context as minimal as this who gives a duck's anus if it's shorter by one class?
 
3:56 PM
@ssube Shorter than my 6 line example (well, plus the constructors that would be needed)?
 
@Retsam You didn't provide an example for "And what would "Square extends Rectange" code look like?"
 
@tereško Yes, yes, the Liskov Substitution Principle. Which is actually violated by the "enforce width = height" method.
 
public class Rectangle {
private int height;
private int width;
public Rectangle(final int height; final int width) { this.height = height; this.width = width;}
public int getHeight() { return height; } public int getWidth() { return width; }
}

public class Square extends Rectangle {
public Square(final int height) {
super(height, height);
}
}
 
square-rectangle is a retarded example, because they would have different intefaces
 
@ssube Because I was advocating for Rectangle extends Square.
 
user1596138
3:58 PM
1: that's not formatted
2: that's java
 
^ wat?
 
@Retsam That's just idiotic
 
@someDoge SUP DOGE
 
user1596138
You *= suck
 
@Retsam Which is not good, even math people know that.
 
3:59 PM
@Retsam there is not inheritance between rectangle and square. Those two are completely different classes with completely different public interfaces.
 
@someDoge I know it's not formatted, I don't know how to format inline submissions in this chat yet.
 

« first day (1496 days earlier)      last day (3447 days later) »