A quick look into software architecture
Let’s talk about software architecture!
So, how are you going to go about making breakfast? If you’re eating eggs, bacon, and pancakes with a glass of milk (because who eats pancakes with orange juice? Borderline psychopaths, that’s who). The process is relatively simple. You grab the ingredients you’re going to need and get cracking, pun intended.
But seriously, you don’t really need to worry about the organization of your ingredients, where exactly the food is being cooked, and for how long. You don’t really think about what’s the best order to cook the food in. It’s eggs, bacon, and pancakes — just make it man! I’m hungry.
Let’s change the context of the said breakfast. Let’s say your extended family is staying over for the weekend and you have to cook breakfast for 10–15 people. Ok.. now we have to think about the process a bit more. We need to consider what we are going to cook and how this will impact the space that we will need or the tools that are going to let us make the food. We might also ask one of our cousins to help us cook.
To change the context of this once more. Let’s say you’re preparing breakfast for an important charity event that will see hundreds of people walking through the doors wanting some eggs, bacon, and pancakes with a side of orange juice (because this is a crowd of borderline psychopaths). You have to give serious consideration to the processes, ingredients, order of cooking, and team members with specialized functions.
In much the same way before you start an application you should spend some time giving thought to what architecture you will need for your application. What is your MVA (minimum viable architecture)? You should use different patterns/structures depending on what the needs of your application will be. Let’s take a look at some options that you can choose from!
This structure consists of three parts that all work together in order to render a functional application.
Model — is the section that represents the data of your application. It holds the information that you want your end-user to see and interact with.
View — this is how the user interacts with your application. It’s the interpretation of the data that allows the user to digest the purpose and intent for the collection of data from the Model
Controller — the controller is connected to both the view and model. Through the user interface the user can make requests that can either get information from or manipulate the data from a given application
One of the main criticisms of MVC is that the code can become convoluted and not have a clear way to implement a separation of concerns(more on this in a bit)!
The purpose behind this structural pattern is to define a cleaner relationship between the data and the view. It makes an effort to implement a separation of concerns. In other words, it stresses the importance of having specific chunks of code doing specialized tasks. Each class should focus on a small number of separate responsibilities.
In the case of MVVM, each view model is a class specifically designed for the state of the view and has methods that implement the logic behind the view for that specific state.
MVVM is a great structure to use if you are testing individual portions of your application because you can isolate specific parts of the app’s functionality.
We can also find a stressor of separation of concerns with MPV (and with the rest of the structure we are looking at). Here we have the user interacting with the view which then interacts with the presenter. All of the data manipulation and view user interface updates happen through predefined methods between the presenter and the view.
HMVC is essentially a cluster of MVC structures normally composed of groups called triads. This breaks up your application by creating code for specific sections of your application or website rather than functionality. If we are looking at a website as an example we would find that there might be a folder dedicated to upcoming events with its own files for its model, view, and controller. This makes it easy for many developers to work on one application but it can be hard to implement outside of websites/web applications.