|
ErikDD wrote: *grins* I happen to be one of the relatively few people who actually speak Dutch (aka a Dutchman) but I do appreciate the effort
ErikDD,
A hidden Dutchman! Very drole. And very hard to tell from your English, of course. I have always thought the Dutch speak the best English in Europe. BTW, how was my Dutch translation of the code? I speak English, French, German and two Australian Aboriginal languages, but alas no Dutch, which, if I could find the time I would try to learn. I also have only a Dutch to German phrase book (relic of a vacation in Amsterdam when I lived in Germany 20 years ago), so it was a bit tricky trying to put together a proper translation, and you don't get any nuances from Babelfish.
Thanks for the sly humour! You definitely made me laugh.
Anthony
|
|
|
|
|
arc_10spd wrote: I have always thought the Dutch speak the best English in Europe
What better than the British? Yeah, you may have a point - have you heard some of our dialects!
|
|
|
|
|
I wouldn't have guessed from your translation that you weren't a Dutch speaker, it was right on the mark
As for the homour..I have my good days
Erik
|
|
|
|
|
Hint: use <pre> when formatting code - much more readable
The .NET Framework does supply some operations to find out whether an operation is possible, rather than throw an exception in case of failure. In the case of the above code, you should use int.TryParse instead of Convert.ToInt32 (.NET 2.0 - in .NET 1.x you have to use Double.TryParse then cast to int ), which will return a bool to indicate whether it could convert it.
Lookups in a Hashtable will also throw an exception if the key isn't found. To avoid this, test for the presence of a key using ContainsKey .
Exceptions are slow. Avoid them where not necessary.
|
|
|
|
|
Exactly my point, a catch block is to handle unexpected exceptions, not for program logic. If the exception is not being handled by the catch block, whats the point in using it?
Thank you for your comment Mike.
Regards,
Marco
|
|
|
|
|
|
<br />
<br />
try<br />
{<br />
FileStream fs = new FileStream(name, FileMode.Open, FileAccess.Read);<br />
using (fs) { fs.Close(); }<br />
}<br />
catch (Exception){continue;}<br />
And these are people I am actually supposed to work with
Ad. Btw the 'user' mentioned here doesn't even exist..this is code running in a Windows NT Service. What the author wants to do (I think ) is see if the user for whom he's retrieving the list of files has read permissions on the file, not the Windows NT User the Service is running under.
|
|
|
|
|
ErikDD wrote: What the author wants to do (I think ) is see if the user for whom he's retrieving the list of files has read permissions on the file, not the Windows NT User the Service is running under.
And your solution would be??
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Ah, I'd have to admit that I have no idea Afaik, this is one of the things that despite the power of the .NET Framework is still either very difficult or misunderstood.
I'd start my search in the FileIOPermission and the WindowsPrincipal/-Identity classes and see where I end up from there. Might be completely wrong though.
In any case the above check checks the Windows NT Service account's access, not the requested user's.
|
|
|
|
|
Clickety[^]
[edit]I forgot: read the discussion, too...
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
Brilliant! I'll give this to my colleague to break his head over
|
|
|
|
|
I especially loved this snippit of code I encountered while rewriting an app:
<br />
FileInfo fi = new FileInfo(name);<br />
<br />
DateTime dt = fi.LastWriteTime;<br />
<br />
int yr = dt.Year;<br />
if (yr >= 2000)<br />
yr -= 2000;<br />
else<br />
yr -= 1900;<br />
<br />
string year = yr.ToString();<br />
if (yr < 10)<br />
year = year.PadLeft(2, '0');<br />
<br />
<br />
<br />
string date = dt.Day + "/" + dt.Month + "/" + year;<br />
Do I even need to post the alternative??
Me and my colleague (NOT the one who wrote the code. Spent at least 15 minutes laughing about the TODO: comment, too. :p
|
|
|
|
|
I was rewriting an application when I came across the following snippit:
<br />
System.Text.UTF8Encoding encoder8 = new System.Text.UTF8Encoding();<br />
System.Text.Decoder utf8Decode = encoder8.GetDecoder();<br />
byte[] todecode_byte8 = Convert.FromBase64String(_body);<br />
int charCount8 = utf8Decode.GetCharCount(todecode_byte8, 0, todecode_byte8.Length);<br />
char[] decoded_char8 = new char[charCount8];<br />
utf8Decode.GetChars(todecode_byte8, 0, todecode_byte8.Length, decoded_char8, 0);<br />
_body = new String(decoded_char8);<br />
Obviously, the culprit ".NET" programmer responsible kinda missed the alternative solution:
_body = Encoding.UTF8.GetString( Convert.FromBase64String( _body ) );
And I wish this was the only occurrence of this..
|
|
|
|
|
Could have been me -
I remember myself digging through that Encoding documentation in MSDN - it is really badly documented, no concepts, just a bunch of classes and members. (IIRC I had to serialize to/from base64, and it was driving me crazy)
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
Oh I couldn't agree more on the level of documentation on this (or the lack thereof). If I were writing this, a little voice in the back of my head would go 'Come on man, there's an easier way to do this, right?'. And I've taught myself to listen to that voice
That, and using the Convert class A LOT :p
|
|
|
|
|
ErikDD wrote: a little voice in the back of my head would go 'Come on man, there's an easier way to do this, right?'. And I've taught myself to listen to that voice
I've got that voice a lot lately... but obviously, it only tells YOU about the solution
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|
|
Ooo I feel special
|
|
|
|
|
Once had the great pleasure of having to examine our banks End of Day processor.
part of the app had the ability to show the account transaction records, which they used to dump transactions to luvly excel spreadsheets for analysis....
the guy who wrote it obviously had never heard of SQL joins though
he used a SQL statement along the lines of "Select * from tran" to retrieve all the records, then entered into a mother loop.
for each row in result<br />
for each column in the result<br />
if the datatype is a int, it must be a foreign key <br />
do a whole load of messin to work out the foreign key table<br />
so do another sql statement to pull back the foreign key value from another table<br />
output the foreign key value<br />
else<br />
output the value<br />
end if<br />
next column<br />
next row.
worked out that each time a new transaction was entered onto the system this loop would have to do another 60 or so new SQL requests.
so instead of one sql query using multiple joins to get foreign key values, this numpty wrote over 60 queries, which fired for each and every row output.
and considering this was only a weeee bank, We did only have in the region of 5 million transactions with about another 100,000 or so a month getting added..
and they wondered why it could take ages to display only a few hundred thousand records and output them..........
|
|
|
|
|
Once upon a time, I had to maintain an MS Java application (first shame). In this application, threads were synchronized using the window-based interface.
At the start of a task, a thread was given a reference to a label. The thread was started and changed by itself the text property of the label to some kind of status. In the "textchange" event of the label, the text was checked. If it equalled "100%" another thread was started following the same pattern.
/Zorbek
|
|
|
|
|
I develop software to control scientific instruments. This is a different world to databases or financial software. The first rule is to insist on the electronic and mechanical designers proving that the hardware is working properly before you will consider that the software has a bug. (The first rule of the mechanical and electronic designers is, of course, "the software is faulty"). The second rule is that just when you've got it all working properly they will change the hardware.
I once worked on software to control a mass spectrometer. This detects a particle beam travelling down a vacuum tube. There were two types of detectors, the instrument could either be fitted with "high detectors" or "low detectors".
I was looking through the source one day when I came across this user error message (without the stars of course).
"Both high and low detectors fitted. B******S, THEY PROMISED ME THIS WOULD NEVER HAPPEN."
Regards
- Roger
|
|
|
|
|
That was hilarious. Thanks for sharing.
A friend is, as it were, a second self.
- Marcus Tullius Cicero
|
|
|
|
|
NOT SO FAST !!!!
Okay you think this is just horrible, and 99% of the time I would agree with you. However, let me explain my experience with this exact situation. I worked at a company where we had the usual daily meeting. The guy sitting next to be asks our manager about a request he's working on. The question went something like:
"This process compares records in out database to the client file and performs calculation "A" which is saved to our database. So, what do you want me to do if a client record cannot be matched up to an record in our database?"
To which the manager said, that will never happen. Being the logical programmer my buddy replies, "but what if it does happen?" To which Mr. Stubborn manager replies, "I just told you that it will NEVER happen.
Hence, the origin of the error message. Given the circumstances, wouldn't you cut this guy some slack?
|
|
|
|
|
It wasn't flagging the situation that I thought was the problem, but calling his colleagues b******s in a message that would be displayed to the users.
By all means write it to an internal log file or something, but don't swear at the users, it's not very professional.
Regards
- Roger
|
|
|
|
|
Color me stupid, I thought the b*****s was the person's name. Note, my initials are B.S. In my case, the manager's name was put into the message replacing the b******s.
Now that i understand your true meaning...
I have a client who is paying top price for a website face lift. I was doing an A/B compare on the test release of the site in FireFox and IE. I must admit they did a good job with absolutely no difference between the two browsers. Curious as a cat, I decided to view the source code in hopes of getting the link to their Java Script file and any style sheets for future reference. Paging down in the source i found a hidden DIV where a developer left a large does of his explicitive filled comments regarding the client. HOLY-COW! I couldn't believe what i was reading, and can't repeat any of it here.
Regardless, it's all pretty funny stuff.
|
|
|
|
|
...so read an error message I found in a customer's code a while back.
Needless to say it didn't last long once I found it!
|
|
|
|
|