|
Class::Meta offers a useful accessor style that you may want to consider. From Class::Meta doc:
The boolean data type is the only one that uses a slightly different approach to the creation of affordance accessors: It creates three of them. Assuming you're creating a boolean attribute named "alive", it will create these accessors:
sub is_alive { shift->{alive} }
sub set_alive_on { shift->{alive} = 1 }
sub set_alive_off { shift->{alive} = 0 }
Suggested accessor style name is 'bool' or 'boolean'.
A good coding practice is to prefix the boolean attribute/field with 'is_', i.e. 'is_alive'. Example: 'is_finished' for the object attribute. Using the above accessor style would require naming the boolean attributes without the 'is_'; this seems to be a reasonable approach. Other thoughts on how to fit coding practive with this useful accessor style?
Thanks for your hard work, Bill |