This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Chalk Board [Nov. 11, 2011, 11:22 a.m.]


11/10/11 MVC

Note: what you’re about to read is my take/understanding of the concept of MVC. Comments and corrections are most welcome…

The MVC is independent from a programming language, therefore, in this case - independent from the Ruby language.

The Model, Viewer and Controller (MVC) architecture is a concept of order and expectation associated with patterns to build and manage a repetitive job task.

The Model is responsible for production or service.

The Viewer is responsible for communication.

The Controller is responsible for direction of interaction.

Let’s look at an example: A Car

Application Domain: Transportation.

The Model is the car.

The Viewer is the dashboard.

The Controller is you.

One repetitive job task out of many while operating a car is to move the car at a certain speed to get from point A to point B. But let’s break it down even further to one simple task, to move the car from speed 0 to 55mph.

As the controller, you step on the gas. As the model, the car starts moving at a speed relevant to the amount of gas injecting into the engine. As the viewer, the dashboard’s speed meter displays the speed at which the car is moving. You react to what is displayed on the meter by pressing the gas pedal controlling the inject gas amount into the engine. The car moves faster, the dashboard displays the difference in speed, you push the pedal more until… voila! The car speed is 55mph. A repetitive and expected outcome to a common task has now just been completed.

I hope that this was a good example in breaking down the MVC architecture.

Up next, I would like to share RAILS directory structure with MVC design pattern.

11/11/11 (How often do you see this date format: The day of ONES)

I came across this learning website which to me seem easy to understand and well organized. Even thought it is based on RAILS 2.1, the fundementals seems the same.

For me every little bit helps: http://www.tutorialspoint.com/ruby-on-rails/index.htm