Cagao has asked for the wisdom of the Perl Monks concerning the following question:
I'm in the process of building an object, which as one of it's accessors contains a list of other objects.
These other objects are only id/name pairs at the minute but may well grow, so I'm modelling them as proper objects from the start.
What are peoples thoughts on this as a design...
has _industries => ( is => 'rw', isa => 'HashRef[Foo::Industry]', auto_deref => 1, default => sub { {} }, clearer => 'clear_industries', traits => ['Hash'], handles => { has_industry_id => 'exists', add_industry => 'set', get_industry_for_id => 'get', industry_ids => 'keys', industries => 'values', num_industries => 'count', }, );
Clearly all the specified handles are how you'd interact with the list/hash.
I don't wanna get 3 months into using this code in various places only to realise a flaw in the design.
Any thoughts, comments, suggestions, issues?
Thanks
Cagao
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Moose Design Thoughts (Traits)
by moritz (Cardinal) on Dec 22, 2010 at 13:51 UTC | |
by Cagao (Monk) on Dec 22, 2010 at 14:08 UTC | |
by moritz (Cardinal) on Dec 22, 2010 at 17:33 UTC | |
Re: Moose Design Thoughts (Traits)
by stvn (Monsignor) on Dec 22, 2010 at 20:55 UTC | |
by perigrin (Sexton) on Dec 23, 2010 at 06:42 UTC | |
by Cagao (Monk) on Dec 23, 2010 at 09:36 UTC | |
by Cagao (Monk) on Dec 23, 2010 at 09:39 UTC | |
by stvn (Monsignor) on Dec 23, 2010 at 19:21 UTC | |
by Cagao (Monk) on Dec 24, 2010 at 11:57 UTC |