|
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.
|
|
|
|
|
AhsanS wrote: What will you call this???
That.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
why not "What the hell is thatttttttttttt"
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
What will you call this?
A mess. Needs to be cleaned up and broken down a bit.
"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
|
|
|
|
|
And what if all this mess is totally of no use???
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
A compound-complex sentence.
|
|
|
|
|
*points and laughs*
Pointless. Really.
The DateTime class can can convert a string to date.
Separating the both dates must be done manually, but the conversion can be done by the DateTime class.
|
|
|
|
|
I was just going through block of code for refactoring and found this. I wonder why is this even allowed in .net framework? What is benefit of it after all?
using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
namespace abc{
using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
namespace abc{
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
Did you paste your code twice, or is that what was actually inside the file?
|
|
|
|
|
I agree.
The using directive's only purpose is to save the developer keystrokes and obfuscate the code.
The only acceptable use for the using directive is to define an alias of a type.
And it has nothing to do with the .net framework; it's merely a compiler directive.
|
|
|
|