|
Yeah. He gave the file a .CPP extension, but there was nothing really C++ about it.
WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated.
|
|
|
|
|
Tom Delany wrote: He gave the file a .CPP extension, but there was nothing really C++ about it.
That actually makes sense sometimes. If he really knows C, but wants to make use of a C++ stricter type system and catches more errors at compile time, that is a way to go.
|
|
|
|
|
C is infamous for pointer abuse. I think this would've been pretty standard C code 10 - 15 years ago.
|
|
|
|
|
The code works, so this is not a coding horror? I don't see any problem here. Maybe it's just your head. You should get a new one and then look at the code again.
Tom Delany wrote: he was forcing sprintf_s
This does not mean that he was "forcing" anything.
|
|
|
|
|
DECLARE p_cursor CURSOR FOR
SELECT TOP 1 SortDateStart AS DateStart, SortDateEnd AS DateEnd
...
This code was in a trigger...
|
|
|
|
|
What especially are you considering to be a horror?
1. Using a database trigger at all (this is IMHO the true horror here ) ?
2. Using TOP 1 without being explicit about it ?
Regards
Thomas
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.
|
|
|
|
|
Well, I am ok with triggers so far you make a sensible use of them (which is not the case for the database where I found this).
You should avoid the use of cursors with SQL Server, that is not good but most people would not call that an horror.
The point is: Why on earth would someone open a cursor on a 1 row set????
In this case it is far more simple and efficient to type: SELECT TOP 1 @A=Column1, @B=Column2.... instead of declaring a cursor, fetch the data and close it.
|
|
|
|
|
Arnaud Lhopiteau wrote:
The point is: Why on earth would someone open a cursor on a 1 row set?
Not sure. Perhaps it was a rush job at the end of a Friday afternoon and they forgot what they were supposed to be doing?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Ah, now I get it...
Sorry, I'm not very familiar reading such things. So I missed the point...
Regards
Thomas
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.
|
|
|
|
|
Assume that pTimeText is containing 2 dates seperated by space.
Like
pTimeText = "31/12/2008 15:36 29/12/2008 15:36"
this.txtTime.Text = Convert.ToDateTime(pTimeText.Substring(0, pTimeText.IndexOf(":") + 3)).ToString(Logic.DateConfigurer.DateFormatWithTime) + Environment.NewLine + Convert.ToDateTime(pTimeText.Substring(pTimeText.IndexOf(":") + 3)).ToString(Logic.DateConfigurer.DateFormatWithTime);
Guess what will above code return.
I found it in a file.
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
I call it ugly.
I call it a "code" bug.
I call it refactoring target #1.
|
|
|
|
|
Now that deserves to be listed in the dictionary as a definition of "fugly"!
Must have been a Power User who wrote that -- you know, someone who figured out how to do desktop word processing using the Calculator.
The PetroNerd
Walt Fair, Jr.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
It seems to me that your job is really really hard...
I have no words for the code snippet you presented - at least none that I will use in public.
It is enough that one has to use the word guess when it comes to source code. This IMHO says it all.
Poor you.
Regards
Thomas
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.
|
|
|
|
|
Thomas Weller wrote: It seems to me that your job is really really hard
Programming is never hard ( if it is programming )
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
AhsanS wrote: Programming is never hard
I fully agree. But psst, don't you tell this to a customer or boss...
AhsanS wrote: if it is programming
Is it ? Sounds more like refactoring/code review.
Regards
Thomas
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.
|
|
|
|
|
Re-factoring is part of programming i guess. isn't it?
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
Sure, you can see it that way...
Regards
Thomas
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.
|
|
|
|
|
|
I'm guessing the effect will be to replace that space with a newline if the Logic.DateConfigurer.DateFormatWithTime is "dd/MM/yyyy HH:mm"
|
|
|
|
|
You are wrong. It runs the same thing it gets as input. I was getting an error and i had to debug the code when i found it. that after doing all that stuff it was doing no change to original values.
Surprised????
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
Did he set Environment.NewLine to a space?
|
|
|
|
|
Actually, "that" removes the 'seconds [and milliseconds]' part from entered datetime, so "2008-11-10 08:00:30.123" => "2008-11-10 08:00:00".
Ugly, I agree.
|
|
|
|
|
Depends on what "Logic.DateConfigurer.DateFormatWithTime" is.
|
|
|
|
|
It contains "DD MMM YYYY HH:mm:ss"
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
Then the format is changed too.
|
|
|
|