|
Couldn't resist adding some "Community Content" on what I found looking through Microsoft documentation.
=========================================
"layoutRect
RectangleF structure that specifies the layout rectangle for the string."
What an inane comment! So layoutRect specifies the layout rectangle! Who wouldda thunk?? What would we do without Microsoft to point out the obvious, while not giving a goddamn clue HOW a layout rectangle is relevant to the goddamn measurement!
It's idiotic comments like this that make Microsoft "help" the butt of jokes!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
I remember a time some 15 years back when I was asked to implement some OLE2 features in our application (i. e. some views on Excel tables, both for entering and reading data). I looked up official documentation of OLE, but pretty much the only information it turned up was a pointer to the documentation of the Excel Automation Interface. This documentation looked something like this:
SetViewRectangle(Variant, Variant, Variant, Variant)
And that was it. No explanation of the function, or even argument names to indicate which is which! While the purpose was halfway clear from the function's name, I had no idea about the type and unit of the parameters, or whether it was top left x/y, bottom right x/y, or bottom left, top right, or maybe bottom right plus width and height? And that was the easy part, at least there was only a small number of possible ways.
The problem was that the documentation was like that for Every. Single. Function.
Fortunately that wasn't the only available documentation: there were in fact some quite useful books out there, just none by MS. But even those books didn't help when I migrated the application from Win NT to Win95, and found the effect of that function to be totally changed! I had to trial-and-error all over again to find the correct use of the function
|
|
|
|
|
I've gotten to the point where I simply exclude any results from MSDN. It's worthless. I think the thing I hate the most is their "samples" which generally don't compile and more often than not have absolutely no relevance to what you're looking up. My favorite though is when you hit F1 over a method of a .net class like say Page.LoadControl and instead of outlining the parameters for LoadControl instead it just coughs up the general Call() help article. Because I was unaware that I was calling a function? Bastards!
|
|
|
|
|
Agreed about the examples though I finally found out how they are created and feel more for the creators and the process than the examples.
Anyone that works in Microsoft Consulting is expected to "remain up to date on most current technology". Of course, the only way to demonstrate that is to write samples of the code. So they are required to be the ones to create the examples, usually at night, after 8-10 hours of coding for a client, when they should be spending time with their families.
|
|
|
|
|
Microsoft is not the only one. Step 7 of Siemens (PLC Programming) is most like that and sometimes even worst
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek wrote: PLC Programming PLC programmers can't.
I have personal experience with them. "You mean I have to install the TCP/IP module to make this work?"
Software Zen: delete this;
|
|
|
|
|
My "favorite" was the documentation for encryption. I was charged with programming the AES 256 encryption of credit card numbers. I don't have the exact code handy but the MS example was virtually this...
Create Key
Create Salt
String = "Test"
Encrypt String
Decrypt String
If I hadn't already created an encryption plugin for SQL Server 2000 by ripping the AES guts out of TrueCrypt and encapsulating it in a C++ wrapper, I would have been totally lost.
Psychosis at 10
Film at 11
Those who do not remember the past, are doomed to repeat it.
Those who do not remember the past, cannot build upon it.
|
|
|
|
|
The funny thing is that you can actually find two different docs on MSDN about the same subject; one explaining well and the other useless.
I think that MS do not pick their authors very well, some are good and some are clueless about documentation skills.
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
"Our heads are round so our thoughts can change direction." ― Francis Picabia
|
|
|
|
|
What I hate is having to go to Google to do a worthwhile search on the Knowledge Base.
Those aren't bugs, they're randomly generated features.
|
|
|
|
|
I believe Microsoft does this intentionally in order to get "support" revenue.
I do know I was hired for a couple of months to create SharePoint documentation. We were told specifically to not explain anything. Make sure to be totally accurate, be sure to read the code so you understand what is the purpose. That's so you don't accidently contradict it, but also don't document it. I think we blew it, because our documentation was better than the usual you see from MS.
|
|
|
|
|
Alan Balkany wrote: "Community Content" is a joke as the community is not keen on updating it. A very loose patrolling of community content by Microsoft as its not 'popular'.
|
|
|
|
|
|
"Do not stop moving the mouse until all the data has been returned to Microsoft Excel. (...) it may take several minutes."
They must have had fun while writing this insanity.
I have just imagined a group of developer all... moving their mouses... for several minutes
Greetings - Jacek
|
|
|
|
|
I just refactored this:
if (requiresLocking)
{
Monitor.Enter(lockerObject);
}
if (requiresLocking)
{
Monitor.Exit(lockerObject);
}
Where requiresLocking is a variable passed in to the function.
Into this:
object thisLocker = new object();
if (requiresLocking)
{
thisLocker = lockerObject;
}
lock (thisLocker)
{
}
I am afraid that the original version was my own code and I am still not happy with the modified version.
Second thoughts: on looking at requiresLocking it will be true except in rare and unusual conditions (for example the application or windows is crashing.) In those conditions I can accept the extra delay of acquiring a lock
I changed it to:
lock (lockerObject)
{
}
|
|
|
|
|
Member 2053006 wrote: object thisLocker = new object();
I hope that isn't a local variable. (It needs to be a field.)
|
|
|
|
|
How about this:
public void OriginalMethod(bool requiresLocking, object otherParams)
{
if (requiresLocking)
{
lock (lockerObject)
{
LotsOfCodeMovedToNewMethod(otherParams);
}
}
else
{
LotsOfCodeMovedToNewMethod(otherParams);
}
}
|
|
|
|
|
I would not do that. Conditional locking controlled by a parameter would introduce a nasty possibility for bugs. If this method is called from many different places it would be hard to ensure that requiresLocking is indeed set to the right value. If there is a way to determine this in the method itself we would not need this parameter.
If the method workes with data that is shared between threads, then it should always be locked. Conditional locking very probably so little a benefit that it's not worth the possible bug hunt.
I'm invincible, I can't be vinced
|
|
|
|
|
Your last version is the simplest and probably the best. Conditional locking with the help of a boolean parameter would only introduce an external source of bugs while (probably) bringing only unnoticably more performance.
What you really should take a look at is the 'Lots of (ahem, good) code here' part. Holding a lock for a longer time may reduce the benefits of working with several threads to zero. You may end up with the performance of a single threaded application. Breaking up the code, identifying smaller critical sections and using several short locks in those locations may help a lot.
I have worked on my own UI. There is an application thread, which of course often makes changes to the controls or their properties, and there is a rendering thread to draw the UI. Not synchronizing those two threads leads to ugly graphical effects when the rendering thread catches the application thread in the middle of some changes. Now I could simply lock the entire control tree when rendering or when making changes to the UI. This would work, but one thread would come to a complete halt when the other one is doing something.
Instead, I never lock the entire tree, but only the one control that is currently going to be rendered or changed. One huge lock has been replaced by many brief locks. This way the two threads collide far less often (only when they happen to access the same control) and if they do, then the wait for the other thread is only brief. Locking is always a manner of 'as much as needed and as little as possible'.
I'm invincible, I can't be vinced
|
|
|
|
|
Very good explanation and clear example
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood
'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
|
|
|
|
|
don't forget to check that your current process owns the lock after setting it - another process may have locked it between you checking if its locked and you locking it
|
|
|
|
|
We have a tool to generate HTML reports. And in this generated HTML we have links in between sections. Those links are very useful for jumping in between sections. However, When the HTML is saved/moved to another location, all the links started to fail.
Simple inspection of the HTML source revealed the problem. All the links used were like this:
<a href="file:///C:/Documents%20and%20Settings/krumia/Local%20Settings/Temp/20120301-00035.html#ta026A3538">some text</a>
They used freaking absolute paths. Could have just used the section anchor #ta026A3538 .
Now think of the disadvantages: (a) As soon as you save the freaking file anywhere else it will be useless. (b) File size increases because of long absolute paths.
Peace, ye fat guts!
|
|
|
|
|
That's one way to license your product. Won't work on other machines.
|
|
|
|
|
Interesting how the hard coded URL has the word krumia in it!
"You get that on the big jobs."
|
|
|
|
|
he he
I replace my actual username with krumia.
Peace, ye fat guts!
|
|
|
|
|
Haha, I remember one government site. That entire site was developed in the local windows based PC and when they upload it to the linux server all the freaking path was absolute "C:/Program Files/PHP/WWW/....."
Mentally disorder will do better work than that one
|
|
|
|