design - Multiple classes in one file, Ruby Style Question -
i writing script takes data database , creates googlechart urls parsed data. need create 2 type of charts, pie , bar, wrong if stick both of classes in same file keep number of files have low?
thanks
if you're asking "ruby" way, put classes in separate files. others have alluded to, placing classes in separate files scales better. if place multiple classes in same file , start grow, you're going need separate them later.
so why not have them separate beginning?
update
i should mention autoload works expecting classes in own files. instance, if you're in rails environment , don't separate classes different files, you'll have require
file explicitly. best place in application.rb
file. know you're not in rails environment, others may find answer, maybe info helpful.
update2
by 'autoload', meant rails autoload. if configure own autoload, can put classes in same file; again, why? ruby , java communities expect classes in separate files. exception nested classes, that's more advanced design patterns.
Comments
Post a Comment