NAME

POE::Declare - A POE abstraction layer for conciseness and simplicity

SYNOPSIS

package MyComponent;

use strict;
use POE::Declare;

declare foo          => 'Attribute';
declare bar          => 'Internal';
declare TimeoutError => 'Message';

sub hello : Event {
    print "Hello World!\n";
}

sub hello_timeout : Timeout(30) {
    print "Alas, I die!\n";

    # Tell our parent as well
    $_[SELF]->TimeoutError;
}

1;

DESCRIPTION

WARNING: THIS CODE IS EXPERIMENTAL AND SUBJECT TO CHANGE WITHOUT NOTICE

POE is a very powerful and flexible system for doing asynchronous programming.

But personally, I find it confusing and tricky to use at times.

In particular, I have found it hard to resolve POE's way of programming with the highly abstracted OO that I am used to, with layer stacked upon layer ad-infinitum to create powerful and complex systems that are still easy to maintain.

I have found this particularly noticable as the scale of a codebase gets later. At three levels of abstraction the layering become quite difficult, and beyond this it became worse and worse.

POE::Declare is my attempt to resolve this problem by locking down some of the traditional flexibility of POE, and by (hopefully) makeing it easier to split the implementation of each object between an object-oriented half and a POE half.

This will hopefully allow me to utilise POE's asynchronous nature, while retaining the traditional codebase scaling capability provided by normal OO.

Of course, this entire exercise is something of a grand experiment and it may well turn out that I am wrong. But I think I'm heading in the right general direction (I just don't know if I'm taking quite the right path).

ARCHITECTURE

POE::Declare is composed of three main modules, and a tree of slot/attribute classes.

POE::Declare

POE::Declare::Object

POE::Declare::Object is the abstract base class for all classes created by POE::Declare.

POE::Declare::Meta

POE::Declare::Meta implements the metadata objects that describe each of the POE::Declare classes.

POE::Declare::Slot

POE::Declare::Meta::Slot
  POE::Declare::Meta::Internal
  POE::Declare::Meta::Attribute
    POE::Declare::Meta::Param
  POE::Declare::Meta::Message
  POE::Declare::Meta::Event
    POE::Declare::Meta::Timeout

POE::Declare::Meta::Internal

POE::Declare::Meta::Internal is a slot class that won't generate any functionality, but allows you to reserve an attribute for internal use so that they won't be used by any sub-classes.

POE::Declare::Meta::Attribute

POE::Declare::Meta::Attribute is a slot class used for readable attributes.

POE::Declare::Meta::Param

POE::Declare::Meta::Attribute is a slot class for attributes that are provided to the constructor as a parameter.

POE::Declare::Meta::Message

TO BE COMPLETED

POE::Declare::Meta::Event

POE::Declare::Meta::Event is a class for named POE events that can be called or yielded to by other POE messages/events.

POE::Declare::Meta::Timeout

POE::Declare::Meta::Timeout is a POE::Declare::Meta::Event sub-class that is designed to trigger from an alarm and generates additional methods to manage the alarms.

FUNCTIONS

For the first few releases, I plan to leave this module undocumented.

That I am releasing this distribution at all is more of a way to mark my progress, and to allow other POE/OO people to look at the implementation and comment.

declare

declare one   => 'Internal';
declare two   => 'Attribute';
declare three => 'Param';
declare four  => 'Message';

The declare function is exported by default. It takes two parameters, a slot name and a slot type.

The slot name can be any legal Perl identifier.

The slot type should be one of Internal, Attribute, Param or Message.

Creates the new slot, throws an exception on error.

compile

The compile function indicates that all attributes and events have been defined and the structure should be finalised and compiled.

Returns true or throws an exception.

SUPPORT

Bugs should be always be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Declare

For other issues, or commercial enhancement or support, contact the author.

AUTHORS

Adam Kennedy <adamk@cpan.org>

SEE ALSO

POE, http://ali.as/

COPYRIGHT

Copyright 2006 - 2009 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.