<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bailey Diveley on Medium]]></title>
        <description><![CDATA[Stories by Bailey Diveley on Medium]]></description>
        <link>https://medium.com/@baileydiveley?source=rss-9afc99f1d18------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4AjlYUMkbTt60Fwd</url>
            <title>Stories by Bailey Diveley on Medium</title>
            <link>https://medium.com/@baileydiveley?source=rss-9afc99f1d18------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:19:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@baileydiveley/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Design in Software Design: MVC]]></title>
            <link>https://medium.com/@baileydiveley/the-design-in-software-design-mvc-d57b94c249ad?source=rss-9afc99f1d18------2</link>
            <guid isPermaLink="false">https://medium.com/p/d57b94c249ad</guid>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Bailey Diveley]]></dc:creator>
            <pubDate>Mon, 05 Nov 2018 18:42:47 GMT</pubDate>
            <atom:updated>2018-11-05T18:42:47.681Z</atom:updated>
            <content:encoded><![CDATA[<p>The inner workings of the internet we know and love were built based on a series of design decisions called protocols. I’m sure you’ve heard the names of some of these layered protocols, even if you’re unsure of their meanings: HTTP (Hypertext Transfer Protocol), IP (Internet Protocol) addresses, or TCP (Transmission Control Protocol) to name a few. Protocols give people accessing the internet a shared way to communicate. These design decisions made very early in the history of the internet have proven to be effective and amazingly scalable.</p><p>Similarly, subsequent software programs created to work upon this designed framework have followed suit in creating their own agreed-upon conventions and design patterns. One such design that we’ll focus on in this article is an acronym known as MVC or Models-Views-Controllers. MVC strategically separates functionality of a web application into three components: business logic (controller), user interface (view), and database logic (model). It manages the flow of functionality and execution through the web application with the goal of improving the overall development process.</p><p>The use of the MVC pattern in web applications rose in popularity in 1996, with a program written in Objective-C. After the rise of new frameworks that emphasized rapid deployment, like Django and Rails, MVC really took off.</p><p>We’ll talk more about the benefits of MVC later, but first, let’s talk about each component individually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*2jiyGcpxw6aK-3OAbfJc1w.png" /><figcaption>High Level Overview of MVC Design</figcaption></figure><p>The controller, or the component that handles business logic, is in charge of receiving HTTP requests and responding to them. When you’re visiting your favorite website, you’re likely having a conversation with that website’s controller. The controller can be considered the brains of the application operation. It is the component that speaks directly to the model and the view.</p><p>Once the controller receives an HTTP request, it may ask the model to get, modify or delete information from the database; it will use this information to tell the view what data to display; and it will then use the information received back from the view to build an HTTP response. The controller also handles user authorization, ensuring you only have access to specific website information based on your access rights.</p><p>By peeking into an actual controller file, you’ll see these controllers are made up of CRUD (create, read, update, delete) methods that make database queries and/or request action to occur with the database via the model. That information is then sent to the View via an instance variable or instance variable(s):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iuOzNuVIG-ApQVejmXg_2A.png" /><figcaption>Example of a controller file in Rails</figcaption></figure><p>Now let’s pry into the model. Within the model, you’ll typically find queries accessing specific statistics from your database. You’ll also see attribute and relationship validations that keep your database clean, normalized, and properly interconnected. You must be very cognizant of your method return values in your model. Your return values become the way your model ‘responds’ to a controller. These return values will be saved as instance variables in your controller and ultimately passed into your view. A return value of a particular object versus an array of objects will need to be treated differently within the View in order for the display to look as intended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*AUfX5_CEgmkX9TjV_x1fZg.png" /><figcaption>Example of a model file in Rails using Active Record SQL</figcaption></figure><p>Last but certainly not least is our view. The view’s functionality is relatively self-defined. The view renders HTML code to display specific pages on the website. The data displayed in the view is presented as instance variables delivered from the controller. The view has some logic written in as well to determine under what circumstances data should display, but for the most part, the view is simply for displaying information in a particular format or design. You’ll typically see a fair amount of enumerating in the view for those instance variables holding collections.</p><p>For a view displaying the option to create new resources or edit existing ones, you’ll see a form. In most views, you’ll see links and buttons as well giving the user access to other functionality which will come to the controller as separate HTTP requests. Here you’ll see a a sample view:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*NGlxqUS4Bu4eCp9A9j58uQ.png" /><figcaption>Example of a view file in Rails</figcaption></figure><p>Now that we have a basic understanding of MVC, we need to understand the benefits of creating this separation of duties.</p><p>The most obvious benefit is that separating each component allows for more efficient workflow for a web application that is managed by a large team. Each team can work on the functionality of a new feature by MVC component, which makes feature development faster. It also allows a team to work to their strengths; a developer strong in data analytics can focus on query development in the model while a strong front-end focused developer can focus on the views.</p><p>Another benefit is how well web applications built with MVC design principles can adapt to code changes. Views typically change the most often because user design trends change rapidly. With MVC, the view can be modified to reflect these changes without the need to make adjustments to the model or controller files. Similarly, if the database needs a major overhaul, the model can quickly take on that work without the need to modify the controller or view files. Modifications are localized.</p><p>If you’re a fan of Test-Driven Development like me, then you’ll really love MVC because of how easy it is to create and implement unit tests. The main purpose of unit testing is taking a small piece of functionality and creating a test to determine if that function is behaving as expected. Because the essential nature of MVC is separation of duties, the design of the application does part of the work for you. For example, if you want to determine whether a database query is providing you with the expected output, you can write a test for a specific method that you know exists within a particular model file. If you want to test whether an admin can visit a specific page, then you know the controller should be handling that functionality and should be modified if the unit tests fails to deliver expected results.</p><p>To summarize, the MVC design pattern was developed to help us, as developers, stay organized, collaborative, and efficient enough to pump out some great code. I hope this article gave you a better understanding of the inner workings of this concept.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d57b94c249ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>