tags:

views:

126

answers:

5

(This is not an interface: I simply omitted the method bodies)

class _ {
    protected $_data = array();

    function __construct($data);

    function set($name, $value);

    function get($name);

    function __set($name, $value);
    function __get($name); //aliases for their respective non-magic methods.

    # and some other generic methods
}

Essentially it's a class that provides a magical object-oriented reusable access layer to some data. I've considered DataLayer, DataObject and some others; I'd like to hear some suggestions from someone who's more terminologically savvy.

+6  A: 

How about Dave ;)

Seriously though, what about DataAccess

Cocowalla
+1 for `Dave`, -1 for `DataAccess`
salathe
Dave sounds good.
orlandu63
Tell people it's an acronym for Data Access Value Enumerator. They just might believe it!
webbiedave
+1  A: 

You could call it AccessLayer.

Gregory Gelfond
+2  A: 

Without knowing how the class is used and what data it's meant to wrap, it's hard to name it. "Wraps some data in magic OOP" is so generic that a meaningful class name is difficult.

If it's for sitting between the controller and the database, you could call it ActiveRecord.

If it really is just for providing some OOP syntactic sugar to an array(), you could simply use the built-in StdClass.

Failing that, given that the only purpose of the class seems to be to wrap an array, I'd be tempted to call it ArrayWrapper.

meagar
+1  A: 

It really resembles KeyPairValue and if you with to make it more specialized in defining how Get would find its entries say using a Hash() function, then it's a Hashtable.

  • class KeyPairValue
  • class Hashtable

Now the question is why? Most SDKs would offer such data structures?

Try to use existing structures and not re-invent them.

ruralcoder
+1  A: 

There's a class like that in Magento. Well, it's got a lot more stuff in it, but the philosophy is the same: add some magic method goodness to the rest of your classes via inheritance. They named it Varien_Object, Varien being the name of the company.

I've also got something like this in a custom framework I've helped build. It's just called Base.

I guess what I'm trying to say is... no matter what you call it, it wont help people understand what it does until they go through the code. Don't worry about it too much, by the time you're done it'll be buried so deep in your app that the only people that find it will be the kind that can grok what it does fairly quickly anyway

Manos Dilaverakis