zdict icon indicating copy to clipboard operation
zdict copied to clipboard

[zdict.py] code refactoring and test cases

Open iblislin opened this issue 10 years ago • 5 comments

It seams that there is some global vars. Could we avoid this? or is it a necessary evil?

And, i want to introduce this coding style: https://en.wikibooks.org/wiki/Computer_Programming/Coding_Style/Minimize_nesting Please comment

I will keep updating the working list here:

  • reduce nesting
    • [x] main()
    • [x] MetaInteractivePrompt
  • test case
    • [x] main()
  • Remove global vars
    • [ ] zdict.py
  • Remove dependency of args (avoid just pass args from zdict.py)
    • [x] DictBase.lookup

iblislin avatar Oct 07 '15 02:10 iblislin

I'm ok with this coding style.

I used global vars for args and dictionary_map because almost every function in zdict.py need these two vars. If u don't want to use global, just pass these two vars as arguments to those functions which needed them. I'm ok with that, I was too lazy to add these two arguments. lol

fkztw avatar Oct 07 '15 05:10 fkztw

Thanks for comment.

I will work on removing the global vars.

iblislin avatar Oct 07 '15 05:10 iblislin

@M157q global vars are really hard to remove.... The appear every where.. @wdv4758h suggests that we need to refactor the flow control of zdict.py

iblislin avatar Nov 10 '15 13:11 iblislin

20160327_11 36 21

  • [ ] zdict/__main__.py
  • [ ] zdict/dictionaries/moe.py
  • [ ] zdict/dictionaries/spanish.py
  • [ ] zdict/dictionaries/template.py
    • as a template for dictionaries unit testing
  • [ ] zdict/dictionaries/urban.py
  • [ ] zdict/dictionaries/yahoo.py
  • [ ] zdict/dictionary.py
  • [ ] zdict/easter_eggs.py
  • [ ] zdict/exceptions.py
  • [ ] zdict/utils.py
  • [ ] zdict/zdict.py

fkztw avatar Mar 27 '16 03:03 fkztw

@iblis17 I'm thinking about just leaving this issue for refactoring only. I'm going to create another issue for the unit-testings part. So, you can make this issue turn into a PR base on issue-48 branch for code review. What do you think?

fkztw avatar Apr 17 '16 16:04 fkztw