I'm trying to follow the SOLID concepts and at same time be DRY (not to repeat myself).
I have a parent class that is sharing a method between its subclasses, but this method is not used in the parent class itself:
class ParentClass
def locals
{ id: ..., result: ... }
end
...
private
def method_used_in_descendants # this method is not used in ParentClass
end
end
class ChildClass < ParentClass
def locals
super.merge { whatever: method_used_in_descendants, one_result: ... }
end
...
end
class AnotherChildClass < ParentClass
def locals
super.merge { whatever: method_used_in_descendants, another_result: ... }
end
...
end
# And not all the descendants of ParentClass need method_used_in_descendants:
class AnotherChildClass < ParentClass
def locals
super.merge { whatever: my_private_method }
end
...
end
Is this method method_used_in_descendants
created in the ParentClass
a bad practice?
Thanks