The Model-View-Controller Design Pattern
A good practice when developing applications is to employ design patterns. Design patterns are a convenient way of reusing object-oriented concepts between applications and developers. The idea behind design patterns is simple: document and catalog common behavior patterns between objects. Developers can then make use of these patterns rather than re-create them. One of the frequently used design patterns is the Model-View-Controller (MVC) pattern.
In the MVC pattern, the user input, the business logic, and the visual feedback to the user are explicitly separated and handled by three types of objects. Each of these objects is specialized for a particular role in the application:
The model manages the data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).
The view manages the presentation of the application output to the user.
The controller interprets the mouse and keyboard inputs from the user, commanding the model and/or the view to change as appropriate.