otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.56k stars 1.04k forks source link

Move Events methods to namespace #4692

Open ramon-bernardo opened 2 months ago

ramon-bernardo commented 2 months ago

Pull Request Prelude

Changes Proposed

MillhioreBT commented 2 months ago

@ranisalt to what extent is it good to use namespace to handle all singletons? I personally like namespaces, but is it in its main function? Anyway, I can't think of any other idea.

ranisalt commented 1 month ago

to what extent is it good to use namespace to handle all singletons?

Singletons are ~almost~ always a bad idea. Namespaces are an enhanced private section in a class, since you hide the implementation details and the compiler can assume it's not visible and perform more aggressive optimizations.

I like this post on how singletons are an awful idea in general. Namespaces don't solve it, but they make it less bad.