Quantcast
Viewing latest article 4
Browse Latest Browse All 5

Answer by Chris McCauley for instance_variable_set in constructor

Answers to this question are always going to be based on someone's personal opinion so here's mine.

Clarity v Brevity

If you cannot know the set of options ahead of time then you have no real choice but to do as you have. However if the options are drawn from a known set then I would favour clarity over brevity and have explicit methods to set the options. These would also be a good place to add any rdoc etc.

Safety

From a safety perspective, having methods to handle the setting of an option would allow you to perform validation as required.


Viewing latest article 4
Browse Latest Browse All 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>