|
My issue is worse, I'm still new to this and by no means am an expert, but I look at code I wrote as little as 6 months ago and think WTF was I thinking. Can't wait to see my opinion of myself in a couple years looking back at now.
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
|
Don't worry, you're not the only one. Besides, that's a good thing: It means you're learning. It also means trying to build any project that takes more than a couple weeks to build ends up taking an eternity as you continuously go back to make older stuff better, always learning just enough more to need to go back and improve the old stuff continuously.
|
|
|
|
|
happens... i often ask myself "wth was i thinking!?"
|
|
|
|
|
Came across this wonderful piece of code:
providerName="System.Data.SequelClient"
Took a while to spot!
-
Bits and Bytes Rules!
10(jk)
|
|
|
|
|
Takes me back to my first year of uni. I remember one guy who used to think the IDE was simply a way to talk to the computer, he would literal write text as if he was telling it what to do - and this was after a good few lessons. Needless to say he didn't survive the year
imagine...
what is your age?
write the users age
tell the user next year he will be a year older!
OK, so not quite like that but he would basically write the phrases the lecturer used to describe what to do...
create an int
set the int based on the users input
add 1 to the int
tell the user next year he will be 1 year older
perhaps he thought he was on a transcribing course
I may or may not be responsible for my own actions
|
|
|
|
|
Maybe he was writing pseudocode, and forgot to wrap it in a comment block..?
|
|
|
|
|
|
Is that the sequel where Russell Crow plays the mild-mannered DBA?
"You get that on the big jobs."
|
|
|
|
|
lol, and he didn't even debug to check whether it worked?
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|
|
Probably not much of a horror as it wouldn't compile and therefore can't get into the main code base...
Of course it could if the dev created a custom System.Data.SequelClient class.
Hmmm. Sounds like an easter egg in the making for an auto upgrade engine.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
There's someone working on a compiler for that. Just so you could write computer programs in natural English.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Dude... that would never happen.
|
|
|
|
|
I know I'll regret this, but sometimes even I can't help myself. Follow this link[^].
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
I guess many of you have heard about log4j, log4net, log4cplus logging libraries. I'm going to show you the worst log appender I've ever seen. It shows message boxes!
class CustomLogAppender : FileAppender
{
protected override void Append(LoggingEvent loggingEvent)
{
base.Append(loggingEvent);
if (loggingEvent.Level >= Level.Info)
{
if (Application.OpenForms != null && Application.OpenForms.Count > 0)
{
if (loggingEvent.Level == Level.Info)
{
((MainForm)Application.OpenForms[0]).MessageBox(loggingEvent.RenderedMessage,
"Application", MsgBoxButtons.OK, MsgBoxIcon.Exclamation);
}
else
{
((MainForm)Application.OpenForms[0]).MessageBox(loggingEvent.RenderedMessage,
"Application", MsgBoxButtons.OK, MsgBoxIcon.Error);
}
}
}
}
}
Let's say you need to log 100 error messages. That means that potential user is going to click "OK" 100 times . Cool, isn't it? And if this logger occasionally gets into some ASP.NET application...
|
|
|
|
|
|
Perhaps this is for debugging, but from what you have put it could work quite well anyway. It shows that only logs with error level of info or above (presume warning) are show to the user - and correct me if I am wrong but I think you should let the user no when an error has occurred (at level info or higher)
I presume there are levels such as 'Silent' or 'System' which will simply log the data in what ever storage it logs in
I may or may not be responsible for my own actions
modified on Wednesday, March 23, 2011 12:33 PM
|
|
|
|
|
You know, any logger should never show any message boxes by definition. By the way, one of our testers ran into situation with these "debugging purposes". There was a bunch (near 10) message boxes one after another. And she was tired of clicking "OK".
|
|
|
|
|
That's painful. Reminds me of when I first learned exception handling... I programmed a message box for most, if not all, exceptions...
Don't worry. I've learned.
|
|
|
|
|
I guess there are many samples of connection strings here (with asterisks instead of password, etc.). Here is another one
string connectionString = String.Format("Sever={0};Dsn={1}", server, databaseName);
OdbcConnection connection = new OdbcConnection(connectionString);
try
{
connection.Open();
}
catch (Exception)
{
return false;
}
1. I think ODBC driver has absolutely no idea what is "Sever" (and if it does, perhaps it would like more to go to the "Yuh". A joke for those who speaks Russian).
2. If it's spelling mistake (author wants ODBC driver as his English teacher), DSN already contains information about server.
3. What about user name and password?
4. DSN is data source name actually.
|
|
|
|
|
I found this piece of PL/SQL code in application exporting data into financial system.
field_number is value of field type number (precision = 2)
trunc(field_number / 60, 0) || ',' || round(100 * (field_number / 60 - trunc(field_number / 60, 0)), 2)
ok, the code is pretty subtle but..
for example: what will be the result for field_number = 10 [min]. Let me guess, 0,16,67 ?
|
|
|
|
|
I would, sadly enough, not be surprised if the financial system wants the data in this format...
|
|
|
|
|
Ouch! Your application was not set to the correct locale. It must be 0,16.67
|
|
|
|
|
I've just found an "excellent" way to detect if boolean value is true or not in C#. Just great! Important, "value" variable is System.Boolean .
string valueStr = value.ToString();
if (valueStr.Equals("true", StringComparison.CurrentCultureIgnoreCase))
{
PDFIncludeWatermark_ = "true";
}
else
{
PDFIncludeWatermark_ = "false";
}
|
|
|
|
|
haha, what a joke!
You could make this so much simpler by just having...
PDFIncludeWatermark_ = value.ToString().ToLowerInvarient().Contains("true") ? "true" : "false";
I may or may not be responsible for my own actions
|
|
|
|