|
Jörgen Andersson wrote: Considering the use of var it must be at least .Net 3.5, unless of course that was part of protecting the innocent.
Ah, good point. The vars were there in the original. It's really weird, it's as if the code was being compiled with C# (some version) but against an ancient version of .NET, because there's even reference elsewhere to StringDictionary which is pretty obsolete since generics.
Marc
|
|
|
|
|
Or it is a person who seldom worked with .NET and had to bring up a solution for yesterday. I have the same issue with old code written in VB6 by "programmers" who at the time used QBasic (yes, first instance of our software worked under DOS).
Besides, today there is .NET 4.6something, I only worked with 3.5 so I would probably write code which does not use any new functionality due to lack of experience / knowledge of them.
DURA LEX, SED LEX
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani
|
|
|
|
|
Like den2k88 wrote, it's probably someone not being used to the language, or even more likely, the framework.
That parsing is just scary, but probably made by someone in a hurry.
|
|
|
|
|
Did you notice this?
List.Add(N1 + "," + N2 + "," + N3 + "," + N3);
N3 is added twice.
N4 is never added.
|
|
|
|
|
I'm guessing that was a typo by Marc. At least I'm hoping it was...
|
|
|
|
|
I thought he copied the code and changed what he wanted to preserve identity...
So, it must be part of the real one. I think.
|
|
|
|
|
Paulo Zemek wrote: N3 is added twice.
That was my typo.
Marc
|
|
|
|
|
Hehe... OK.
I thought I was another coding horror... you know, complete lack of testing.
|
|
|
|
|
Possibly a cut and paste job from the internet by someone not familiar with C#, .NET or programming in general.
Could well be a port out of C, C++ or VB6. Things like a private static method and module/global variables could be an artifact of another language.
|
|
|
|
|
If you are hyper-optimizing code, you can avoid allocation of an enumerator object by checking the count first if you expect that it will often contain 0 items. That said, it is obvious that this guy probably wouldn't know that, but worth noting. We've done it in very performance sensitive code that might be called many times in a tight loop.
|
|
|
|
|
Better to avoid foreach whenever possible. If there's a Count , it's probably indexable, so use for instead.
|
|
|
|
|
For performance sensitive code that could be used in long tight loops I agree, but "whenever" I don't agree with. In 95% of code it will make zero difference, so the readability and simplicity of foreach wins.
|
|
|
|
|
Oh, now I am reminded of some ODBC code (in ANSI C) I had thrust upon me in the late-90s -- query results were returned as CSV strings.
I had to write my own version that at least returned sort of an array of strings.
|
|
|
|
|
Yesterday, I put in around 5 hours making changes on a form. This was done on a laptop having a synched drive to my home-office server where the development files are kept. I've learned with the laptop that it's actually safer to copy the project from the synched folder(s) and work on them locally, then manually replace the files when I get back to the office. Anyway, I opened the project from the local directory where I had copied it and spent the day putting in the new changes, and getting it all working. Hooray!
This morning, I got out the laptop and let it synch up to the network, then opened the local folder where I had done all my work, got the files I wanted, and replaced them on the network drive. It was then that I realized that the file dates/times were wrong...I had actually been working on the offline/synched files and had just overwritten 5 hours of work! There seems to be no way to get it back either...bummer! It'll take me at least 2.5 hours to rewrite it, but I've already got ideas for improvements! (trying to be optimistic!)
"Go forth into the source" - Neal Morse
|
|
|
|
|
Use source control, either a local repository on both machines or (ideally) one with a repository both machines can access (if both have the internet you could use GitHub for example). I use SC even for my noddy projects on a local machine just in case stuff like this happens and anyone can mess up and once the code is overwritten it's gone.
|
|
|
|
|
This is one of the many, many reasons to use some form of source control. With modern editors and IDEs, the overhead is negligible and it saves you so many headachese - this scenario being just one of them.
|
|
|
|
|
No, Seriously. A Web Browser written using Bash[^]
What.
The.
F***.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Quote: The butthurtery is strong in these.
I'm laughing so hard.
cheers
Chris Maunder
|
|
|
|
|
Last commit by lawl butthurt.
The only file starts out promising
|
|
|
|
|
When you are trying to understand some weird while-if conditions in a 15-year old system in java (!). And after that the only thing you do is write.
And just try to think about a New Year coming... ("Do you have a JIRA or other issue tracker?" "No, we don't need it because we don't have testers." - "OK, what about that NullPointer on a production code?" "C'mon, after 15 years every user knows that he shouldn't click that button").
|
|
|
|
|
Yep, nothing like coming back into work after 2 weeks, settling in and seeing:
public void DoSomething(){throw new NotImplementedException();}
These are the moments when I realize that I'm an idiot.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
What. The. F***.[^]
Take 2.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I'm thinking flash in the pan. I'm not about to hop to and learn Bootstrap 3....D
After having a look at the Samsung "VR Headset", I'm 100% certain of it. That thing is so incredibly stupid.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I just came across the following comment in some code in our core application:
Care to guess when that was written? (it is still in our code now)
Answer:- I don't know because it was already in the first version of the code loaded into our version control system.
|
|
|
|
|
I went to school in a very, very temporary building that was put up shortly after World War 2. It's still going strong.
On that basis, the code should be good a few decades yet.
Slogans aren't solutions.
|
|
|
|