Live data from Hacker News

Code snippets on Microsoft website shown in form of images.

msdn.microsoft.com

41–50 of 58 posts

Re: Code snippets on Microsoft website shown in form of images.

#42

Earlier quoted context omitted.

I am learning javascript nowadays. Can you describe, what is wrong with this javascript? So that, I won't learn any bad practice.

I'm not the most savvy javascript developer, but I'll take a stab at it. Variable declarations and assignments happen on multiple lines in the 2nd snippet instead of all being defined at once. var currentLanguage = "en"; var spanish = "es"; var german = "de"; var english = "en"; vs var currentLanguage = "en", spanish = "es", german = "de", english = "en"; Additionally, "en" is assigned twice. If you're going to take…

A lot of developers don't like declaring more than one variable on one line, that's a style choice.

There's nothing wrong with it, especially in JS where accidentally deleting a variable declaration can suddenly turn your variable global.

The problem with the code is more that the code stinks, even after you remove the formatting problems, it looks more like .Net code and it doesn't make any sense.

Re: Code snippets on Microsoft website shown in form of images.

#44
post #40

Someone please explain how this isn't a Reddit-esque tempest in a teapot? Sure, it's silly, but getting angry over it? Ridiculous.

Developers love to complain about other people's minor bugs, and yet hate it when testers open them against their own code. "Who even cares about this?"

This is why pair programming and code reviews work so well.

Re: Code snippets on Microsoft website shown in form of images.

#45
post #5

Earlier quoted context omitted.

You are probably right. I've found the MSDN pretty inconsistent. There are a number of C#/VB.net examples that don't have any syntax highlighting at all. It all depends which area you are in.

It's not just MSDN which is inconsistent. Microsoft's web presence in general varies widely. The philosophy appears to highly favor providing access to knowledge/content over standardization of form/presentation. The scale of Microsoft's web properties is vast and they do not waste resources trying to get a herd of cats to goosestep.

Yes, much to Bill Gates' dismay: http://gizmodo.com/5019516/classic-clips-bill-gates-chews-ou...

Re: Code snippets on Microsoft website shown in form of images.

#46

I would like to see how long it stays that way ... people make mistakes, but if you are on the front page of HN for a wrong reason, you leave everything aside and fix it.

I doubt the editors or developers of the MS Translator even know what HN is. I know... it's shocking.

There are plenty of MS employees on HN. I'm curious...what makes you think someone who works on translator is less likely to know what HN is?

Re: Code snippets on Microsoft website shown in form of images.

#47
post #39

Earlier quoted context omitted.

I'm not the most savvy javascript developer, but I'll take a stab at it. Variable declarations and assignments happen on multiple lines in the 2nd snippet instead of all being defined at once. var currentLanguage = "en"; var spanish = "es"; var german = "de"; var english = "en"; vs var currentLanguage = "en", spanish = "es", german = "de", english = "en"; Additionally, "en" is assigned twice. If you're going to take…

I don't see a bunch of variable definitions on one line as an improvement, just reads less easily and only feels justified in the case of some low numbers like var x = 0, y = 1, z = 0; // Some looping or similar here I do agree with your using of `english` variable to assign `currentLanguage`.

Personally, I like doing all the declarations on their own line as well. But anytime I've used JSLint in the past, I seem to recall it complaining about that. Perhaps I'm mistaken?

Re: Code snippets on Microsoft website shown in form of images.

#48
post #39

Earlier quoted context omitted.

I don't see a bunch of variable definitions on one line as an improvement, just reads less easily and only feels justified in the case of some low numbers like var x = 0, y = 1, z = 0; // Some looping or similar here I do agree with your using of `english` variable to assign `currentLanguage`.

Personally, I like doing all the declarations on their own line as well. But anytime I've used JSLint in the past, I seem to recall it complaining about that. Perhaps I'm mistaken?

I expect JSLint was whining about using multiple `var` statements.

Using a single var and putting each declaration on its line is not incompatible:

    var foo = 4,
        bar = 5,
        baz = 6,
        qux = 'quux;

Re: Code snippets on Microsoft website shown in form of images.

#49
That's catfooding right there.

The site has something to do with javascript on the web, which is very close to html/css, and it does not ever use formatting as seen on many other sites (code coloring).

(Okay, I'm total html/css/js noob, never done a web page in my life, but I think it's wrong).

And in the past examples were showing just right in MSDN, along with way to switch between C#/C++/VB/etc.

Re: Code snippets on Microsoft website shown in form of images.

#50

Earlier quoted context omitted.

Personally, I like doing all the declarations on their own line as well. But anytime I've used JSLint in the past, I seem to recall it complaining about that. Perhaps I'm mistaken?

I expect JSLint was whining about using multiple `var` statements. Using a single var and putting each declaration on its line is not incompatible: var foo = 4, bar = 5, baz = 6, qux = 'quux;

That feels like a situation that could easily end up (copy pasting something, someone adding another var, ...) in an unexpected global variable declaration.

    var foo = 4,
        bar = 5,
        baz = 6,
        sprinkles = 'wee';
        qux = 'quux';
Making `qux` global.
Post reply on HN