
MSDN, if anyone knows, this is the
Microsoft Developer Network - a collection of various documents (plus forums, blogs, newsletters, etc.) on Microsoft products (and not only). I personally respect this resource, often use it and find it useful. But somehow it happened that recently several times in a row ran into very strange articles and code in the examples. No, I'm not talking about typos, broken links or wrong layout - who does not happen?
Here things are more interesting.
Page: Constants (C # Programming Guide)In short, the essence: the page tells what constants are, why they are needed. It is explained that a constant is such a value that is known in advance, unchanged, does not depend on user actions and other external factors. The following is an example of constants:
')
class Calendar2
{
const int months = 12, weeks = 52, days = 365;
}
Isn't it a great example of a constant - 365 days a year! Well, it would be a typo or even a complete lack of example. Well, it would have been written in some other topic where it is not important and it was possible not to pay attention. But there is no - the essence of the concept of a constant is illustrated by an example that is not a constant and completely contradicts the explained concept. Horror.
On this occasion, to me, by the way, I recall another book on C ++, where the need to use constants was explained with the emphasis that declaring a constant and using it in the code, we can do with changing it in the future to edit just one place in the code. As an example, the declaration of const double PI = 3.1415926 was given. Well, like, if the number of Pi change, then you will need to change only in one place. :)
Page: override (C # Reference) (open in the installed MSDN 2008 and without the htp: // prefix)
In short, the bottom line: the page describes the
override modifier for the C # language. It is told that this modifier makes it necessary in the inheriting class to implement the method of the parent class. And an example is given of the base class ShapesClass, from which the Square class is inherited. In the parent class there is the Area method, which is not defined there, but with the override attribute, but in the Square class there is its implementation. The square of a square is counted as the width of a square multiplied by the height of the square. :) I even had a doubt that “square” is a square (maybe a rectangle). But no - both Google and Yandex and lingua use the first and main translation of the word to write exactly “square”. A rectangle is a “rectangle”.
Code example:
abstract class ShapesClass
{
abstract public int Area();
}
class Square : ShapesClass
{
int x, y;
// Because ShapesClass.Area is abstract, failing to override
// the Area method would result in a compilation error.
public override int Area()
{
return x * y;
}
}
Here, in fairness, you need to recognize that in the online version of MSDN, something near the end of 2009, the page was
corrected to:
public override int Area()
{
return side * side;
}
Well, I am glad that science does not stand still and such advanced achievements as the method of calculating the area of ​​a square are available in MSDN already in 2009.
Page: description of dns tag in WCF configuration schemeIn short, the essence: the dns tag allows you to specify what DNS is in essence - matching the host name with the IP address. The dock is written correct, and the example is, in principle, working and normal. A wide smile is an explanation of the example:
"... Users can remember display names such as
http://go.microsoft.com/fwlink/?prd=10929&pver=3.5&plcid=0x409&clcid=0x409&ar=MS&sar=MS or ..., easier than number-based addresses , such as 207.46.131.137. "
After all, remember to remember a link to a simple third-level domain with a subfolder and six parameters is better than a complex IP address of 4 numbers. :)
Page: Key Scan CodesIn short, the essence: the page provides a list of scan codes for the keyboard keys. These values ​​are widely used in drivers, low-level I / O, etc. For example, I needed them to write my own Scan Codes <-> Virtual Key Codes converter, since there is no analogue of the
MapVirtualKey function in .NET, and somehow I don’t want to use the call from user32.dll. But what we see in the link above? Scan codes are provided as a picture with a table of values ​​drawn on it. At what, judging by the quality, the picture was scanned from some book of the antediluvian year, and the poorly recognized parts were then manually circled with a vehicle. And how can I ask you to rip these values ​​from there? Rewrite? Search in Google, of course, drives and codes in the form of text are, but an example in MSDN is tin.
All examples, of course, are not critical and cause a smile and a shrug rather than resentment. But it is for us and you who are looking at this imperfect world with a fair amount of skepticism. But some young novice programmer, opening MSDN for the first time and believing in it, as the source of the highest truth, these little things can make you think about it.
Updated:
Funny oddities from
adontzPage: drink AttributeIn short, the essence: Active Directory developers have assumed that an important attribute of the user along with his name, password, phone, etc. is his favorite drink. And this information should also be stored in a database. Moreover, according to the description of the field, a favorite drink can be not only a person, but also any Active Directory object.
PS I'm not going to be too impudent if I timidly ask the minus to write a comment with comments? Thank you in advance.