|
Singleton is not thread-safe, Query property is potentially recursive, and can cause null exception. Also shouldn't query container contain list of Query instead of list of QueryContainer if QueryContainer is supposed to be a singleton (i.e. having only one). Also the whole class is crazy. Why have ID counter if you're using kinda "singleton"? Also no comments on what the class does or on public members. This IS Sparta!
|
|
|
|
|
Singleton is usually one of the first design patterns people learn. They immediately fall in love with it and are become blind for any other patterns out there.
I'd say the problem with this code would be that it causes brain damage.
|
|
|
|
|
I assume the intended purpose was to create a list of recently used queries. Even though the list was never actually filled (or allocated for that matter).
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
Your warnings obviously weren't dire enough - he's back[^], with a modified version of the same class, which still doesn't fix his original problem.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Clue bat needed in Aisle 5! Clue bat needed in Aisle 5!
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???
|
|
|
|
|
Yes, I saw it.. sighed, and decided to let someone else answer since he apparently didn't believe me
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Among all the toe-curling flaws in there, these are my two favorites:
It's not even a singleton - it's a "noneton": Trying to access the Instance-property will cause a stack overflow due to recursion..
The List<QueryContainer> will be really, really short. Even when fixing the above flaw..
And the answer to the million dollar question:
It's supposed to somehow (don't ask me) help with fixing code that is vulnerable to SQL-injection.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
The new version[^] still doesn't fix the problem.
I'm running out of different ways to explain to him why his approach isn't going to work.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
He might be impervious to advice..
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I know one remarkably effective way to explain to him: use SQL Injection to delete his database. And every time he puts it back, it goes again.
It's cruel. It's nasty. It's probably illegal.
But it's what his best mate will do, just to see the look on his face...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Sascha Lefèvre wrote: It's supposed to somehow (don't ask me) help with fixing code that is vulnerable to SQL-injection.
After reading the actual questions, I don't think he is trying to fix the actual vulnerability with his code. Instead he may be trying to cheat the test system (by obfuscation) from detecting that there is an SQL injection vulnerability.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
"But please - no programming questions."
|
|
|
|
|
As you didn't mark your post as a joke or put a smiley into it I have to assume you're being serious: But my post isn't a programming question.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Here's your smiley:
Pick the one you like best. Only one per member.
|
|
|
|
|
|
I'll take the second one, please. Can you wrap it as a gift?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
******
* *
******
|
|
|
|
|
Very nice, will order again
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
With reference to this article[^], one of the young developer argued with me that the User object in asp.net application is singleton and Singleton class is used to store value in Session.
It might be looking funny, but its hard and time consuming to convince people if he has got partial/incorrect knowledge beforehand.
In my opinion, this kind of articles should be removed from codeproject as it misleads young developers.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
I think it is called Singleton per session AFAIK.
|
|
|
|
|
Anurag Gandhi wrote: this kind of articles should be removed from codeproject as it misleads young developers I completely agree, and you will pleased to hear that it has now been deleted!
Don't forget that you can report articles as being "Inaccurate or Misleading"
|
|
|
|
|
This comment (not mine, I hasten to add) on a question about serial ports:
Convert.ToFloat("12.51");
You're not going to like this, but converting from one simple type to another simple type should not be an issue.
I suggest you buy a book and go through a lot of tutorials before attempting anything more complex.
Elicited a down vote, and this reply from the OP:
Hi,
Sir what Book mean ?
Regards
This is getting frightening...he doesn't even know what a book is?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
OriginalGriff wrote:
Hi,
Sir what Book mean ?
Regards
This is getting frightening...he doesn't even know what a book is?
Yah... old technology requires old research methods...
Kids these days. I have a serial comm book at home I don't throw old books away. New books on the other hand... quite useless imo... I'll just use the web for that.
|
|
|
|
|
The OP may wish to look up a rather obscure short story by Asimov, The Holmes-Ginsbook Device.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
He can't - it's in a book!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|