MegaLotto::Drawing.new.draw
You don't have the information of how many numbers you are getting back. That's not a big deal, but adds to the cognitive load (or requires some comments). Also, if you need to draw different numbers in several different places, you will have to change the configuration many times: # First use, we need 10 numbers
MegaLotto.configure do |config|
config.drawing_count = 10
end
MegaLotto::Drawing.new.draw
# Second use, we need 6 numbers
MegaLotto.configure do |config|
config.drawing_count = 6
end
MegaLotto::Drawing.new.draw
And as soon as you do that, you may need to take multi-threading into account, because you are mutating the class. Array.new(4)
If instead you configure Array.new to have a given size for all instantiations, you also lose locality and you may run into thread safety issues. # Another approach which modifies the instance
drawing = MegaLotto::Drawing.new
drawing.size = 10
drawing.draw #=> returns ten numbers
But this is not optimal design given the elements we have. MegaLotto.configure do |config|
config.drawing_count = 10
end
MegaLotto::Drawing.new.draw
With the alternative: MegaLotto::Drawing.new(10).draw
If you want to make it extensible, you can use keyword arguments: MegaLotto::Drawing.new(size: 10).draw
The interface and the implementation are simpler, but also the performance is better because there are less method calls. If you look at the code of both implementations, you will find the simpler one easier to understand. As a side effect, you will also get simpler stack traces if anything goes wrong.
Also, it's sad that you have such a negative view on your neighbors, given that you are very much alike and that they boost Uruguay's economy.