Structure and Flow
We were back at it first thing this morning with another heavy lecture day to kickstart our second week into back-end (!). Unlike last week’s right-off-the-bat code/language/program intensive intro (see image below for a listing of just a few of last week’s concepts) , today’s discussion was more focused on some theories and approaches to developing and organizing your programs.
We started the lesson with a bit of review from last week, and then jumped straight into a conversation on MVC. For the uninitiated — aka, me about 12 hours ago — the MVC (Model View Controller) can be thought of as a sort of architectural/structural approach to building your programs.
The ‘M’ (i.e., ‘Model’) represents the database, and contains the majority of a program’s stored data. It handles most of the interactions pertaining to your data and communicates only with the ‘Controller’ (‘C’).
Get Emily Deans’s stories in your inbox
Join Medium for free to get updates from this writer.
The Controller, in turn, processes all of the CRUD requests (‘Create’, ‘Read’, ‘Update’, ‘Delete’) and handles all server-side logic. It acts as a sort of “middle-man” that takes information from the user, interprets that information in order to make appropriate requests of the database (Model), and then processes the response from the database and uses that to communicate to the browser (i.e., ‘View’) on how it should display the content.
The ‘V’ (‘View’) listens only to the Controller, and is the only component of this triad the user ever sees.
Many back-end language frameworks — including ‘Rails’ (for Ruby), ‘Django’ (for Python), and Cake (PHP) — use MVC, and it’s an extremely useful approach for structuring your files to improve the organizational flow of your programs.
After doing a few exercises, which mostly involved us reworking our code from previous submissions to follow MVC principles, we moved into a discussion on running code tests for all our programs. While there are many approaches to testing your code, we focused today on the concept of ‘Test Driven Development’ (TDD). One of the foundational principles of TDD is that you write your tests BEFORE you write your software. We went through a few programs together as a class to practice creating code tests using the ‘Jest’ npm, which contains a comprehensive library to assist you in running your own customized program tests.
Tomorrow, we’re gonna be testing it up even more (!) and also working with MongoDB for our first taste of working in a real database program. Can’t wait!
Song of the Day: “North Side Gal” by JD McPherson









