|
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
|
|
|
|
|
Sigh...read this (again):
http://www.cs.utexas.edu/~EWD/ewd02xx/EWD215.PDF[^]
Note that Dijkstra is speaking specifically about "higher level" languages. Assembly level code will never dispense with the goto statement, because it maps directly to the machine JMP instruction. Very efficient. But this can't justify their use in a higher-level language.
Hhigher-level programs should represent complex logic through abstraction. In OO languages, complexity in a method is usually an indication that the object model should be refactored...without using goto.
|
|
|
|
|
|
Well, that was the biggest bunch of tripe spouted as an erudite document that I've read since college. That's worth the hall of shame all by itself.
It's stored as images when HTML text would be much more readable, manageable, and condensed in storage costs to boot.
This guy is using circular logic to justify not supporting the GOTO command, which I found ironic.
They copyrighted something that anyone should be ashamed to claim as their own.
Spell-checkers have been around forever, I'd have thought a professor might have found one by now.
I have to admit that I started hating GOTOs several decades ago when I read one tome without a single comment in it and as near as I could tell about a third of the code was dead code. I'm predisposed to like a document that advocates this concept and I didn't see one valid argument given.
Says it produces errors, which I've seen firsthand, but doesn't explain why they are produced.
The only reason you'd need to re-read it, is if you are searching (again) for its logic.
I kind of liked the original poster posting it like it is a document worth reading, but puts it in the hall of shame. Eliminating GOTO statements deserves a well written document. That wasn't it.
|
|
|
|
|
Well, that "tripe" was written by Dr. Dijkstra who is considered to be the father of programming languages and much of the framework of what we call computer science today. If you actually read the beginning it was also written in 1968, on a typewriter. You ever seen one, child? There is no spell checker on an IBM Selectric.
I also have seen developers today utilize GOTO: in C# which makes me shudder!
|
|
|
|
|
Just started working on some objective C code today and been giggling quite a bit. I thought I'd post this little gem.
NSString *dateCompletedTitle = [[NSString alloc] initWithFormat:@"%@", NSLocalizedString(@"PDFCompletedKey", @"")];
Creating a string to return a localized string that's formatted as a string by creating another string. Even better, the application only supports one language, English.
And if you did localize it to support a number of languages, the translator would have no idea of what PDFCompletedKey was as there is no comment.
Life's too short to refactor this project.
"You get that on the big jobs."
|
|
|
|