A Modest Namespace Proposal

Jon Galloway recently pointed out something that's been bothering me for a while:

I'm happy to see the huge growth of community contributed code - things like RSS.NET, sharpziplib, ftp classes to tide us over 'til .NET 2.0, etc. But one thing that bothers me is the namespaces. The .NET System namespaces are beautifully organized. Community / open source code namespaces are an anarchistic babel. Those that originate from a big company usually start with the company name, those that come from larger project usually take the the project's name. One-off code snips / hobbyist / micro-projects usually contain a random concatenation of some or all of the following words: monkey, alien, squishy, bug, fuzzy, code, util, works, MyNamespace, namespace, ware, example, contrib, and lib: monkeyCode, fuzzyAlienWare, utilLib, bugware, etc. This is the case I'm talking about.

Instead of answering Jon's implied question, I think we should be asking ourselves if we need to do this at all. Rather than blindly slapping 20+ characters of namespace on the front of all your classes "just because", I have a modest proposal for you: how about no namespace at all?

Almost every time I see namespaces used, they're not functional. They don't solve any collision or duplication problems for me. They're little more than vanity license plates for the author's code.

For example. I built this class MhtBuilder. It lets you duplicate the "Save as single file" functionality in IE using 100% managed code. It's not going to cure cancer or anything, but it's useful, not that common, and worth sharing. So I posted it on CodeProject. Do I really need to call this class..

  • CodingBadass.MhtBuilder
  • MonkeyAlienSquishyBugFuzzyCodeUtilWorks.MhtBuilder
  • AtwoodHeavyIndustries.MhtBuilder
  • MegaCorp.MhtBuilder
C'mon. Let's stop kidding ourselves. What does this accomplish? How many MhtBuilder classes are out there that I need to distinguish between? If you're distributing signed binaries with no source, then you can arguably make a case that you need a namespace. Otherwise, stop with the veiled ego tripping, give your class a good descriptive name, and have the cojones to leave it at that.

Read more

Stay Gold, America

We are at an unprecedented point in American history, and I'm concerned we may lose sight of the American Dream.

By Jeff Atwood · · Comments

The Great Filter Comes For Us All

With a 13 billion year head start on evolution, why haven't any other forms of life in the universe contacted us by now? (Arrival is a fantastic movie. Watch it, but don't stop there - read the Story of Your Life novella it was based on

By Jeff Atwood · · Comments

I Fight For The Users

If you haven't been able to keep up with my blistering pace of one blog post per year, I don't blame you. There's a lot going on right now. It's a busy time. But let's pause and take a moment

By Jeff Atwood · · Comments

The 2030 Self-Driving Car Bet

It's my honor to announce that John Carmack and I have initiated a friendly bet of $10,000* to the 501(c)(3) charity of the winner’s choice: By January 1st, 2030, completely autonomous self-driving cars meeting SAE J3016 level 5 will be commercially available for passenger

By Jeff Atwood · · Comments