Inside out objects

So a few weeks ago I stumbled across perlcritic. Which led to finding Module::Starter::PBP as a way to try to stop the carping my code was generating with missing perldoc, etc etc. I’ve been looking at Perl Best Practices on OReilly’s Safari, but I’ve never really sat down and read it online. So because perlcritic seems to hate lots of things about my code, and because each complaint is backed up by a page number in PBP, I decided to buy it.

Last night I was reading through it over my late dinner (Brooke recycled the newspaper) and I stumbled across Inside Out Objects. What a cool concept. I always feel like Perl is far more advanced than it is given credit for being, and I am also struck by its similarities with JavaScript, possibly because both of them can be pretty freewheeling, but also respond well to careful programming.

Anyway, one of the things I’ve noticed in JavaScript is that it is relatively easy to subvert an object. Even Google Maps objects, wrapped up in closures and all, can still be manipulated somewhat by using some of the inheritance methods described by Douglas Crockford.  So  I wonder if it is possible to use inside out objects in JavaScript?  I wonder if that would prevent unauthorized access to internal data and methods of an object.  I have to think about how to do it right, because JavaScript doesn’t have a bless mechanism, but maybe even though you still use a hash as an object, you can still invert the object’s methods to use the hash signature as a key to internal hashes/objects that do the real work.  I don’t know if there is an ident function, but I’m pretty sure one can hack up a UUID, even if it has to be generated server-side (either make a list of UUIDs at load time, or set up a service to spit out UUIDs, or both).

I guess I should try it and see.  Perhaps I should try the technique in Perl first.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s