CodeGym /Courses /Java Multithreading /Big task: MVC design pattern

Big task: MVC design pattern

Java Multithreading
Level 4 , Lesson 14
Available

"Hello, soldier!"

"Congratulations on upgrading your skills. We need guys who are prepared to do anything."

"I'm sure you still have many unfinished tasks. It's time to finish some of them!"

26
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 1)
Hi! This task will cover the Model-View-Controller (MVC) pattern. Together we are going to build an MVC architecture. Dive in deep to understand why you need to implement it the way that I show you. You'll probably be asked about this pattern in an interview or will be given a task that will require you to implement it.
7
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 2)
1. Create a controller package, and create a Controller class inside it. This class will receive requests from the client and notify the Model. The Model, in turn, will update the DataModel. 2. Add a Model model field, along with a setter, to the controller.
26
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 3)
To understand whether you're heading in the right direction, you need to see the data. Therefore, 1. In the view package, create a UsersView class that implements View. It will display the list of users. 2. Create a controller field, and a corresponding setter, in UsersView.
13
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 4)
It's time to replace our fake Model with a real one that receives data from the DataSource. I've added a service for working with users to the model.service package. You'll also find a Util utility class in the root of this task. 1. Create a MainModel by analogy with FakeModel.
13
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 5)
The service has a method that returns all deleted users. Let's display them. 1. Assign each of these methods to the correct MVC classes.
26
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 6)
The functionality for displaying deleted users exists, but we don't have any deleted users. Let's fix that. Let's make a new view that will be responsible for editing a specific user. UsersView displays a list of users. EditUserView will display data about editing a specific user.
26
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 7)
1. Assign each of these methods to the correct MVC classes.
26
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 8)
1. Following the MVC pattern, do the following by analogy with how the previous methods were implemented: write the logic for deleting a user. After a deletion operation, the list of users must be displayed. Assign the following methods to MVC classes.
7
Task
Java Multithreading, level 4, lesson 14
Locked
MVC (part 9)
This is the last task on MVC. 1. Following the MVC pattern, do the following by analogy with how the previous methods were implemented: write the logic for updating a user. After the update operation, the list of users must be displayed. Assign the following methods to MVC classes.
Comments (32)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Evgeniia Shabaeva Level 40, Budapest, Hungary
10 February 2025
Wow, wow, wow, what a whole new world. Before starting the first task, I had to have a long theoretical conversation with AI about databases in general, and then about DAO, DAO layer and UserDAO. When I finally got some idea of what that all is about, the task appeared to be medium or even easy. At least at this stage we are nor required to do a lot.
Evgeniia Shabaeva Level 40, Budapest, Hungary
12 February 2025
2 days later, I'm done with the whole MVC saga. Alongside the things that I completed with understanding, there are also those that I just wrote by analogy, without a clear idea why I was doing them. That is why I'm still trying to recap what exactly I've learned from the whole set of tasks. I hope I'll be able to process it all and apply my new skills in the future:).
Paweł Mackiewicz Level 32, Poland, Poland
26 January 2025
To be honest, It was easy for me. I did it in few hours and understood most actions. Just before start, I readed this whole articles cycle: CodeGym: Introduction to Enterprise and did task as they instructed. Also I got familiar with Observer and Facade design patterns (as mentioned in articles that I linked before). Really enjoyed this lesson. Thank You CodeGym!
Anonymous #11450946 Level 47, Nanjing, Hong Kong
7 April 2024
This MVC lesson is very impressive, but I suppose there should have been a facade according to the given literature, or is it reduced for simlicity?
FelixUjo Level 35, Gijón, Spain
3 March 2024
Part 8 solved after 29 attempts
Willi Ehrmann Level 37, Germany
4 July 2023
I find this tasks to be very complex and hard. But in contrast to the other people in the comments here I actually like them. Because for the first time in this course it felt like you're working on some kind of corporate project implementing stuff. That's what I've always looked for and that's what we need to practice more. Those single class tasks help to understand the concepts and simple stuff but these kind of tasks let you think more in software engineering patterns.
Brandon Waites Level 26, Cincinnati, United States
8 June 2023
06/08/2023 Finishing up my first pass of this concept. Will most likely give it a reset so I can more completely understand the nuances within this structure. Took me just under a week to go through. This was tough, but I've learned so much about the MVC design pattern through these tasks. As Luis mentioned, there really should be some introductory tasks since this seems to be a valuable programming concept, and it may help with the growing pains of coming to understand these tasks. At any rate, this is an amazing set of tasks that I feel deserve to be repeated (despite my disagreements with the validator).
matemate123 Level 50, Kraków, Poland
18 April 2023
https://www.youtube.com/watch?v=DUg2SWWK18I https://www.youtube.com/watch?v=1IsL6g2ixak https://www.youtube.com/watch?v=pCvZtjoRq1I https://www.youtube.com/watch?v=mtZdybMV4Bw
LuisRC Level 39, Gijón, Spain
9 July 2022
In my opinion instead of starting with something so "complicated" we could have previously done some less complicated related tasks to get familiar with the idea on how MVC works and step by step getting it more complex. Now, after solving some of them with some help, and after having read some articles on INTERNET a have an idea on what MVC does. Now I would say that I have a rough idea about MVC.
Dan Level 26, Clarksville, United States Expert
4 February 2022
Just finished this task. Below, I've listed everything that helped me. https://www.youtube.com/watch?v=dTVVa2gfht8 (Taken from a comment by Andrei) - This seems very obvious at first glance, but it helps solidify what the Model, View, and Controller components DO. Model: Knows nothing about View or the Controller. It has functions that it can perform, and it holds the the DataSource View: Entire purpose is to ask Controller to do things for it. It knows about the Controller. Controller: It sees the Model, and the View. It takes requests from the view, and has the Model perform the necessary operations. When you start, you may notice that each feature you intend to add, you have to add it 3 times. This is because you are creating a UserView function which asks to do something. It calls the controller function, which will have the Model perform the operations. Finally you have the Model which performs the function. Listed below like this: View: fireUserDataChangedEvent(String name, long id, int level) - Ask the controller Controller: onChangeUserData(String name, long id, int level) - Have the Model perform the task, and then refresh what the View sees Model: Performs the task This is a bit rambling, But try to think of the Controller as the go-between for the Model and the View. You might think "Well how about I skip all this and do each thing one time". Based on my (very weak) understanding of MVC, its values can be derived directly from the principles of Object-Oriented Programming. You can hide away complexity (Abstraction) by making the view's functions very simple. You can very easily ask for new things (Polymorphism) by having the model perform very general tasks, which the Controller puts together in a more advanced way, etc., If you have any trouble with these tasks (I had tons of trouble), feel free to message me or post your code for help. It doesn't hurt to ask for help, and none of us can do everything alone. GOOD LUCK!!
Jurij Thmsn Level 29, Flensburg, Germany
28 October 2021
I solved all tasks without getting any help - and still, I don't understand the program properly. It would be nice to implement a simpler version of an MVC with lesser classes (like the ones you find in other MVC tutorials) before writing it like this with all the fake classes etc. Also a few proper comments in the classes would help to understand what the purpose of all the classes are. tip - always start with the method call in the main method and go on step by step. And don't trust the validator regarding the order of calls in the main method. Anyways- these tasks got my brain working for sure 👍
LaikaLaikaka Level 32, United States of America, United States
7 May 2025
Same. I got completely lost at the later tasks. I just follow the instruction and have no idea what i was doing. There are so many classes with similar or probably same names and I just don't remember what I have wrote at the later stage.