|
Hehe, nice one.
Although I thought Response.Redirect sent a HTTP 303 and the browser was clever enough not to re-request the same page in that case.
And yes, it would be interesting to know what he meant to do with that.
|
|
|
|
|
Want to send to the login page and has a login user conrol on the same page. He is redirecting on the same...
|
|
|
|
|
Naaah, that's not a coding horror - it's a typo! Shoulda been caught in the code review that his senior performed before check-in...
Time you enjoy wasting is not wasted time - Bertrand Russel
|
|
|
|
|
Reminds me of a place I worked at that had the application maintain a trace log. Procedure calls and errors were logged to a disk file.
So when the disk was full and generated an error...
Only to be matched by their desire not to have a cursor displayed (pre-Windows version) during start up that they moved the cursor off the screen and then wondered why a start up error message was not being displayed...
I told them to just turn the cursor off. I was told you couldn't do that, see the Peter Norton book...and then any other book and find them using the same sentence. I pulled out my 6845 CRTC controller spec sheet and turned the cursor off with it still on the screen space. Error messages became visible.
My Former Bitch Supervisor From HellTM declared I was arrogant for thinking I was smarter than Peter Norton (a claim I never made).
Psychosis at 10
Film at 11
|
|
|
|
|
Wait, your supervisor had declared that this task was impossible (according to Peter Norton's book) and then you tried it successfully, which proved that you were arrogant rather than... smart and determined?
Real nice. Perhaps she should be working behind a library service desk somewhere
|
|
|
|
|
It would have been nice, but in her eyes, I showed her up. Being an insecure control freak she was always afraid I was after her job. She never accepted the idea that I had no interest in her job, I had my own career path I was interested in.
But don't get me started. I and my colleagues who had the misfortune of working under her have HOURS of stories about her.
Psychosis at 10
Film at 11
|
|
|
|
|
rahultandon1000 wrote: Code from one of my junior :-> ---- this is
Page-A.aspx
<SPAN class=code-keyword>protected</SPAN> <SPAN class=code-keyword>void</SPAN> Page_Load(<SPAN class=code-keyword>object</SPAN> sender, EventArgs e)
{
Response.Redirect(<SPAN class=code-string>"</SPAN><SPAN class=code-string>Page-A.aspx"</SPAN>);
}
for (int i = 0; i < 101; i++) Blackboard.WriteLine("I must not use unterminated recursion.");
|
|
|
|
|
Surely you mean
for (int i = 100; i >= 0; i++) Blackboard.WriteLine("I must not use unterminated recursion.");
|
|
|
|
|
Or even...
void F() {
Blackboard.WriteLine("I must not use unterminated recursion");
F();
}
(Your version was unterminated iteration)
|
|
|
|
|
rahultandon1000 wrote: it keeps browser busy to keep loading the same page
Finally someone who knows how to get the fullest from the newest i7 uber-core computers with really very fast internet connections!
It's an OO world.
|
|
|
|
|
rahultandon1000 wrote: protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("Page-A.aspx");
}
Page-A.aspx .. Is this the real page name or you have modified it ?
|
|
|
|
|
If it's the real name, it's a bigger horror then the relatively small mistake of redirecting to the wrong page...
|
|
|
|
|
He stated earlier that it's a login loop, not as simple as what he posted, so I imagine the page is actually Login.aspx or similar. (Which is a relatively easy mistake to make with how login protection works ... just needs you to accidentally put an authorisation check on the login page.)
|
|
|
|
|
Ever wondered how those password dialogs work like? Here is a small sneak under the hood:
final PasswordDialog pwd = new PasswordDialog(ApplicationWorkbenchWindowAdvisor.getShell());
if (pwd.open() == Window.OK) {
ConnectionManager.password = AccountManager.getGeneralStore().getString(
"UA.Account.Security.sec_pass"
);
}
else {
return null;
}
Security at it's best. At least does the string from the preferences store just fit if you've got the right username
regards
Torsten
I never finish anyth...
|
|
|
|
|
It is not necessarily a horror if it was found in a debug/dev build. I do it in similar way, too. Of course you have to remember to remove it for release builds (or use #if DEBUG clause).
Note: don't use GOTO (multiple returns are gotos too)
Greetings - Jacek
|
|
|
|
|
Multiple returns are not gotos and are not a bad design practice.
Guard conditions are actually favored over nesting if's
|
|
|
|
|
You are right about guard condition. My note was general -- do not use 'return' like 'goto' (jumping from the middle of method).
Greetings - Jacek
|
|
|
|
|
That depends a lot on your language. Its a common (and safe) technique in C++ using RAII techniques.
|
|
|
|
|
This is Java code.
Returning a value "null" is not the best idea, but it's a invalid value one can identify as such.
I actually often return values in that way:
switch(key){
case x: return a;
case y: return b;
default: return null;
}
It's pretty handsome and easy to maintain.
regards
Torsten
I never finish anyth...
|
|
|
|
|
Since the Nullable<> thing was introduced, it seems that MS encourages developers to use null as a "special" and possibly meaningful value.
Personally I don't have a strong opinion on that, but often after I declared sth as T? I had to change it to T due to interopability issues and too many not-null checks.
Greetings - Jacek
|
|
|
|
|
If you're going to say something is bad, could you at least explain to rookie doofuses like me why it's bad?
Due to my lack of experience, I look at your code and I have no idea what the problem is. Furthermore, none of the comments here helps. Explain to me like I'm a complete idiot (which I occasionally am).
|
|
|
|
|
Seems to me what they're talking about is the use of null as a return value. "They" don't seem to like it.
Seems to me there's lots of "personal preferences" in a lot of threads found on this forum. To me, returning null is just fine; as an old database guy, null proves to be a very handy and very real data type/value.
|
|
|
|
|
As to the return thing...
Camp 1 says, when writing a method/function, you should have one entry point and one exit point. For languages that use return to exit the method, this implies a single return at the end of the method/function. Using this model sometimes involves multiple nested if statements.
Camp 2 might say I like to validate all preconditions and immediately return if something appears amiss, but then I have one return at the bottom for the real answer.
Camp 3 might say, I use assert() for things like Camp 2 does with returns, but I still have one return at the bottom.
Camp 4 might say, just throw a return in wherever it makes sense.
Camp X, might pick and choose what they want from other camps.
|
|
|
|
|
|
There is a dialog opened - a password-dialog.
When it returns OK (dialog is confirmed / left with "OK" button) the app not uses the entered password, but refers to some preference stored before.
Passwords which are entered by the user in a customers application, may never be written to files - no matter if ASCII, binary or whatever. It took me a couple of hours to verify that no password is stored in that application and no password is read at any time. A password must always be kept in the RAM and disposed when the application is shut down.
Also the stored password in the database should be encrypted.
regards
Torsten
I never finish anyth...
|
|
|
|