Skip to main content

MVC Architecture - In depth

Hello friends,

Welcome back 🙂.

In this article, I’m writing about which the new developers consider a very big concept. The MVC

What is MVC?

MVC is actually a design pattern or a development architecture which is specifically used in developing dynamic web applications. It also can be used for static web applications. There are also other design patterns which are frame-worked for accomplishing specific development architecture. The MVC right now is used for implementing dynamic web applications, static web sites, desktop applications etc.

MVC Purpose

The major purpose of MVC design pattern is to segregate the code snippets based on their use.
  • M stands for MODEL in which specifically db and data related operations performed.
  • V stands for VIEW in which view related operations performed.
  • And finally C for CONTROLLER which co-ordinates between Models and Views.
So due to the separation of codes by above sections, team work becomes easy and code maintenance becomes easy.
The team works on view (HTML, CSS, Javascript and its frameworks etc.) doesn’t need to be familiar with the technologies and code used in model and controller, only work related to design and presentation is important.
The team works on controller and model doesn’t need to be familiar with client side/view related technologies, only work related to business logic and control logic is important.
So that’s why code maintenance and team work becomes easy.

Architecture in detail

The key part of MVC framework is that it has a single point where all requests comes. In PHP, its `index.php` (or any other file which is configured in `.htaccess`), in Sprinv MVC, its DispatcherServlet (The servlet from spring framework).
Based on the URLs, configurations and routing mechanism, the main entry point executes only those code stuff which is required.

Due to its single entry point, the developer can add code for securities, sanitization, validation and many more common operations on each request.

After a single entry point, there are 3 main parts included in that MVC, the configuration, routing and library which are as follows:

Configuration :
The configuration part (might be stored in db or in a file) contains the essential and optional settings with its default values (which can be modified by providing GUI or its source or by any custom tool which works on terminal). The configuration may include db configurations, view path, debugging level configuration, logging configuration etc.

Routing:
Routing's job is to detect the URL, and based on the URL path (like https://host/controller/action?parameter=value), load the appropriate controller's class and call its appropriate method for that action.

Library:
The library is nothing but collection of classes and methods for different common generic operations. e.g. encryption and decryption of data, FTP/SFTP management, file operations etc.

The above 3 parts, the controllers, models and views is bundled and MVC is formed.

Thanks.

Comments

Popular posts from this blog

Initialization blocks in Java

Hello friends, Welcome back. Today in this article, I'm going to explain you about the static block and initializer block. As the Java language is pure OOP language, whatever the code we write is only in classes. So whenever we use class to represent a real life entity, we use members in the class as the attributes or properties of that entity. To initialize those properties or members, we can use one of the way i.e. Constructor Setter method Inlinie Blocks I'm assuming that you are familiar with all methods. Here about first three methods, I'm just giving a short description. The first three methods are : we initialize member in constructor by using a parameterized constructor. Setter methods is a java standard which denotes that class's member should be private and it should have setter method so that the member can be initialized. Third method is inline i.e. when we declare a member or variable, at the same time, we set its value. In this article, we...

The final keyword in java

Hello friends, Welcome back 🙂. In this article, I'm going to give a short introduction to final keyword which would be helpful to know more about it. The final keyword in java has multiple uses. The main purpose of the final keyword is to add some restrictions on java elements (class, member and method). The restrictions have been described as below. Use of final keyword: 1. The final class : We can say the class is final when it declared as final. The restriction on final class is that the final class cannot be extended by any class. Rest of the behavior of the class remains same as any normal class. 2. The final method : The method declared using final keyword is to be said as final method. The restriction is that the final method cannot be overridden by derived class. This restriction applies to static method also. 3. The final member : The final member is the java class's member which is declared using final keyword. The restriction is that it can be initial...

Recover messed up/lost UTF-8 characters in MySQL db

Hi friends, This was my first story on medium, now copying as it is on blogger. In this note, I’m going to explain you what are the messed up/lost/bad utf-8 characters and how to recover them to original in MySQL db. What is messed up/lost/bad utf-8 characters? The messed up or lost or bad characters are those characters which are normal if we convert it to UTF-8, but due to mistakes while import/export, that characters not display properly. Consider following example: 很好的产品。就是没货了 The above sentence is actually a Chinese sentence, but while import/export from db, it’s get messed up. How to recover them? To recover the messed up characters, we should convert them first into binary form, then convert that binary string to UTF-8 string, that’s it! To do this, use following SQL: In above SQL, we firstly converted data of varcharColto binary form using MySQL’s CAST function. Then converted that binary string to UTF-8 using CONVERT function. Aft...