I was studying the Model-View-Controller design pattern and i understand the concept behind the pattern theorotically, but I wanted to get a peek at how one would actually put i
A simple text editor could be designed based on MVC. Think of the string
class as the model, where data is stored. We might have a class called SimpleTextView
which displays the text in the string
attached to it, as it is. A class called KeyboardEventHandler
can act as the controller. The controller will notify the view about new keyboard events. The view in turn modifies the model (like appending or removing text). The changes in the model is reflected on all views attached to it. For instance, there might be another view called HtmlView
attached to the string
object manipulated from within the SimpleTextView
. If the user enters valid HTML tags in the SimpleTextView
, the HtmlView
will display the formatted output - real-time.