Devel::StrictObjectHash

Devel::StrictObjectHash is a strict access-controlled hash for debugging objects.
Download

Devel::StrictObjectHash Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Stevan Little
  • Publisher web site:
  • http://search.cpan.org/~stevan/

Devel::StrictObjectHash Tags


Devel::StrictObjectHash Description

Devel::StrictObjectHash is a strict access-controlled hash for debugging objects. Devel::StrictObjectHash is a strict access-controlled hash for debugging objects.SYNOPSIS use Devel::StrictObjectHash ( # replace bless in the modules that match this reg-ex strict_bless => qr/.*?Module$/, # allow hash autovivification in routines other than 'new' allow_autovivification_in => qr/create_.*|_init/, # set the field access identifiers field_access_identifiers => { # no public access allowed public => undef # first char is an underscore followed by alpha protected => /^_/ # the word 'private' followed by an underscores # followed by an alpha character private => /^private_/ }, # turn on debugging debug => 1 );The goal of this module is to provide a drop in bless replacement for debugging object field access issues during development. It should never be used in production, as it has performance costs.What does this module do?This module implements a tied hash which has OO style access control. By default, it provides protected style access control for regular hash keys, and private style access control for hash keys that are prefixed with a underscore (_), and does not allow any form of public access. However, if this is too strict a setting, it is possible to configure the key-style for public, protected and private access using regular expressions (see INTERFACE).How do I use this module?The idea is that you configure this module at the top of your script (or in your mod_perl startup.pl file) to turn it on. Your application will then raise an error (the default is to die) if you try to access your object fields incorrectly. It will quickly help you to find where someone (possibly you) is doing bad things with your objects.Do I need to change my code to use this module?Yes and No.No - If your code is well written OO code, then you should not have to make any other changes then to load and configure Devel::StrictObjectHash. I have tried (and am trying) to make this object as configurable as possible to cover many styles of hash-based OO code. However, if I am not accomadating your style (and you would like me too), let me know.Yes - If your OO is not so good and you do things like allow private fields to be accessed by subclasses, or access fields outside of object methods or other such nastiness. Then you will likely either not want to use this module at all, or you will need to recode.However, if your goal is to recode/refactor "bad-style" OO, then you actually may find this module very useful. Requirements: · Perl


Devel::StrictObjectHash Related Software