Circular dependecy on classes

A

Anatol Pomozov

I have several classes that have circular dependencies on each other.
See following example.

class Solder
@can_upgrade_to =3D [Knight]
#or use constant from Knight class

def upgrade!(to)
raise "Unable to upgrade" unless @can_upgrade_to.contain(to)
end
end

class Knight < Solder
end

I cant use Knight constant (class name) before Solder and can't use
Solder before Knight.

I am just come from Java lang and for Java circular class deps is not
a problem.
But ruby is a dynamic language and it creates classes just on script
executing. (right?)

So my questions is: how to solve this problem? What is the best way to
deal with it.

--=20
anatol
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top