Class vs Module

Should be a great WWE match up

Really the question was “should I use a class or a module?”

There’s not really global “Oh always use X” answer here.

But usually if you find yourself wiring code that passed data to a method and you have a group of methods that collectively define a “data type” then you probably want a class.

What do I mean by that ?

Suppose you create a structure and put it in a module. And then that module has all kinds of methods that perform some kind of operations on that structure. That really probably _should_ be a class and all the methods in that module methods in the class.

Modules, or namespaces, arent as a mechanism to define a data type. This kind of style is very classical non-OOP design.

There _may_ still be reasons you want to use this style though. Yoi might use it when the data you’re dealing with is used for a declare or other external API and so your choices ARE limited by what declares can accept. There _may_ be other ways to deal with this situation but it wouldn’t be the worst choice to use a namespace in such a case.