

Code snippets on Microsoft website shown in form of images.  - aashu_dwivedi
http://msdn.microsoft.com/en-us/library/ff512385.aspx

======
danielhunt
I think a more disturbing detail here is the alt text being used on the images
themselves:

    
    
      Description: \\christw4\c$\TranslatorHelp\en-us\GSG_files\image014.png
      Description: \\christw4\c$\TranslatorHelp\en-us\GSG_files\image015.png
    

_edit_ formatting

------
_delirium
Curious. Sometimes people do that sort of thing to avoid copy/pasting, but I
wonder if in this case it's a poor man's way of getting syntax highlighting on
the web: just screenshot an IDE instead of dealing with a syntax-highlighting-
in-HTML tool.

~~~
ryan_s
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.

~~~
brudgers
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.

~~~
lr
Yes, much to Bill Gates' dismay: [http://gizmodo.com/5019516/classic-clips-
bill-gates-chews-ou...](http://gizmodo.com/5019516/classic-clips-bill-gates-
chews-out-microsoft-over-xp)

~~~
bostonpete
What does that article have to do with the standardization of
form/presentation?

------
ap22213
Based on the formatting, it looks like a screen capture from Visual Studio.
Ugly.

Probably just some poor soul trying to meet some arbitrary deadline, and the
screen shot and crop method was the easiest solution. Or, maybe they were the
first person in a workflow, and they had no idea that it'd be translated into
web content.

Not defending it, but just saying - I've been there, and I'm sure you have,
whether we like it or not.

------
mattgreenrocks
Someone please explain how this isn't a Reddit-esque tempest in a teapot?

Sure, it's silly, but getting angry over it? Ridiculous.

~~~
smackfu
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?"

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

------
EpaL
More importantly, that is some of the nastiest looking JavaScript I've seen in
a while.

I think MS are doing everyone a favour.

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

~~~
WesleyJohnson
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 the time to
assign the "en" abbreviation into the "english" variable, then you should use
it when assigning to "currentLanguage", in my opinion, if only to avoid typos
and redundancy.

    
    
      var spanish = "es", german = "de", english = "en", currentLanguage = english;
    

The "disclaimer" element is accessed using the documentGetElementById DOM call
twice. javascript is getting faster, but forcing multiple DOM calls when it's
not necessary is bad practice. Ideally, you'd access it once and save it into
a reference.

    
    
      document.getElementById("disclaimer").firstChild.nodeValue = response;
      var text = encodeURIComponent(document.getElementById("disclaimer").firstChild.nodeValue);
    

vs

    
    
      var disclaimer = document.getElementById("disclaimer"), text = disclaimer.firstChild.nodeValue;
      disclaimer.firstChild.nodeValue = response;
    

The code formatting is poor and inconsistent, notice an incorrect space after
"encodeURIComponent (", but no spaces after "getElementById(" and
"getElementsByTagName(". Also notice no indentation anywhere, or line-breaks
after the function signatures and opening brackets "{";

The code is polluting the global namespace by not being enclosed in its own
namespace or perhaps an immediately executed anonymous function.

I'm sure more seasoned JS devs can list some more things wrong with the code,
but those are the ones that stood out to me.

~~~
ward
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`.

~~~
WesleyJohnson
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?

~~~
masklinn
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;

~~~
ward
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.

------
Ubersoldat
Come on!

<http://www.bing.com/search?q=code+highlighter+online>

------
abraham
On the plus side having to manually type all of it will help developers learn
it better.

------
JonoW
Keep in mind that most of the MSDN has copy-pasteable links (at least last
time I checked, i.e. this morning), e.g. the entire set of .NET BCL reference
docs. But, they don't use a syntax highlighter on those, boo to them.

------
tathagatadg
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.

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

~~~
memoryfault
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?

------
malkia
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.

------
petercooper
How else can you guarantee how it will look in a feed reader (many of which
strip styles or ignore stylesheets)? The Web is one thing, the places that
ignore your styling.. quite another ;-)

------
pearle
Any reason why they would want to prevent the code from being searchable from
external search engines? Software patents..etc.

------
wpeterson
How else can you get it to work in IE?

~~~
astrodust
More <font> tags.

------
adhipg
Since the page is all about translation, could it be to avoid online
translators (like Google Translate) to attempt to read that code and translate
it since you expect many of the visitors to the page coming from a locale
different than English?

Or, does Google Translate etc. handle this and not attempt to 'translate'
code?

------
iamandrus
I'm OCD about code, and that Javascript makes me want to rip my hair out.

~~~
brudgers
I suspect that the C# from which asp.net generated the javascript is far
closer to your standards.

------
DrinkWater
I hope it was an accident/mistake, otherwise it makes Microsoft look
ridiculous as fuck.

~~~
aChrisSmith
For a company of 92,000+ people I am sure there are at least a few C and
D-level people in charge of MSDN content.

However, for a company of 92,000+ people, I would have also assumed there
would be a standard tool or process for doing this sort of thing.

Edit: updating employee totals. Holy crap MSFT is big.

~~~
brudgers
I suspect that letting people do their own thing when it comes to placing
content on the web is based on two historical features of Microsoft.

The first is that because many Microsoft employees were strongly engaged with
computers, there were many early adopters of the internet and more importantly
the web (Microsoft.com registered in 1991). I suspect that the anything goes
culture of the wild west days of the web persists to some degree within the
organization.

The second historical factor is that there were a lot of employees with fuck
you money during the early days of Microsoft's web presence and Microsoft
management didn't waste resources forcing developers to heel to the sacred
ideas of branding experts.

If you dig around Microsoft, you will find lots of standard tools - e.g. MSDN
has a fairly consistent graphic presentation when it comes to technical
documentation - it just looks nothing like Channel9. However, these
differences, while not ideal for consumers, are pretty much irrelevant when it
comes to supporting developers.

Yes the bitmap code snippets are embarrassing but not in a Facebook security
hole kind of way. Any developer doing .NET programming isn't going to be
greatly slowed down by typing in the code rather than copying and pasting from
the MSDN page.

------
maximusprime
It's a step up. I think they used to use silverlight to show code snippets.

------
bmaeser
i am so sad now, i event cant find proper words for a meaningful comment

