Written by: Nick Kelley
Have you ever wondered how programs on your computer take the information stored on your hard drive and turn it into something that you can see on your monitor and interact with using your keyboard and mouse?
There are many different ways that computer programmers can complete this task. One of which is an architectural pattern known as MVC. MVC stands for Model, View and Controller. The Model can be thought of as the data behind a program, the View is the way in which the data is conveyed to the user, and the Controller structures and manipulates the data based on the input and required output of the view. Each part can be developed independently of one another but all are required to work together in order to perform the required task, think of them as separate equal parts of a whole.
An every day example of this procedure in action is logging onto a program or website. The screen that appears when you launch a program and asks for your username and password is a View. It shows you information, like the program name or the fields that it wants you to populate, and waits for you to type in and submit data. Once you populate the fields and click submit the Controller takes over. It takes the input that you submitted and uses it to run whatever code it needs to in order to perform its assigned task. In the logon example it takes the username and password that you provided and compares it to stored values in order to ensure that the information is valid. How does the Controller know it has the right information? It uses stored information from the Model in order to verify that the information that it has is correct. The Model stores all information in a way that is easily accessible, a database in this example, in order for the various different Controllers to perform the tasks that they are assigned. In our example the database stores pairs of usernames and passwords in order for the Controller to compare them and let the program know that it can allow the user access to the program or website. The Controller can use whether or not the information in the Model was verified in order to decide which view should be sent to the user. If the verification failed a screen can be displayed to the user asking them to resubmit their password and if the verification was successful the next screen of information can be shown to the user.
There are several inherent benefits to the MVC approach to programming. The different areas can each be programmed separately and linked together using code after the fact. This allows for a team of developers to work on a project and focus on areas that they are most comfortable with. This means that individuals that are strong in programming visual elements, webpage design for example, can develop the Views and individuals that are strong in database implementation and administration, like a SQL server architect, can develop the Models. Each member of the team can work at their own pace and make changes on their own schedule without waiting for others to catch up.
The MVC architectural pattern also allows great flexibility in the ways that a program or website can be programmed. It does not lock you into a certain programming language. Are your developers stronger with HTML and C++? Great! Are they more adept with XML and SQL? Sure thing! This fluidity is a major benefit of the MVC framework. And, because MVC has been around since the 1970’s, many top of the line development packages allow for its easy implementation from the beginning of a project, which increases the likelihood of a successful outcome.
While MVC may seem like a silver bullet approach to programming there are several areas that need to be considered before deciding to use MVC. In order for the three areas to come together to form a strong final product there needs to be a strong link between them. If any of the three sections is lacking all of them will suffer. Thinking back to our password example, imagine what would happen if the View only asked the user for a password? The Controller could take the password and look for the records that match it in the Model, but how would it know if it was correct without the user name? If the Controller asked for the user name and password but did not know how to get the information from the Model to verify that they were correct, what good would it do? If the Model stored only user names, users could not be authenticated at all.
This relationship requires that in depth planning sessions take place at the beginning of a project to ensure that structures are defined and relationships are maintained throughout the project. If there are several developers working on a project, they must maintain strong levels of communication in order to convey changes and updates that may impact other areas of the project.
MVC is one way to approach a problem and by no means is it the only way to accomplish such a task. There are many other ways to validate data besides using the MVC approach, and there are many other tasks that can be efficiently handled by the MVC pattern.
It is very important to thoroughly gather detailed information evaluate client needs in order to glean all necessary information and before we decide on the best way to develop your solution. We value the relationship that we develop with our clients and find it best to be within arms reach during the course of a project. We have found that constant communication between the end users of a project and its developers ensures that the best possible solution is reached in the shortest amount of time. Let’s talk about how we can work together to find ways to enhance your business today!
MarinerTek, an NWBOC and WBENC certified woman owned small business headquartered in Cleveland, Ohio, specializes in custom software development, mobile application programming, .NET, SQL, SharePoint and SalesForce integration.