by admin admin Yorum yapılmamış

The dating site is powered by tons of user information

The dating site is powered by tons of user information

Users create profiles, list their interests, dislikes, and answer silly questions that are probably irrelevant to dating. This information needs to be stored somewhere. The model deals with information storage and retrieval.

The dating site lets its users see their own profile and others’ profiles. Maybe it has a page that shows you a random person a la Russian Roulette. Each of those pages has its own look and feel. The view deals with presentation of content like a newspaper layout.

A whole lot of logic goes into the site’s recommendations for you. Using some complex algorithm (like throwing darts) the site presents a list of users it thinks you’d be compatible with. The controller handles the program’s logic, including the importance of information in relation to other data.

Since most applications have these three basic needs, developers tend to separate these concerns into their own homes in the program. By convention (and by default), the app folder generated by a rails new command contains a subfolder for controllers, a subfolder for models, and a subfolder for views.

MVC illustrates an overarching concept in programming: convention over configuration, the principle that common structural concerns should follow a common structural patterns, the way sentences abide grammatical rules (and when they don’t, you end up with Finnegan’s Wake).

The Flow of Information in the MVC Pattern in Rails

The MVC pattern has the cobenefit of making it much easier to learn Rails (or D can be learned about separately. Read more