As I understood: In Ruby, we use modules instead of classes when we don't need a state (if it's just a function that takes an input an produces an output).
Some design patterns depends on inheritance like template design pattern.
I am making a crawling libirary that takes a link as an input and produces an object containing the data.
It don't need a state so a module seems to be suitable for me instead of a class, I also need to use template design pattern as I am using different algorithms to produce data of the same structure.
Now my question, I need to use inheritance to implement template design pattern, but I don't need a state it just returns the data from the website.
Is implementing a design pattern a good reason to use classes (for inheritance)? or what is the best practice in such cases ?
Aucun commentaire:
Enregistrer un commentaire