Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

One first question you should do to yourself is: How big is this system?

This question is important because this can make you choice from two different approuches...

1) If the system is small and you just need to show the contents of a database, you can stick to the MVC used by struts, or others... wich mean that the Model object is the database encapsulation.

2) OTOH, if the system is supposed to be a little bigger, and you're not just showing the contents of the table, but you have to deal with business rules you probably want to create a more sofisticated design...

In this design, you would split your system in two parts, one as a Service Provider that would provide the needed services to retrieve and save the information, so you can implement multiple interfaces, or interface with other systems (see Web Services Architecture in w3c website)...

The not-so-obvious implication is that the Model object will not necessarly represent the plain table, but could also include some calculated information, some object's relationships.

Now to the implementation:

The main key to MVC is a magic keyword named: "event". The key is... When the model is changed, it notifies the changes, so if the model is changed by the Controller (I mean, loading the data) the UI is updated, and if the UI changes the Model, the controller can be notified and do some extra calculation (I mean, sum the values and set the total value in the model and the UI will be notified).

The big difference is that when you want to fetch the data to send to your service, you will not traverse all the components getting the values, the model will be already in the format you need to pass to the service, thus, reducing the complexity of the user interface.

daniel

In reply to Re: Implementing Model-View-Controller by ruoso
in thread Implementing Model-View-Controller by ghferrari

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (6)
    As of 2021-04-20 11:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?