Your Task
Description
What you want to accomplish with this task is to solve a design problem. In the reading example, you saw that you can run a bunch of computations in a process, but if one request causes a crash, it takes everything down. This means that everyone else using that process for computations has a request fail. This is not good. As part of this redesign, you will want to use the Erlang programming principles learned earlier in the class to write easily read, understood, and, therefore, easily maintained code.
The Process
Complete the following steps
- Download the task project, friends.zip file.
- Using the ctemplate.erl file as a template, complete the run/1 function in the friend_tracker.erl file in such a way that it passes all of its unit tests. Pass each test, one at a time. Do NOT attempt to write code to pass them all before running the tests. Instead, use the provided unit tests in the friend_tracker.erl file to help you fill-in the code for each of the functions that are spawned.
Stretch Challenge (Optional)
- Modify the start/2 to register the process. This way you won't ever need to know the PID of your process. You can see an example of registering processes in the setup portion of the unit tests.
Review
After completing the previous steps:
- Review one of the many possible solutions for this task. Do not expect to have found this solution out of the many available.
- Compare and contrast your code with the possible solutions’ code.
- Make note of any improvements you could make for future tasks.
- Make note of what your approach does well.