Suppose You Want to Help Out Your Senior by Taking Responsibility and Modifying Some Code Using Asynchronous Programming
It's 8 o' clock in the morning. The door you've opened time and time again stood before you. It was just a normal office door, but there was much more to it. A feeling you couldn't describe. You then asked yourself, "is it because I am starting to feel attached to it?" You acknowledged the idea as you opened the door for several seconds. A part of you still denied that possibility as the truth.
As you entered the room, seeing the folks run wild in the middle of the room, you began to smile. "I might attached to this office after all." Bitter the fact may be, you accepted it. For some reason you were started to feel something about these people and this world. After all, it has almost been a year since you arrived and worked for this company.
You hated some of your workmates at first. Your first impression for most of them were bad. Besides Emory, you were unable to mention a single good thing about them. However, as time goes on, your impression changed. They were not as bad what you imagined.
You sat at your office desk and noticed something was wrong. It might be the regular morning chaos, but something was different. It felt very different from the mess you normally experience everyday. As you gazed through the mayhem, you noticed what it was.
"Where is Emory?" You wondered.
"If you're looking for Emory, they've fallen sick." An answer to your inquiry came a second later. You saw Alex standing there, looking like he's been to hell and back, and back to hell again, and back. Worried, you asked him.
"Are you alright?"
"HECK NO" He didn't even hesitate to answer. His voice erupted with pain. He was also out of breath. You looked at the clock. It's not even time for your daily stand up, yet Alex is already dead.
"The whole building lost its structure when it lost its foundation. That's what Emory means to us I guess.They are this team's leader after all." Alex's voice was getting softer and softer as he spoke. The whole morning has always been a big mess even when Emory's arround. However, losing its captain, the ship had no direction at all.
Alex continued to speak. "No one in our team can code as fast and as accurate as Emory. I might be fast but not accurate. Even worse, I don't possess the same leadership skills as Emory. " You knew Emory's ability very well. Hearing such things coming from Alex was also a shock. He had always been a prideful man. You couldn't imagine just a few minutes without Emory could lead to this mayhem.
It made sense after all. As the sprint deadline got closer, and with a lot of hard stuff being handled by Emory, their absence meant a lot. There was a need to change priorities and resource allocation.
"Can I help with something? I don't have that many tasks left, so I think I can handle more."
Alex seemed pleased with your initiative. "You will? That's great. " Alex showed a task left by Emory. He began to explain the job you need to do. "I belive you quite familiar with this application. If I recall, you are the one that implemented the PDF exporter in this application. "
"Yes. I did that one." you replied.
"That saves time, then."
Anyway, I will remind you some basic features of the application. This is a guild management system requested by a town called Luneburg. It's a little town in the east of Literra empire. This application lists some kind of information about guilds in Luneburg. It has a lot of data stored in json
format. The good news is it is immutable. The bad news is it's so slow, although it's just a read-only app. "
"So you believe there is something wrong with the IO process? " You guessed.
It seems like that it was the most obvious thing, so Alex just answered it quickly. "There should be more than one source of data, so I think some parts of IO process could be converted to an asynchronous call. To help you enable the asynchronous process in Spring Boot, you can modify the code to match this snippet. But, I leave the rest to you. Thank you so much, and don't forget to write the tests!" Alex then ran away after briefly explaining everything. You were a bit annoyed by his attitude after worrying about him. At least he showed you how to enable the asynchronous process.
After you saw the application's code, you knew you needed to work on the service layer of the application. From the information you got from Alex, you knew it should be something related to IO process. There are should be a part of the IO process that can be ran as parallel process. So as not to waste anymore time, you then proceeded to work on the program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
Guild Information System
This application serves as a list of all guild members on the realm. The list itself is quite long, so the system has automatically paginated into neat looking pages which you can control and search through using the tools given. It also provides a way to look into the details of each members and turn the list itself into a portable PDF file.
There are 3 endpoints to this app:
- List of all guild members
- Details of each members
- Generate PDF of the list
The main list can be accessed at "/guilds/members". With this, you can do a multitude of things including filtering certain roles, change your sort bys, go to different pages, and control entries. Filtering roles refreshes the page, but the others do not. Maybe you can use this knowledge in the future, so make sure to look at how it's created.
Details of each member can be accesed at "/guilds/member/detail?id=x" where x is the id of the member. Of course you can visit this page by simply clicking at the name of a member. To export pdf, you may access "/guilds/members/exportpdf" or click the export pdf button on the main screen. This will create a pdf which you may then save.
As is the norm, the problem with this app lies within these 3 endpoints. Make sure to read the code thoroughly and figure out what each does!
The Side of Me I don't Want You to See
"You seem close with Emory. Could you visit their apartment?"
"Huh?" You are puzzled by the request. You didn't even try to look at your conversation partner.
That's the only answer you got. This whole day had been nothing but a living hell. The fact you need to get on Emory's level and helped Alex to replace Emory had taken everything from you. Accompanied by the slow and relaxing jazz music, you gazed at him. You saw Alex and Maya sitting beside you. Not far from them, Riley was also enjoying their drink. After a while you gave a proper response.
"Is this a joke?" you replied. But there was no response other than a serious look from Alex. You knew he was dead serious. Riley, who supposed to not bother your conversation with Alex, also looked interested. With that, you were sent to Emory's place.
You weren't bothered with the smug look on Alex and Maya's eyes when you accepted the request. It was just a visit to a sick coworker. You didn't think much of it until you saw the look of Emory when they opened the apartment door. A moment of awkwardness. The both of you were startled. You by their look and Emory by your sudden arrival. The silence lasted for more than a minutes before Emory let you in.
Your eyes couldn't help admire the unit. This is the first time you had come to their place. Everything was so clean and neat. Judging from how Emory arranged their work desk, this is really no suprise.
"Please don't look around too much..."
"I am sorry."
Emory's cracking voice suddenly made you stop. They were still as cold as always, but something was different. Somehow their sick and weak voice possessed much more emotion than usual.
You then humored Emory with small talk, telling them how your team was worried about their condition. You tried several approaches, each with different questions. Somehow it always ended with Emory apologizing. It was not something you expected to happen. You never imagined Emory could be docile like this. Was this really Emory? No cold stares or dismissing gestures. They always answered properly and even sometimes laughed. This Emory was so sweet, it made you wonder whether they are the same person.
Two hours filled with awkward yet strangely cozy moments had passed, and it was about time for you to leave. You were glad to see Emory's condition was getting better. It seemed like Emory was also happy to see you. But as you announced your departure and tried to turn toward the front door, Emory stops you by grabbing your jacket.
"Don't leave me alone.." Emory raised their voice a bit. Her voice cracked, but was driven by strong emotion. You were left with no choice but to stay, and only left after making sure Emory had fallen asleep. It wasn't so bad after all. This was something you couldn't see everyday. Might as well enjoy it while it lasted. A side of Emory you were sure they never wanted you to see. This might be a story you would never forget.
Tasks
- Identify the part of the service you need to refactor to asynchronous. All service method always return a
CompleteableFuture
. Your task is to find which part of the method that might be better to run as parallel process. You can use the help of other tools like profiler (see practical-4) to find the said segment(s) - Explain your decision and reasoning in
README.md
- Write tests for service and repository packages. Achieved at least 90% line coverage for both service and repository.
Created: 2022-03-15 21:16:49