CPT write up
Row 1 (Purpose & Function):
-
The overall purpose of the program is for people to be able to record their workouts, find motivation to continue their workouts, and use the website for educational purpose (P.E).
-
The video shows the user typing in their name, the date they completed their workout, what type of workout they did, and the duration into the form and then that data gets added to the table.
-
When the user inputs their name and the other information, that data is sent to be stored in the database (helped being transmitted with the API) and the information comes back to the frontend to be displayed on the table.
Row 2 (Data Abstraction):
-
The list is called uo
-
The data contained in the list is the ID assigned to each section of the form the user has to input. (ex. name, workout type, etc.)
Row 3 (Managing Complexity):
- The list manages complexity because there is only a numbered amount of places where every user has their information (lets say 4 places) instead of having countless number of variables for each user (if there were 50 people using the program, then having 50 lists, one for each person, would make it less efficient). It's better to have just a few variables (one for ALL names, and one for ALL workouts) than to have one for each person for multiple people. (The list is above)
Row 4 (Procedural Abstraction):
- What this does is it takes the uo list and uses create which is what allows the user to add on a new row in the table.
Row 5 (Algorithm Implementation):
- It basically repeats each step if the user doesn't input something and makes the user type what is needed in order to move onto the next step. If the user were to type in nothing, it wouldn't move forward and add a blank table. The user needs to input something in order for the program to work. This specific peice of code is for the form that is used for the users to input their information in order to add it to the table, but it's not the actual form but "garbage data", or variables that can't be entered, in order for the program to work as intended. The class is workout API and within that class is another class called create. Then under that the program defines fname (for first name) and lname (for last name) and so on and has specific requirements. For example, it the name is less than two characters than you would get an error message and it would ask you to try again. Likewise, the following lines have code have a specific number of characters or requirements in order for the form to be filled out correctly and added to the table.
Row 6 (Testing):
-
First Call: The user inputs their name, workout, the date, and # of hours and submit
- Conditions: It checks if the data is being added
- Result: Data will appear in the table just below the form
-
Second Call: User enters something that is not accepted by the program (like numbers in the name entry)
- Conditions: Checks if the data is valid and if it is invalid it will get rid of it.
- Result: The program will return a message asking the user to correct their error.