From: tamouse mailing lists Date: 2012-12-16T11:22:11+09:00 Subject: Re: by value - by reference, circular reference On Sat, Dec 15, 2012 at 12:35 PM, Michael Sas wrote: > Allright, thanks robert. Its clear now how this attempt failed. > > There was a working solution, where all references where class variables > of one big class. The constructors of all classes where unparameterized. > If a resource was needed, it was accessed through the big class. I > didn't like this solution, because the classes where tightly coupled to > the big class. But it was a good thing, that exchanging one resource was > trivial. > > Before that the circularly intertwined classes called each others > initialize in their constructors, where self had an adress already. > Worked. In my opinion it was the ultimate form of cuppling. > > Now i have rather long parameterlists. I don't like that either. > > Another solution would be to use setter methods. But that would mean > writing a few lines of code per initialisation extra. > > The latter three solution also leave the question of globally exchanging > a resource open. > > The circular reference must go. But this topic is interesting. What are > the established ways to treat circular references, long parameter lists > and globally used (and potentially variable) objects? > > -- > Posted via http://www.ruby-forum.com/. > if you object to long parameter lists, consider passing a hash. This may still have a lot of code on the calling side, but it is at least rather more understandable vs. just passing in values. a = A.new({ :option1 => 'Something', :option2 => 'or' :option3 => 'other' }) then the method definition is def initialize(options = {}) # ... code end This form is used all over the place, all the time.