1
00:00:10,380 --> 00:00:17,070
Welcome to brand new section and that is MVC Design Party.

2
00:00:17,190 --> 00:00:20,370
What is it and why should we care about it?

3
00:00:20,550 --> 00:00:22,650
Well, let's explain more.

4
00:00:22,710 --> 00:00:26,970
When we see MVC, it is a design pattern.

5
00:00:26,970 --> 00:00:28,050
What does it mean?

6
00:00:28,050 --> 00:00:34,070
Well, as a back end developer or as a programmer, you need a design pattern.

7
00:00:34,080 --> 00:00:42,120
Simply means that how you write your code, because we have a standard way of writing code.

8
00:00:42,120 --> 00:00:49,140
So the most popular design pattern in Node.js is what we call the MVC.

9
00:00:49,290 --> 00:00:56,040
We have many types of design pattern, but in Node.js, MVC is the most popular one.

10
00:00:56,040 --> 00:01:03,570
So we are going to stick to MVC design pattern, meaning how we can write a better code.

11
00:01:03,570 --> 00:01:05,190
So let's get started.

12
00:01:05,400 --> 00:01:13,620
When we say MVC, it simply means model view controller, and this is a design pattern.

13
00:01:13,620 --> 00:01:23,850
Specify that an application consists of one data model two presentational information and three control

14
00:01:23,850 --> 00:01:31,530
information, meaning that every application that is back in application comprises of three components.

15
00:01:31,530 --> 00:01:40,020
One is the data flow inside your application and is being represented as the model and the view represent

16
00:01:40,020 --> 00:01:43,230
the presentational part of your application.

17
00:01:43,230 --> 00:01:47,400
And then the C represent what the control information.

18
00:01:47,520 --> 00:01:56,970
So when designing an application, one can think of the MVC paradigm as dividing the element of your

19
00:01:56,970 --> 00:02:00,150
application into three groups.

20
00:02:00,150 --> 00:02:04,020
And the first one is what we call the model.

21
00:02:04,050 --> 00:02:11,520
So when you say model, what does the mean where any code representing the knowledge or the data in

22
00:02:11,520 --> 00:02:12,840
your application?

23
00:02:12,840 --> 00:02:21,750
For example, database entries when seven files or in memory object and all this is what we call the

24
00:02:21,750 --> 00:02:22,530
model.

25
00:02:23,100 --> 00:02:26,790
The next component is what we call the view.

26
00:02:27,150 --> 00:02:35,250
So view represent how models are displayed to the user, meaning how content are being displayed to

27
00:02:35,250 --> 00:02:36,030
the user.

28
00:02:36,060 --> 00:02:43,740
A sample of them is eight pages with some embedded JavaScript or XML documents or console.log output.

29
00:02:43,740 --> 00:02:48,090
All these are what we call the view part of your application.

30
00:02:48,240 --> 00:02:52,530
And lastly, we have what is called the controller.

31
00:02:52,980 --> 00:03:02,910
Well, the controller take input from the user and then decide what to do with it based on the predetermined

32
00:03:02,910 --> 00:03:04,500
or predefined rules.

33
00:03:04,650 --> 00:03:09,960
An example of this is when submitting a form in a web application.

34
00:03:09,960 --> 00:03:14,310
So controllers is where our business logic lies.

35
00:03:14,550 --> 00:03:21,180
So for any application that you are going to build using Node.js, you need to have these components

36
00:03:21,240 --> 00:03:28,920
and we are going to create an example application to explore or to show you how all these pieces come

37
00:03:28,920 --> 00:03:32,370
together to form a complete design paradigm.

38
00:03:32,460 --> 00:03:36,930
Well, so controller is where our business logic lies.

39
00:03:36,930 --> 00:03:40,320
So again, always the controller.

40
00:03:40,320 --> 00:03:45,570
Talk to the model, but a controller cannot talk to the view directly.

41
00:03:45,570 --> 00:03:47,100
So it goes like this.

42
00:03:47,100 --> 00:03:54,630
Well, we take an action from the controller to interact with our object, meaning our data base here.

43
00:03:54,660 --> 00:04:00,810
And in case there are some changes, then it will display to the UI for the user to see.

44
00:04:00,990 --> 00:04:05,310
So in a nutshell, this how MVC design pattern works.

45
00:04:05,310 --> 00:04:12,000
So the next video, let's get started by building and complete API where we are going to differentiate

46
00:04:12,000 --> 00:04:15,330
our application into these three components.

47
00:04:15,360 --> 00:04:17,790
Let's get into that in the next video.

