Thursday, November 26, 2015

Day 18

MVC Architecture


I think one of the hardest parts about the bootcamp so far is picking up new technology like every other day. Yesterday was the last day of using Flask and MySQL. And we were only on Flask and MySQL for two days. Now we're learning Pylot MVC to help us understand MVC architecture.
MVC is a way to organize server side information.

Here's a flowchart of how MVC works
  • M stands for Model and does all the data manipulation to and from the database.
  • V stands for View and is all the HTML templates or whatever the user sees.
  • C stands for Controller and is the director of where information goes.
I struggled with understanding the routes of MVC. Since in Flask, everything is done on one server-side file, you initialize the app.route('/name of route') and when you want to redirect you just write redirect('/name of route'). But in MVC, you have a specific routes file that handles all routing. Initially, I thought this was a waste of time but I quickly realized how useful it is. This is the progression of routing:
  1. Form action on html page is submitted
  2. Information is sent to the routes file
  3. If the action matches the route as well as route method (POST, GET etc.), it will go to whatever is after the hash in this example ('Controller_name#method_name')
  4. It will go that controller's method and execute whatever code is written in it.
The assignments were all assignments we've done before, except this time we're doing everything in MVC so all in all, wasn't too much of a struggle today.

No comments:

Post a Comment