₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,899 members, 8,447,597 topics. Date: Saturday, 18 July 2026 at 03:34 PM

Toggle theme

ATTENTION: Programming Logic Comparison - Programming (2) - Nairaland

Nairaland ForumScience/TechnologyProgrammingATTENTION: Programming Logic Comparison (3684 Views)

1 2 Reply (Go Down)

Re: ATTENTION: Programming Logic Comparison by Nobody: 10:41pm On Nov 13, 2014
GozieDiora:
Though I prefer your approach, you seem to be forgetting we are dealing with pseudo codes here not programming languages. Functions are not to be imagined.

That aside, I think the goal is to prompt the user with his user name in case of password mismatch. In other words, if the user does not exist at all, the system simply tells the user but if the user name exists, the system should call the user by his name and ask if he forgot his password.

Just a slight modification of your code can achieve this.
I understand it's a pseudocode, I was just questioning his logic. why would we check for passwords if username does not exist?

Btw, the first scenario would not fetch you the specified goal, the second would
Re: ATTENTION: Programming Logic Comparison by Nobody: 10:45pm On Nov 13, 2014
GozieDiora:
Yeah, bro.

Let's not bother going into parsing/tokenisation (Backus Naur/ type 2 grammar) or semantic trees (Finit State Automata/ type 3 grammar). I'm sure a good number of peeps here won't flow along with us.

This is what differentiates a computer scientist from other computer programmers.

Lol. ... just kidding.
:-D sure boss. That's why I tried to keep things simple from the beginning, explaining with examples.

But before this could be understood I'm afraid we might have to consider that option. As this could be confusing sometimes.

U seem to be learned about this issue. I admire you.

People need to understand what's going on in the background before they could actually decipher how things work.
Re: ATTENTION: Programming Logic Comparison by Nobody: 10:52pm On Nov 13, 2014
bruceleah:
I understand it's a pseudocode, I was just questioning his logic. why would we check for passwords if username does not exist?

Btw, the first scenario would fetch you the specified goal, the second would
I've actually written off his code. Not that it's not gonna work but like you pointed out, it's amateur.

Let's focus on yours, if you will.

At what point will a user whose name exists get a prompt asking if he forgot his password?

Instead of saying [else {mismatch}], why not put the prompt there? This is because for the logic to have gotten to that point, the username obviously exists but the password is wrong.

Then the last "else" should ask the user, 'Ogbeni, who are you?' Because at this point, even the username does not exist.

What do you think?
Re: ATTENTION: Programming Logic Comparison by Nobody:
@GozieDiora, are you familiar with the word "offensive security"? I've been working on this project that's based on this idea and I would wanna make it open source.

Also, the codes and d app would be available for free as that's the beauty of open source dev.

Interested programmers could please join (send me a pm).
Re: ATTENTION: Programming Logic Comparison by Nobody: 10:58pm On Nov 13, 2014
bruceleah:
:-D sure boss. That's why I tried to keep things simple from the beginning, explaining with examples.

But before this could be understood I'm afraid we might have to consider that option. As this could be confusing sometimes.

U seem to be learned about this issue. I admire you.

People need to understand what's going on in the background before they could actually decipher how things work.
And where can people learn such? At roadside IT centres?

They say, "why spend years studying Computer Science when you can easily get trained along the streets" and I smile knowing that these peeps have never been to a CSc classroom. Not their faults though, some CSc grads aren't representing well.
Re: ATTENTION: Programming Logic Comparison by Nobody:
GozieDiora:
I've actually written off his code. Not that it's not gonna work but like you pointed out, it's amateur.

Let's focus on yours, if you will.

At what point will a user whose name exists get a prompt asking if he forgot his password?

Instead of saying [else {mismatch}], why not put the prompt there? This is because for the logic to have gotten to that point, the username obviously exists but the password is wrong.

Then the last "else" should ask the user, 'Ogbeni, who are you?' Because at this point, even the username does not exist.

What do you think?
Exactly boss. Yeah, that should solve the issue.
I was just trying to make the logic understood.

I guess this could save some pple headaches if implemented but could consume time. Cos sometimes, I tend to forget my username and I just wanna know if it's actually correct and I'll try to figure the password later.

But all I do get is "invalid username or password"

In btw, this could be exploited by crackers too.
Re: ATTENTION: Programming Logic Comparison by Nobody: 11:09pm On Nov 13, 2014
GozieDiora:
And where can people learn such? At roadside IT centres?

They say, "why spend years studying Computer Science when you can easily get trained along the streets" and I smile knowing that these peeps have never been to a CSc classroom. Not their faults though, some CSc grads aren't representing well.
I tell you, it's really a shame. There's a big difference between understanding a language and how to write an essay with that language.

For instance, I could understand english language but I might not be able to write a correct essay.

This is applicable to programming too. Road side IT might teach you a language (dey might just brush it for u sef) but would never teach you what's going on in the background.

You only get this from csc classrooms or some well-respected IT firms
Re: ATTENTION: Programming Logic Comparison by Nobody: 11:21pm On Nov 13, 2014
bruceleah:
Exactly boss. Yeah, that should solve the issue.
I was just trying make the logic understood.

I guess this could save some pple headaches if implemented but could consume time. Cos sometimes, I tend to forget my username and I just wanna know if it's actually correct and I'll try to figure the password later.

But all I do get is "invalid username or password"

In btw, this could be exploited by crackers too.
But in real life scenarios, we use this approach mostly when the user's e-mail or phone number is used to log on instead of his actual username. The system them prompts him with his username if the password is wrong.

This is because, in popular systems, most usernames will definitely exist in the system but email addresses/phone numbers are more unique so once supplied, the system would be able to match it against a username and still request clarifications like we have in the popular Facebook system.

Hackers exploit everything, bro.
Re: ATTENTION: Programming Logic Comparison by Nobody: 11:33pm On Nov 13, 2014
GozieDiora:
But in real life scenarios, we use this approach mostly when the user's e-mail or phone number is used to log on instead of his actual username. The system them prompts him with his username if the password is wrong.

This is because, in popular systems, most usernames will definitely exist in the system but email addresses/phone numbers are more unique so once supplied, the system would be able to match it against a username and still request clarifications like we have in the popular Facebook system.

Hackers exploit everything, bro.
Sure boss, it's advisable to use email addresses or phone numbers as unique keys, rather than mere user names. but this could be used too.

Talking about exploitation, hackers exploit to resolve while crackers exploit to destroy.
I guess this is another story for another thread

I keep preaching this every where I go, hackers are NOT crackers. People tend to mistake one for the other.

A cracker might sit at his/her desk, trying to get list of valid users in a system. I guess that's why the error "invalid username or password" is being thrown.
Re: ATTENTION: Programming Logic Comparison by romme2u(op): 2:32am On Nov 14, 2014
GozieDiora:
Well, from the stand point of computer programming purity and code optimisation, one is actually better.

Here is the gist:

In the first scenario (I.e. using the logical operator), compilers equiped with code optimisation functionality (like Object Pascal etc) take advantage of this structure to reduce total execution time by handling only one side of the operator in the best case scenario. In other words, the second side is executed if and only if the first part evaluates to be false (for logical OR). This goes a long way to increase speed and reduce run time memory consumption. However, this benefit can only be remarkable in data crunching programs like large file processing, batch processing especially in ERP's etc. IDE's like Netbeans for Java language, Morph X for X++ etc. which show approximate execution time would show this for very large amount of data.

In the second, still on logical OR, provided the first condition is true, the second must run.

So if OR is the intended logic, it would pay to use the first structure for code optimisation.
This feature you just explained is called short-circuiting, whereby the second condition is ONLY evaluated if the first condition is true else the inner block statement is skipped and the else block executed if it is available.
Re: ATTENTION: Programming Logic Comparison by romme2u(op):
bruceleah:
I understand it's a pseudocode, I was just questioning his logic. why would we check for passwords if username does not exist?
Great optimisation reducing system resources consumption (like overhead incurred by database access) and faster code execution.
Re: ATTENTION: Programming Logic Comparison by blueyedgeek(m): 9:06am On Nov 14, 2014
bruceleah:
I don't seem to understand line 3 of ur code.

What if this logic was simplified:

If (validUser(user)) {
If (validPword(user,pword)) {
// Do something
} else {
"Mismatch";
}
} else {
"No user";
}

Instead of

If (validUser(user) && validPword(user,pword)) {
//Do something
} else {
"Mismatch"
}

Note: the goal is to prompt user if user name does not exist and if there's a mismatch.
Cool, I'm actually learning quite a few things from this thread although I do think we might have gone off tangent here from the initial op which is if there is a difference between both and as I have pointed out, there isn't much difference between both except in special cases.
Re: ATTENTION: Programming Logic Comparison by Nobody: 9:33am On Nov 14, 2014
blueyedgeek:
Cool, I'm actually learning quite a few things from this thread although I do think we might have gone off tangent here from the initial op which is if there is a difference between both and as I have pointed out, there isn't much difference between both except in special cases.
Hehe.... the word "except" simply means there is actually a difference. After all, the OP didn't say, "are there much differences between.....?". He asked if there is any.

I do not think we are deviating yet. We are just going beyond scope and that is a different thing. All the same, do you really think this thread will make any headway if we all stick to a couple of "FOR" statements?

It has to grow beyond that and that is the scope expansion we are talking about. Lol

It would have been better if the thread were about algorithms proper instead of control structures.
Re: ATTENTION: Programming Logic Comparison by Nobody: 9:52am On Nov 14, 2014
Resolved
Re: ATTENTION: Programming Logic Comparison by Raypawer(m): 3:20pm On Nov 16, 2014
no need to talk much, the second is nesting. you are nesting a condition inside one. the first (if(condition &&condition){…} the two conditions has to e true, the second condition (if(condition){if(condition)} the first situation has to be true before the second comparison can take place. this is called nesting nd mostly used to check username and password on a login page. like username has to exist before checking if the password z true.
1 2 Reply

Help Me Keep My Brain In My Skull! Solve This Logic!Simple Logic!think U Can Crack This?The Door-Goat-Car Logic Problem234

Re: Amazon Recruitment Of Software Developers In Nigeria 2022. OpinionResults For Programming Challenge Season 2Sign Your Online Documents With This App