T
Trans
I wonder what's the general consensus on modular organization. Overall
there seems to be four general approaches.
1) BASE CLASS
ActiveRecord, uses this design:
module Foo
class Base
end
class Bar < Base
end
end
2) BASE CONTAINER
An alternative is to call the base class Foo and use it as a
container:
class Foo
...
class Bar < self
end
end
3) EXTERNAL BASE
In this case the organizing module contains a plurality of
subclasses. The base class is external to this module.
class Foo
end
module Foos
class Bar < Foo
end
end
4) BY NAME
No container modules, just use naming:
class Foo
end
class BarFoo < Foo
end
Which is better? Are there serious advantages/disadvantages to any of
these?
Thanks,
T.
there seems to be four general approaches.
1) BASE CLASS
ActiveRecord, uses this design:
module Foo
class Base
end
class Bar < Base
end
end
2) BASE CONTAINER
An alternative is to call the base class Foo and use it as a
container:
class Foo
...
class Bar < self
end
end
3) EXTERNAL BASE
In this case the organizing module contains a plurality of
subclasses. The base class is external to this module.
class Foo
end
module Foos
class Bar < Foo
end
end
4) BY NAME
No container modules, just use naming:
class Foo
end
class BarFoo < Foo
end
Which is better? Are there serious advantages/disadvantages to any of
these?
Thanks,
T.