0

is this the right way?

i built this code that have 'accounts' in them and in order to register to your account you need to write the name and the PIN code and if the data is correct you get access to the data in your account. can you tell me if i did it well? is there a better and more recommended to do it? is it close to how real companies do it? (btw, you cant run this code on sololearn.. you can run it on this site: https://www.onlinegdb.com/online_python_compiler ) code: https://code.sololearn.com/ceXe6Cu3dc2u

10th Jul 2020, 7:46 PM
Yahel
Yahel - avatar
3 Antworten
+ 2
Of course this depends - as always - on the kind of application and some more conditions. For sure it's absolutely uncommon to use Scanner for a user input in real world projects. You would never use if-else if-branches to select a user. You will find in most applications some sort of role system. And depending on the risk potential and the architecture, some encoding might be required.
10th Jul 2020, 8:21 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
That's nothing what can be written down in a few minutes and some of the required stuff is even not supported by sololearn playground (UI e.g.). Auth systems and role management are a complex and wide field. There are hundreds of libraries supporting various functions. Your user classes can be seen as some kind of sololearn-testdata. Try to wrap around a role system on your own first. Name the test users as test users. Remove that if-else if-branches and replace it with a test-list of test users (as kind a sololearn mock of a database, which would be used in real world projects). Then we'll continue...
10th Jul 2020, 8:50 PM
Sandra Meyer
Sandra Meyer - avatar
0
Sandra Meyer ok, can you please give me an example (in code) on how it should look? (To be better and more realistic..)
10th Jul 2020, 8:23 PM
Yahel
Yahel - avatar