|
What did you do wrong to deserve this? Did you destroy Sealand?
On another note, the comments in your code block stretch the screen. Could you please fix them?
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
fixed the comments, sorry
I think it must be bad karma, the whole site is like this (they were the lowest bidder).
It does function, and there are pieces that are seem good, but then I come across stuff like this and I really want to bang my head against the wall.
|
|
|
|
|
I am not familiar with db connection issues. Could you explain why is it bad, please?
icewolf_snowfire wrote:
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
Thanks.
Greetings - Jacek
|
|
|
|
|
when you use a SqlDataReader, you always have to check if it actually contains any data with reader.HasRows if it doesn't have data, like in this case if the username is not in the database, it throws an InvalidOperationException "Invalid attempt to read when no data is present"
what's happening is the person who wrote this, didn't understand what was causing the exception, so he just handled in with a try catch, rather than fixing the actual problem.
|
|
|
|
|
I get it. It seems to be another case of an "exceptional coding". Moreover, it rethrows the exception so the overlaying method will get a plain InvalidOperationException with no clue what is going on, as far as I understand the throw; syntax. Terrifying.
Greetings - Jacek
|
|
|
|
|
icewolf_snowfire wrote: reader.HasRows
Wouldn't if (reader.Read()) { ... } be ok too?
xacc.ideIronScheme - 1.0 beta 3 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
you're right it would, I didn't realize that was there. (and neither did they)
it would be less lines of code, so slightly more efficient?
|
|
|
|
|
icewolf_snowfire wrote: it would be less lines of code, so slightly more efficient?
lol.
Greetings - Jacek
|
|
|
|
|
I've always used while (reader.Read()) { ... } which does the trick.
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
Click here to view my blog
|
|
|
|
|
I'm not sure what's worse, that a professional development company has people who think this is how you use exceptions, or that my company actually paid money for this code Unsure
I love the way they put database errors in the message to the user, and identify which they got wrong, the username or the password.Mad
In many situations, it's entirely reasonable to distinguish a bad username from a bad password. User names are generally not secure, and legitimate users may not always remember which variation of their username they used at a particular site.
Having a login routine throw an exception for user-not-found is not the best, but if a custom exception were used for that purpose, it wouldn't be totally horrible. The only really horrible thing I see is the munging of the exception message.
BTW, one feature I'd like to see on a web site would be an option for users to specify a string that should be displayed on an unsuccessful login attempt, with the instruction that the string should contain something recognizable, but should not contain any security-related information. That would allow someone who mistakenly tries to log in with someone else's username to immediately realize their mistake.
|
|
|
|
|
It would also be nice if sites told you what the rules for passwords were so that you knew which passwords you were likely to have used on a given site. Often I've had to try to create a new account to find out what the rules are for a site so I can login again. Life was so much easier before websites started getting themselves removed from BugMeNot!
|
|
|
|
|
Russell Jones wrote: It would also be nice if sites told you what the rules for passwords were so that you knew which passwords you were likely to have used on a given site. Often I've had to try to create a new account to find out what the rules are for a site so I can login again. Life was so much easier before websites started getting themselves removed from BugMeNot!
No kidding. If a site requires passwords to be precisely eight characters, how is it any less secure to remind people of that at the login screen than after they create a new account? (Of course, requiring that passwords be exactly eight characters seems a dumb design anyway--even if the system only had space to store eight bytes, and policy factors dictated an eight-character minimum, the system should easily be able to hash a password of arbitrary length into an eight-byte digest or--failing that--just take the first eight bytes of the password and ignore the rest).
|
|
|
|
|
I've seen the exact same crap from a third party 'development company' my employer has recently stopped using.
I ended up submitting report after report on how bad their code was ... finally got listened to and we promptly dumped them.
|
|
|
|
|
I don't think these are the bad Idea or junk or crap etc. whatever you called it.
It just the way of programming. And it the way the programmer want it to be.
One Algorithm can be done in many way.
So If you think you can write a better one, You should not shout into their face an say something Like
"Your code is bad. I found this junk in your code. I am the best." Impressive Huh!?
What you should do is give them a suggestion, Though it free
|
|
|
|
|
Well... you can lead a horse to water...
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
And remind him he was drinking poison...
It feels good to learn and achieve
|
|
|
|
|
Not only the code uses hardcoded "enums" and uses everything as strings, it also does very "useful" IFs.
if(cboTipoIncentivo.SelectedValue == "414")
dtIncentivo = oIncentivo.ConsultaCreditoIncentivo("", txtN_Processo.Text, sIdf_Pessoa, cboTipoIncentivo.SelectedValue);
else
dtIncentivo = oIncentivo.ConsultaCreditoIncentivo("", txtN_Processo.Text, sIdf_Pessoa, cboTipoIncentivo.SelectedValue);
|
|
|
|
|
Looks like a breakpoint construction to me. I would consider using such things myself assuming you can't break on an empty code block.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: I would consider using such things myself assuming you can't break on an empty code block.
;
xacc.ideIronScheme - 1.0 beta 3 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Right click on the breakpoint's red ball => Condition.
Here you go!
Admittedly it does slow down the program a bit...
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Thanks. I'll give it a try sometime next week.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Super Lloyd wrote: Admittedly it does slow down the program a bit
Yup. Don't even try to use it in a loop...
Greetings - Jacek
|
|
|
|
|
A switch would have been more fun!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Even more fun: inheritance. And delegates
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Haha, why make simple when we can make it complicated!?
Challenge: write a 12193 lines long C# program which convert any value to the integer value 1 (or 0).
Bonus point: all method should be called, through different path, for any values!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|