From: Robert Klemme Date: 2012-12-06T17:44:20+09:00 Subject: Re: Organizing code to avoid name space collision On Wed, Dec 5, 2012 at 7:28 PM, Martin Hansen wrote: > I don't know if this is a design issue on my part - or how to resolve > it. The individuel test_backtrack.rb and test_dynamic.rb runs just fine. > Any script I have that utilizes one of these modules also have no issues > - because both modules are never included at the same time. It's only > the test suite that includes both when running rake test - and problems > occur. How is it decided which of the two is included in regular code? > I spend some time studying the Modeles and Namespaces section in the > Ruby Cookbook. Here the suggestion is that one should chose different > method names to avoid conflicts. I think that is a crude solution. That is obviously a bad solution if you want to use both variants interchangeably. > I also explored your extend solution, but while that should work (I didn't > test) it means that every time I instantiate a Seq object I need to > extend it. I could accept that for the testing files, but I think it > would obfuscate the regular code that uses Seq objects. Not at all. You can do it in #initialize. No caller would need to change. > I don't > understand your 3. suggestion. I am very open to suggestions to improve > the organization of my code - and to any coding practices that eliminate > such design issues. http://c2.com/cgi/wiki?StrategyPattern Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/