r/javascript • • Mar 01 '16

Udemy offering javascript course with JAVA logo

Post image
413 Upvotes

121 comments sorted by

View all comments

55

u/METALz Mar 01 '16 edited Mar 01 '16

There are so many things wrong with this picture that it could be easily posted to /r/programmerhumor

42

u/[deleted] Mar 01 '16

Here's some problems I can see:

  • Java logo

  • Non-monospaced font

  • HTML comment inside <script>

  • Deprecated attributes on <table>

11

u/maffoobristol Mar 01 '16

Three sync function calls inside an onclick is the bit that really hurt me. Also where the hell is photos defined?

4

u/azium Mar 01 '16

Where is page defined?

3

u/maffoobristol Mar 01 '16

Yep! Especially seeing as it's inside a closure. Basically, it's shit code.

2

u/sakabako Mar 01 '16

page is defined inside the onclick handler string, right before updatePage is called.

1

u/altrae Mar 02 '16

It just resets page to 0 there. page had to be not equal to 0 to even get to that reset so it needs to be defined before the if statement, and I'm not seeing that in the snippet.

1

u/sakabako Mar 03 '16

You just ruined what had been my favorite code for two days.

0

u/azium Mar 01 '16

ah your right! Wasn't expecting it there heh.

3

u/n9e9o9 Mar 01 '16

why is that bad? is it because we can't guarantee those particular calls will synchronously execute, in relation to other possible calls going on in that page?

2

u/thebezet Mar 01 '16

You want to avoid inline code as it is less maintainable – you want to have your code in one place, where it is expected to be, not attached to DOM elements in your markup, dotted all over the place.

2

u/maffoobristol Mar 01 '16

Just hideously unstructured.

2

u/theywouldnotstand Mar 01 '16

depending on what they are, they could take forever and block the UI on click.

2

u/Zhouzi Mar 01 '16

After giving it some thought, that's actually pretty close to <button ng-click="doSomething()">click me!</button>

1

u/maffoobristol Mar 01 '16

Yeah true, but then Angular makes it kinda okay by balancing that with an incredibly steeply curved, complicated structure behind it ;)

Genuinely though, the ng-click pattern of Angular is a design decision that I've never really understood. Just like React's inline templating...

3

u/Madd0g Mar 01 '16

Genuinely though, the ng-click pattern of Angular is a design decision that I've never really understood. Just like React's inline templating...

What's the problem with putting ng-click in the HTML? The entire point in angular is avoid writing DOM manipulation code for the most common tasks. Putting stuff like ng-click and ng-class in the HTML saves you from writing controller code to find that element and somehow change it - which is what you'd do in most other frameworks.

I always found that to be one of the best things in angular.

1

u/flaccidopinion Mar 02 '16

One thing to keep in mind with Angular, and React, is that you're not writing HTML in the sense of something that will be rendered by the browser. You're writing a view for a templating engine. It may look like HTML, and angular tries to keep it HTML spec compliant, but it's not being rendered by the browser, it's being read into a template by Angular.