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.
Class::Observable
Class::MVC::View
"Class::MVC::Model"
[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.
Class::MVC::Model
Reference to a Class::MVC::Controller object.
Class::MVC::Controller
Class::MVC::Model-notify_observers( 'update' )> will call a _on_update method of the observing View's.
Class::MVC::Model-
_on_update
[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.
update()
super_view
sub_view
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.
Class::Listener
update ( $this, @_ )
Sends a Class::Listener change ( $this, @_ ) signal to the view.
change ( $this, @_ )
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").
Class::Listener::signal
None by default.
Murat Uenalan, <muenalan@cpan.org>
Class::Maker, Class::Listener and Class::Observable.
http://ootips.org/mvc-pattern.html
http://www.enode.com/x/markup/tutorial/mvc.html
http://st-www.cs.uiuc.edu/users/smarch/st-docs/mvc.html
2 POD Errors
The following errors were encountered while parsing the POD:
=back without =over
=over without closing =back
To install Class::MVC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::MVC
CPAN shell
perl -MCPAN -e shell install Class::MVC
For more information on module installation, please visit the detailed CPAN module installation guide.