3 ms·
Just put the function in a namespace?
by cgrealy 6y ago
Just put the function in a namespace?
- ClikeX 6y agoIn Ruby, that basically comes down to creating a static class.
- risorect 6y agoIn terms of ruby, we may be splitting hairs when it comes to namespaces vs classes. Modules, which are typically used for namespacing, can have state and extend themselves, making them effectively singleton classes.
- ratww 6y ago> Modules, which are typically used for namespacing, can have state But there's nothing about state that makes it specific to classes. Namespaces in C++ can hold (static) state, for example. So it's actually the other way around: singleton classes can effectively be namespaces/modules.
- cessor 6y agoObject without state but with functions is just a namespace. But that depends on how the language implements it.
- hamandcheese 6y agoIn Ruby that looks a lot like what the article says is an anti-pattern.