in reply to Moose Design Thoughts (Traits)

You missed the most important part: the way this class is going to be used.

In general good API design should include many possible use cases. Writing a class is just writing part of an API.

As you've shown it, your class is just a glorified hash, with no reason not to use a hash in the first place. Adding methods that do some actual work might change the situation. But again that depends on how you want to use your class.

Asking your questions without more background information is like asking "is the Ford Fiesta a good car for me?", but not telling what you want to use it for (offroad? crossing a dessert? taking your 6 family members to vacations? Or just some shopping half a mile away?)

Replies are listed 'Best First'.
Re^2: Moose Design Thoughts (Traits)
by Cagao (Monk) on Dec 22, 2010 at 14:08 UTC

    Cheers for the input.

    The object will be used by people I don't trust :) so I'm not giving them direct access to the hash, hence it also being "private" - it'll be used a lot by front-end guys working in TT, and thankfully that forces privacy of the methods.

    It'll also be used by people writing scripts (before/after TT), to set the contents of the hash before saving the state of it.

    This main class will have several of these types of lists, and other simpler attributes.

    I'd always previously just used a list in these circumstances, then moved to a hash for quicker lookups and less loops in checking the contents, and now using the Traits with Moose.

    I've added the trait handles as I've been writing a script that needs them, gradually moving more and more towards to the Moose way of doing things.

    Just wanted to make sure I wasn't going off on the wrong tangent, or maybe I've mis-understood something.

    Thanks again, all greatly appreciated.

      Ok, now you've told us who uses your class, but not how. Image you were not the implementer of the class, but its user. In your ideal world, what would you do with objects of that class, and how would the API look like?