.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Class::InsideOut::Manual::About 3pm" .TH Class::InsideOut::Manual::About 3pm "2022-12-12" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Class::InsideOut::Manual::About \- guide to this and other implementations of the inside\-out technique .SH "VERSION" .IX Header "VERSION" version 1.14 .SH "DESCRIPTION" .IX Header "DESCRIPTION" This manual provides an overview of the inside-out technique and its application within \f(CW\*(C`Class::InsideOut\*(C'\fR and other modules. It also provides a list of references for further study. .SS "Inside-out object basics" .IX Subsection "Inside-out object basics" Inside-out objects use the blessed reference as an index into lexical data structures holding object properties, rather than using the blessed reference itself as a data structure. .PP .Vb 2 \& $self\->{ name } = "Larry"; # classic, hash\-based object \& $name{ refaddr $self } = "Larry"; # inside\-out .Ve .PP The inside-out approach offers three major benefits: .IP "\(bu" 4 Enforced encapsulation: object properties cannot be accessed directly from outside the lexical scope that declared them .IP "\(bu" 4 Making the property name part of a lexical variable rather than a hash-key means that typos in the name will be caught as compile-time errors (if using strict) .IP "\(bu" 4 If the memory address of the blessed reference is used as the index, the reference can be of any type .PP In exchange for these benefits, robust implementation of inside-out objects can be quite complex. \f(CW\*(C`Class::InsideOut\*(C'\fR manages that complexity. .ie n .SS "Philosophy of ""Class::InsideOut""" .el .SS "Philosophy of \f(CWClass::InsideOut\fP" .IX Subsection "Philosophy of Class::InsideOut" \&\f(CW\*(C`Class::InsideOut\*(C'\fR provides a set of tools for building safe inside-out classes with maximum flexibility. .PP It aims to offer minimal restrictions beyond those necessary for robustness of the inside-out technique. All capabilities necessary for robustness should be automatic. Anything that can be optional should be. The design should not introduce new restrictions unrelated to inside-out objects, such as attributes and \f(CW\*(C`CHECK\*(C'\fR blocks that cause problems for \f(CW\*(C`mod_perl\*(C'\fR or the use of source filters for syntactic sugar. .PP As a result, only a few things are mandatory: .IP "\(bu" 4 Properties must be based on hashes and declared via \f(CW\*(C`property\*(C'\fR .IP "\(bu" 4 Property hashes must be keyed on the \f(CW\*(C`Scalar::Util::refaddr\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`register\*(C'\fR must be called on all new objects .PP All other implementation details, including constructors, initializers and class inheritance management are left to the user (though a very simple constructor is available as a convenience). This does requires some additional work, but maximizes freedom. \f(CW\*(C`Class::InsideOut\*(C'\fR is intended to be a base class providing only fundamental features. Subclasses of \f(CW\*(C`Class::InsideOut\*(C'\fR could be written that build upon it to provide particular styles of constructor, destructor and inheritance support. .SS "Other modules on \s-1CPAN\s0" .IX Subsection "Other modules on CPAN" .IP "\(bu" 4 Object::InsideOut \*(-- This is perhaps the most full-featured, robust implementation of inside-out objects currently on \s-1CPAN.\s0 It is highly recommended if a more full-featured inside-out object builder is needed. Its array-based mode is faster than hash-based implementations, but black-box inheritance is handled via delegation, which imposes certain limitations. .IP "\(bu" 4 Class::Std \*(-- Despite the name, this does not reflect currently known best practices for inside-out objects. Does not provide thread-safety with \s-1CLONE\s0 and doesn't support black-box inheritance. Has a robust inheritance/initialization system. .IP "\(bu" 4 Class::BuildMethods \*(-- Generates accessors with encapsulated storage using a flyweight inside-out variant. Lexicals properties are hidden; accessors must be used everywhere. Not thread-safe. .IP "\(bu" 4 Lexical::Attributes \*(-- The original inside-out implementation, but missing some key features like thread-safety. Also, uses source filters to provide Perl\-6\-like object syntax. Not thread-safe. .IP "\(bu" 4 Class::MakeMethods::Templates::InsideOut \*(-- Not a very robust implementation. Not thread-safe. Not overloading-safe. Has a steep learning curve for the Class::MakeMethods system. .IP "\(bu" 4 Object::LocalVars \*(-- My own original thought experiment with 'outside\-in' objects and local variable aliasing. Not safe for any production use and offers very weak encapsulation. .SS "References for further study" .IX Subsection "References for further study" Much of the Perl community discussion of inside-out objects has taken place on Perlmonks (). My scratchpad there has a fairly comprehensive list of articles (). Some of the more informative articles include: .IP "\(bu" 4 Abigail-II. \*(L"Re: Where/When is \s-1OO\s0 useful?\*(R". July 1, 2002. .IP "\(bu" 4 Abigail-II. \*(L"Re: Tutorial: Introduction to Object-Oriented Programming\*(R". December 11, 2002. .IP "\(bu" 4 demerphq. \*(L"Yet Another Perl Object Model (Inside Out Objects)\*(R". December 14, 2002. .IP "\(bu" 4 xdg. \*(L"Threads and fork and \s-1CLONE,\s0 oh my!\*(R". August 11, 2005. .IP "\(bu" 4 jdhedden. \*(L"Anti-inside-out-object-ism\*(R". December 9, 2005. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 4 Class::InsideOut .IP "\(bu" 4 Class::InsideOut::Manual::Advanced .SH "AUTHOR" .IX Header "AUTHOR" David Golden .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2006 by David A. Golden. .PP This is free software, licensed under: .PP .Vb 1 \& The Apache License, Version 2.0, January 2004 .Ve