List of Ruby subclasses with parent class

Is it valid and / or acceptable to use a class for a namespace as opposed to a module? Maybe this is just a matter of opinion, but I thought that someone has experience with this, which could finally say whether this is an accepted practice.

Take the following classes, for example:

class Parent
end

class Parent::Child1 < Parent
end

class Parent::Child2 < Parent
end

I know that the code above works, but it seems strange to use a class instead of a module for a namespace. The reason I want to add the name of the parent class to the subclass is because I plan to have many subclasses and avoid name conflicts. For instance:

class Priority
end

class Priority::Low < Priority
end

class Temperature
end

class Temperature::Low < Priority
end

An alternative to this would be to not use namespaces and just use the parent name as part of the subclass name:

class PriorityLow < Priority
end

Ruby?

Update:

@sawa . , classy_enum, , Enum. . , , . PriorityLow Priority::Low ( , , )

+5
1

, , , , Ruby Class Module, , - , , , , , . , , , , , - .

+6

All Articles