katkalouckova / my_vocabulary

Application for creating individualized vocabulary and learning stored words
1 stars 0 forks source link

rewrite spaghetti code into linear #6

Open mpavlase opened 5 years ago

mpavlase commented 5 years ago

Take a look at this piece of code as example (not only one): https://github.com/katkalouckova/my_vocabulary/blob/36fe2377d3ed45e25606972387c2cb8fb9331c1b/web.py#L43-L64

How it can looks like when there will be another 5 conditions... ?

Try to rewrite it into linear form like this (caution, it wouldn't be exactly like this!):

if not required_word:
    # Nothing was entered 
    message = "Enter some word."

if not my_vocabulary.exists_word:
    ...

The goal is to act on negative behaviour (like missing entered word) and keep the executing "bubble" till positive lines of code. Figure out to better passing message values.

katkalouckova commented 5 years ago

Done.