Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6713505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:23:20+00:00 2026-05-26T08:23:20+00:00

I just started to study the Model View Controller pattern. I now understand the

  • 0

I just started to study the Model View Controller pattern. I now understand the basic usage of MVC, but when i tried to implement MVC in a simple test, i ran into a problem. Ofcoarse I could easily adjust the code so it works, but I wish to learn how to correctly implement the MVC pattern.

The test:
I used actionscript 3 to make a simple program. It consist of a turret, and a mouseclick. The turret is in the middle of the screen. When I click anywhere the turret rotates towards the point where I clicked. Both the mouse and the turret have their own model,view and controller. When I click, the MouseModel changes correctly. But for the actual TurretView to respond, the TurretModel must change its rotation variable and send out an event.

The question is who responds to the MouseModel event?

     /------->MouseControl------\
    /                            \
MouseView                ?<---MouseModel

TurretView <------------------TurretModel

             TurretControl

I figured its best not to have MouseModel directly influence TurretModel or TurretControl, because this would require them to be an eventListener. Making TurretView listen to the MouseModel, and then tell TurretControl to adjust TurretModel, after wich TurretView can update trough a TurretModel event looks like a lot of extra code for a simple task. Also I’d rather not have MouseControl affect TurretModel, this would break the flexibility of the mouse as input for future classes.

Ow, also in which class do I put the code for the angle calculation?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:23:20+00:00Added an answer on May 26, 2026 at 8:23 am

    Remember that the goal with MVC is primarily the separation of Model and View, and the Controller can serve as the communicator between the two.

    Unless you are planning on storing each action that occurs (clicking, rotating, etc.), there is no real need for an action (in this situation) to send data to the Model. Everything you’d like to do should be easily handled with the Controller. So the flow would be:

    • Mouse click
    • Event is fired to trigger a command (in the Controller), passing along the mouse location
    • The command calculates the turret’s rotation
    • The command tells the View to rotate the turret

    This is, of course, my suggestion based off of your example. In truth, depending on the project, the above flow could easily change (for instance, in this situation it seems good to do rotation calculation in the command, but in other situations that may not make as much sense). Look at MVC as a goal – you’re trying to separate these elements as much as possible, but there is no 100% “works-every-time” way to do it.

    Robotlegs, a popular MVC framework, has a great diagram on their site showing how they tackled MVC:

    http://www.robotlegs.org/diagram/

    I’m not advertising that you NEED to use Robotlegs (it’s good, but there’s plenty of other alternatives), but they definitely made a pretty diagram 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started to study computer sciences at my university where they teach
Just started my first MVC 2.0 .net application. And I set up some default
Just started working with .NET and MVC(1). I'm having a problem wherein in my
I just started study of class and object in php. I have a very
I am new to C# and .NET and I just started to study LINQ
Just started a tutorial in SQL for beginners. I'm doing some exercises now and
Just started re-learning Haskell (did it at uni but forgot most of it) and
I have just started a feasibility study on Django for my company and I
I have just started to study jQuery and it seems to be full of
Just started converting to MVC from classic ASP and wondering about best practice for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.