Zach’s ugly mug (his face) Zach Leat­herman

Surnamespacing

May 07, 2008

Everyone has a library. Everyone has their own utility classes and functions they’re using in their own personal and contracted projects. And now that everyone has a blog too, they’re all releasing their libraries as open source, using the commando underoo philosophy of wild, free, and unrestricted naming schemes for their code. Not anymore. Let’s surnamespace.

What does surnamespacing give me?

  • Accountability: Your code is directly linked to your family honor. You’d be surprised how hard people work at test cases and increased code coverage when the respect of their lineage is at stake.
  • Connect with your Extended Family: Connect with programmers sharing your namespace, your family is now your development team.
  • Minimize Collisons: The ball and chain associated with an imposed naming scheme means that we won’t have everyone using foo and bar to hold their code, unless you’re the lucky son of a bitch that has inherited that top notch surnamespace real estate.
  • Faster Initial Development Cycle: Sometimes naming your library is the hardest part. Skip this step and just surnamespace it. Jesus Christ, please show me some examples:

JavaScript Surnamespacing

var Christ = {
        Jesus: {
            walkOn: function(obj) {},
            turn: function(from, to) {},
            respawn: function() {}
        }
    };
    // Sample Usage
    Christ.Jesus.walkOn('water');
    Christ.Jesus.turn('water', 'wine');
    Christ.Jesus.respawn();

Java Surnamespacing

package Christ;
    public class Jesus {
        public void walkOn(String s) {}
        public void turn(String from, String to) {}
        public void respawn() {}
    }

PHP 6 Surnamespacing (projected usage)

namespace Christ {
        class Jesus {
            public function walkOn($obj) {}
            public function turn($from, $to) {}
            public function respawn() {}
        }
    }

Update: Apparently I can’t write Java code. Don’t tell work.

Zach Leatherman is a builder for the web at Font Awesome and the creator of Build Awesome (née Eleventy/11ty), an award-winning open source website generator. He measures website performance with speedlify and at one point became too fixated on web fonts. He has given 86 talks in nine different countries at events like Beyond Tellerrand, Smashing Conference, Jamstack Conf, CSSConf, and The White House. Learn more about Zach »