Code snippets on Microsoft website shown in form of images.
msdn.microsoft.com
msdn.microsoft.com
Description: \\christw4\c$\TranslatorHelp\en-us\GSG_files\image014.png
Description: \\christw4\c$\TranslatorHelp\en-us\GSG_files\image015.png
edit formattingIt all depends which area you are in.
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.
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.
Sure, it's silly, but getting angry over it? Ridiculous.
I think MS are doing everyone a favour.
Readability is something you need to be aware of, but don't worry about learning bad practice. You'll become opinionated pretty quickly on your own.
So true.
The formatting is non-existant. That makes me angry. Because I have OCD. Most programmers do.
There's a lot of direct use of DOM traversing, which makes the code rather brittle. (Use a css selector for binding to the DOM - jQuery is the de-facto standard tool here).
Variables are not encoded in the URL. And when it is, it happens on a separate line from where it's used. That's just bad style.
Oh, and what's the point of those declared-but-unused variables (`spanish, german, english`).
And why aren't they in a hashmap?
I assume you mean fake, self-diagnosed OCD, then.
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.
var x = 0, y = 1, z = 0;
// Some looping or similar here
I do agree with your using of `english` variable to assign `currentLanguage`.Using a single var and putting each declaration on its line is not incompatible:
var foo = 4,
bar = 5,
baz = 6,
qux = 'quux; var foo = 4,
bar = 5,
baz = 6,
sprinkles = 'wee';
qux = 'quux';
Making `qux` global.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.
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.
Or, does Google Translate etc. handle this and not attempt to 'translate' code?
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.
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.