Design Patterns Tutorial
A tutorial on GOF design patterns. This tutorial is for beginners who are going to learn design patterns for the first time. Each pattern is expalined with suitable examples.

15/11/2013 Categories: Introduction. No Comments on Design Patterns in Smalltalk MVC

The Model/View/Controller set of classes are used to build user interfaces in Smalltalk-80. MVC consists of three kinds of objects. Model is the application object. View is the representation of the model and the Controller specifies how the user interface (View) reacts to the user input. Before MVC, these three objects (Model, View and Controller) used to be coupled together.

design patterns in smalltalk

MVC decouples model and view objects using the subscribe/notify protocol. Whenever the data in the model changes, it has to notify the associated views. In response, each view gets a chance to update itself. This allows add or create views on a model without changing the model itself. In the figure we can see three views: a table display, a bar chart and a pie chart associated with the same model. When the data in the model changes, the views are updated accordingly. This design that decouples views from models can be applied in a more general problem context like: decoupling objects where a change in one object causes change in all other associated objects. Such design pattern is the observer pattern.

Another feature of MVC is, views can be nested. For example, a control panel can contain a set of buttons as a button view along with other controls which are nested inside the main container view. In Smalltalk, nested views are supported by the class CompositeView which is a sub class of the View class. This design can be applied in a more general context like: to group a set of objects and that group can be treated as an individual object. This general design is described as the composite pattern.

MVC also lets us change how the view responds based on the user input. This is achieved through controller classes in Smalltalk. For example, we might want the view to respond based on key strokes or through mouse movement on the user interface. It is even possible to change a view’s controller at run time. This design can be applied in a general context: where you have several variants of an algorithm and you want to apply a single algorithm either statically or dynamically. This View-Controller relationship is an example of Strategy pattern. A strategy is an object which represents an algorithm.

These three patterns: Observer, Composite and Strategy specify the main relationships in MVC although there are other design patterns like Factory Method and Decorator.

Suryateja Pericherla

Suryateja Pericherla

Hello, I am Suryateja Pericherla working as an Asst. Professor in CSE department at Vishnu Institute of Technology. I write articles to share my knowledge and make people knowledgeable regarding certain topics.
Suryateja Pericherla

Latest posts by Suryateja Pericherla (see all)

Note: Do you have a question on this article or have a suggestion to make this article better? You can ask or suggest us by filling in the below form. After commenting, your comment will be held for moderation and will be published in 24-48 hrs.
Scroll Up
Thank you for visiting! If you like this website do share with your friends by clicking on the social icons available on the left hand side.

As the domain name is quite large to remember, use this short domain to visit this site. Short domain: