update readme
[dotfiles/.git] / .config / Typora / draftsRecover / 2020-3-3 Happy Birthday! Bug Fix Proposal Report 133955.md
1 # "Happy Birthday!" Bug Fix Proposal Report
2
3 ## Description:
4
5 After the incorporation of the new feature for multiple birthday registrations a bug appeared. You can reproduce this bug by, after registering one person, choosing **YES** in the prompt `"Would you like to add another person?"`, after said action the app would overwrite the last person registered locally with the new one and at the end of the operation would only send the information of the last person registered in the app.
6
7 This bug is probably occurring because the same variables are being reused instead of putting all the persons in one array, resulting this in the deletion of all the old data every time a person register their relatives.
8
9 ## Proposed fixes:
10
11 ### Proposed fix #1
12
13 > Multiple requests to the API.
14
15 A solution that can be simple, that would affect minimally the code base of the app and have many advantages is to send a request to register the person just before asking for the `"Would you like to add another person?"` prompt, that way we can not only fix the bug but also it acts as a mechanism to prevent the lost of all the data in case of an interruption in the app.
16
17 The major downside to this is the fact that in this way we are going to increment the amount of request that we are going to get from the app from just one to the amount of persons someone registers.
18
19 The code at this time might look something like this:
20
21 ```python
22 bool continue = True
23 while(continue):
24         print("What is your name?")
25         name = scan();
26         print("What month where you born?")
27         birthMonth = scan();
28         print("What day in {{birthMonth}} where you born?")
29         birthDay = scan();
30         print("{{name}}, what is your email?")
31         email = scan();
32         print("Everything is ready")
33         print("Would you like to add another person?")
34         continue = scan();//True repeats the loop
35 registerOnServer(name, birthDay, birthMonth, email) //request only with last data
36 ```
37
38
39
40 The main idea is to get to something like this:
41
42 ```python
43 bool continue = True
44 while(continue):
45         print("What is your name?")
46         name = scan();
47         print("What month where you born?")
48         birthMonth = scan();
49         print("What day in {{birthMonth}} where you born?")
50         birthDay = scan();
51         print("{{name}}, what is your email?")
52         email = scan();
53         print("Everything is ready")
54         registerOnServer(name, birthDay, birthMonth, email) //request before overwrite
55         print("Would you like to add another person?")
56         continue = scan();//True repeats the loop
57         
58 ```
59
60
61
62 ### Proposed fix #2
63
64 > Caching in an array
65
66 Another solution would be to save every person in one array locally, so the data does not get overwritten, this solution could be a little more intrusive in the code and require more local resources, but would not increase the amount of requests like in the other solution. The deciding factor between this two would be the capacity of our servers, but they both solve our problem.
67
68 The idea here is to do something like this:
69
70 ``` python
71 bool continue = True
72 name = []
73 birthMonth = []
74 birthDay = []
75 email = []
76 while(continue):
77         print("What is your name?")
78         name.add(scan())
79         print("What month where you born?")
80         birthMonth.add(scan())
81         print("What day in {{birthMonth}} where you born?")
82         birthDay.add(scan())
83         print("{{name}}, what is your email?")
84         email.add(scan())
85         print("Everything is ready")
86         print("Would you like to add another person?")
87         continue = scan() // True repeats the loop
88 Data = convertToJSON(name, birthDay, birthMonth, email))
89 registerOnServer(Data) //request with all of the data
90 ```
91
92 <div dir="rtl">
93 Oscar J Rodriguez B
94 </div>
95