Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

setter methods in various code #62

Open
zopyx opened this issue Feb 16, 2016 · 2 comments
Open

setter methods in various code #62

zopyx opened this issue Feb 16, 2016 · 2 comments

Comments

@zopyx
Copy link

zopyx commented Feb 16, 2016

Looking at examples/create_forest.py

The tons of set_xxx() methods are completely superfluous and unpythonic.
Why don't you just use

create.some_property = value

directly instead of usinger setter methods? Python is not Java!

@ndw
Copy link
Contributor

ndw commented Jun 14, 2016

Interesting. Are they really a python antipattern?

If one wants to have validation when necessary and consistency, it seemed like they were necessary.

@zopyx
Copy link
Author

zopyx commented Jun 15, 2016

setter/getter methods are the anti-pattern #1. No offense but this anti-pattern is often seen by code written by people from the Java world. We call that "unpythonic".

Regarding validation: I would pass the result from parse_args() to a dedicated validation method performing the validation of all parameters. Or you look into a higher-level module 'click'
http://click.pocoo.org/5/ for having parameter types or hooks for validation. 'click' is not part of the Python core but you are already using external dependencies like 'requests'...so further deps should not be a big problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants