
Class::MVC - model-view-controller paradigma

use Class::Maker 'class';
use Class::MVC;
class 'Widget',
{
isa => [qw( Class::MVC )]
};
class 'Widget::ViewModel',
{
isa => [qw( Device::Output::Channel )],
public =>
{
string => [qw( info )],
},
};
class 'Widget::Model',
{
isa => [qw( Class::MVC::Model Shell::Widget::ViewModel)],
};
class 'Widget::View',
{
isa => [qw( Class::MVC::CompositeView )],
public =>
{
ref => [qw( device )],
},
};
class 'Widget::Controller',
{
isa => [qw( Class::MVC::Controller )],
public =>
{
ref => [qw( sensor )],
},
default =>
{
sensor => Device::Input->new(),
},
};

The Model-View-Controller (MVC) is a general paradigma mostly used for GUI-development. It is very well known and tons of publications are available through your favorite search engine (Or jump to "REFERENCES"). It is also an introductional example from the famous "Design Patterns" book.
+------------+
| Model |
+------------+
/\ . /\
/ . \
/ . \
/ . \
/ \/ \
+------------+ <------ +------------+
Graphical <==== | View | | Controller | <==== User Input
Output +------------+ ......> +------------+
This class is derived from Class::Observable (Class::Observable). Class::MVC::View's observe it to make appropriate changes to the presentation (aka View) if an update of the "Class::MVC::Model" happens.
[Note] Some publications prefer to separate a Data Model and a View Model. My personal preference tend to have a simple ViewModel class and let a DataModel class derive from Class::MVC::Model and our ViewModel class.
Reference to a Class::MVC::Model object.
Reference to a Class::MVC::Controller object.
Class::MVC::Model-notify_observers( 'update' )> will call a _on_update method of the observing View's.
[Note] Class::MVC::View is derived from Class::Listener to dispatch the observer notify to the _on_update method.
This is the base class for nested views. A CompsiteView is a derived View. Its update() method takes the job to inform the super_view of sub_view changes changes.
See "REFERENCES".
Points to the view that contains it and another subviews.
An array pointing to all subviews.
Reference to a Class::MVC::Model.
Reference to a Class::MVC::View.
Sends a Class::Listener update ( $this, @_ ) signal to the model.
Sends a Class::Listener change ( $this, @_ ) signal to the view.
Calls Class::MVC::View methods to do controller specific view changes (for example beep() or flicker() when wrong input is done).
Signals are transported via the Class::Listener::signal method ("SEE ALSO").
None by default.

Murat Uenalan, <muenalan@cpan.org>

Class::Maker, Class::Listener and Class::Observable.
