in reply to Implementing Model-View-Controller
You can change how the Model stores and retrieves the data without impacting either of the others. You can change how the View gets and displays its templates without impacting the others. You could use a different controller, e.g. an interactive script that prompted for foodtype. ...#!/usr/bin/perl -w use strict; package Model; my $data = { fruits=>'apples',vegies=>'carrots'}; sub get_food { $data->{$_[0]} } package View; my $template = "I like %s, especially %s!\n"; sub show_food { printf $template, @_ } package main; # Controller; for my $foodtype(qw(fruits vegies)) { my $food = Model::get_food($foodtype); View::show_food($foodtype,$food); } __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Implementing Model-View-Controller
by dimar (Curate) on Jan 05, 2006 at 16:15 UTC | |
by jZed (Prior) on Jan 05, 2006 at 18:19 UTC | |
by dimar (Curate) on Jan 05, 2006 at 19:33 UTC |