Hacker News new | ask | show | jobs
by SanFranManDan 3474 days ago
How they use the singleton is strange also.

https://github.com/vvk-ehk/evalimine/blob/master/ivote-serve...

> Election().count_questions()

> Election().is_hes()

> for el in Election().get_questions()

> Election().is_voters_list_disabled()

Election is a singleton so they keep reinstantiating it every time they want to use it instead of just doing

> election = Election()

at the module level and having a more idiomatic singleton (module variable are singletons). But a singleton design probably isn't the best approach.

The singleton example isn't that bad of code since it assumes that one server will run one election which is a valid assumption, but reading through this code makes me weary about e-voting. I think this proves that OpenSource doesn't always mean good code. There is little incentive for people outside of Estonia to contribute to the project.