MVC question

Discussion in 'Java' started by Stephanie Stowe, Jun 18, 2004.

  1. My collegues and I had a disagreement about what the "M" is. One (A)
    described the M as the DATA model, corresponding to database tables in the
    dbms. Another (B) and I have learned that it is the OBJECT model where the
    data model is "just persistence." This impacts the role of the "C". A
    beleives that "business processing" is the role of the controller. B and I
    believe that the controller is simply responsible for traffic control
    between the business processing, or object model, and the view. This
    traffic control layer between the business and the view was the whole point
    of struts as it was explained to me.

    Who is right? If we cannot understand this simple thing about MVC as a team,
    how on earth are we going to implement it properly?

    THANKS!

    S
    Stephanie Stowe, Jun 18, 2004
    #1
    1. Advertising

  2. Stephanie Stowe

    VisionSet Guest

    "Stephanie Stowe" <> wrote in message
    news:...
    > My collegues and I had a disagreement about what the "M" is. One (A)
    > described the M as the DATA model, corresponding to database tables in the
    > dbms. Another (B) and I have learned that it is the OBJECT model where the
    > data model is "just persistence." This impacts the role of the "C". A
    > beleives that "business processing" is the role of the controller. B and

    I
    > believe that the controller is simply responsible for traffic control
    > between the business processing, or object model, and the view. This
    > traffic control layer between the business and the view was the whole

    point
    > of struts as it was explained to me.
    >
    > Who is right? If we cannot understand this simple thing about MVC as a

    team,
    > how on earth are we going to implement it properly?
    >


    You & B are right on both counts.
    The controller most certainly has nothing to do with 'business processing'.
    The controller is a go between, between model & view it has references to
    both view and model, probably typed as interface. It listens to events in
    both model & view and makes calls on both in response.

    --
    Mike W
    VisionSet, Jun 18, 2004
    #2
    1. Advertising

  3. Stephanie Stowe

    Oscar kind Guest

    Stephanie Stowe <> wrote:
    > My collegues and I had a disagreement about what the "M" [in MVC] is.

    [ Stance A: only the data; the controller does business logic.]
    [ Stance B: data & business logic. ]

    Although stance A is often implemented in real-life applications to some
    extend, it is most certainly wrong: it makes for applications that become
    extremely rigid and expensive in maintenance when they near completion.

    Stance B (the correct one) ensures the modularity of the MVC pattern:
    - the model contains all business logic
    - the view contains all display logic
    - the controller ties these things together

    The controller should only contain boilerplate code, and may even be
    implemented as a small set of classes that pass all commands of the user
    to the model.

    Also note that if the controller contains no significant logic, you can
    use vanilla JUnit to do regression testing, while you only need to test
    each page in the view only once (as a view contains no logic and thus
    nearly no bugs).


    kind regards,
    Oscar

    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
    Oscar kind, Jun 18, 2004
    #3
  4. "Oscar kind" <> wrote in message
    news:...
    > Stephanie Stowe <> wrote:
    > > My collegues and I had a disagreement about what the "M" [in MVC] is.

    > [ Stance A: only the data; the controller does business logic.]
    > [ Stance B: data & business logic. ]
    >
    > Although stance A is often implemented in real-life applications to some
    > extend, it is most certainly wrong: it makes for applications that become
    > extremely rigid and expensive in maintenance when they near completion.
    >
    > Stance B (the correct one) ensures the modularity of the MVC pattern:
    > - the model contains all business logic
    > - the view contains all display logic
    > - the controller ties these things together
    >
    > The controller should only contain boilerplate code, and may even be
    > implemented as a small set of classes that pass all commands of the user
    > to the model.
    >



    Collegue A has backed off the idea that the model is the data model. There
    is such a one to one correspondence in this one app between the underlying
    persistence and the objects in the model, that it made sense. There is still
    some confusion about the role of the controller.

    Here stems our confusion in discussion. I am going to give you a little info
    about our app. We are creating an application, as in the ability to apply
    for a loan. On one page, the user chooses to include a spouse's information.
    The user is directed to a page to enter the spouse's information. OR the
    user chooses not to include the spouse's information. Then the user is
    directed to a different page.

    The VIEW encompasses the 2 JSP pages which may accessed. The MODEL contains
    the value object for Person, Spouse, Loan etc.. It is appropriate that the
    CONTROLLER be aware of the different navigation paths that must be taken
    given the choice in the request. As such, the contoller is responding to a
    business rule in that it knows what to do for a spouse or no spouse.

    Does this make sense? If not, no worries. I have only been charged with
    classes that are definitely part of the Model up to this point. But I am
    going to run over the apache and run through some of the tutorials so I am
    not so ignorant. Perhaps it will become clear to me then.

    Thanks for your help!

    > Also note that if the controller contains no significant logic, you can
    > use vanilla JUnit to do regression testing, while you only need to test
    > each page in the view only once (as a view contains no logic and thus
    > nearly no bugs).
    >
    >
    > kind regards,
    > Oscar
    >
    > --
    > Oscar Kind http://home.hccnet.nl/okind/
    > Software Developer for contact information, see website
    >
    > PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
    Stephanie Stowe, Jun 21, 2004
    #4
  5. Stephanie Stowe

    Oscar kind Guest

    Stephanie Stowe <> wrote:
    > [...] We are creating an application, as in the ability to apply
    > for a loan. On one page, the user chooses to include a spouse's information.
    > The user is directed to a page to enter the spouse's information. OR the
    > user chooses not to include the spouse's information. Then the user is
    > directed to a different page.
    >
    > The VIEW encompasses the 2 JSP pages which may accessed. The MODEL contains
    > the value object for Person, Spouse, Loan etc.. It is appropriate that the
    > CONTROLLER be aware of the different navigation paths that must be taken
    > given the choice in the request. As such, the contoller is responding to a
    > business rule in that it knows what to do for a spouse or no spouse.
    >
    > Does this make sense?


    Yes, perfectly.

    It occurred to me that I may have misrepresented the location of the
    business logic a bit, given the way most people seem to understand it
    (I'm also still learning).

    Both the view and the controller cannot be unaware of the business logic:
    - the view must know what information to request/represent and what
    actions can be performed (so it can show a button for example).
    - the controller must know how to validate the information and how to
    navigate through the view (including login and errors).


    kind regards,
    Oscar

    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
    Oscar kind, Jun 21, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thatguy Steve

    Basic MVC Question(s)

    Thatguy Steve, Aug 14, 2003, in forum: Java
    Replies:
    6
    Views:
    494
    Steven T Abell
    Aug 15, 2003
  2. LuCk

    Dumb MVC++ Question

    LuCk, Jan 3, 2004, in forum: C++
    Replies:
    1
    Views:
    322
    Victor Bazarov
    Jan 3, 2004
  3. rmn190
    Replies:
    2
    Views:
    2,331
    Arne Vajhøj
    Jan 10, 2008
  4. Paulo
    Replies:
    3
    Views:
    462
    Peter Bromberg [C# MVP]
    Dec 4, 2008
  5. Crazy Cat
    Replies:
    1
    Views:
    671
    schepp
    Sep 3, 2009
Loading...

Share This Page