4

A "God Namespace" is the (uncommon) term for an (anti?)pattern analogous to the "God Object", when you stuff a metric ton of stuff (mostly methods/functions) that is not related or not closely related to each other into one huge namespace/static class just so that it can be used in multiple sections of your project.

When following that (anti?)pattern, you often end up, as a C# example, with something like a static class Assets with tons of methods mostly unrelated to each other, but used across multiple places in your project(s).

I usually approach this problem by letting the next Assets grow for as much as I can bear it, and then desperately try to sort its contents out into several smaller ones based on the criteria which seems most legit, like MathAssets, or BitmapAssets, or RNGAssets, and then end up forgetting what did I put where... and make a new Assets for several new methods which don't fit into either of the SomethingAssets already cluttering up the project.

Are there any other ways of clearing up the "God Namespace"? Or will I just have to live with good old static class Assets?

  • 2
    This has been asked (I'm sure) many times before. Here's one: http://stackoverflow.com/questions/3339929/if-a-utilities-class-is-evil-where-do-i-put-my-generic-code – rory.ap Apr 28 '15 at 14:32
  • @roryap: thanks, I must have been searching with the wrong keywords! =) I guess this should be re-closed as a duplicate... –  Apr 28 '15 at 14:33
  • 1
    Jon sonmez have a series of articles regarding this subject. [Here is the introduction](http://simpleprogrammer.com/2010/04/12/should-i-leave-that-helper-class/) and [read this](http://simpleprogrammer.com/2010/04/14/how-to-refactor-the-helper-class/) – Sriram Sakthivel Apr 28 '15 at 14:39

0 Answers0