You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ada-project-docs/optional-enhancements.md
+2-22Lines changed: 2 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,36 +28,16 @@ How would you write tests for it? How would you implement it?
28
28
29
29
Your decisions should not break the other tests.
30
30
31
-
### Model Instance Methods
32
-
33
-
We can define instance methods in our model classes.
34
-
35
-
Consider places in your code that deal with one model at a time. Is there any repeated logic or behavior?
36
-
37
-
Here are some ideas to start:
38
-
39
-
- Create an instance method in `Task` named `to_dict()`
40
-
- Converts a `Task` instance into JSON
41
-
- Returns a Python dictionary in the shape of the JSON our API returns in the `GET``/tasks` route
42
-
- Create a class method in `Task` named `from_json()`
43
-
- Converts JSON into a new instance of `Task`
44
-
- Takes in a dictionary in the shape of the JSON our API receives in the create and update routes
45
-
- Returns an instance of `Task`
46
-
47
31
### Use List Comprehensions
48
32
49
33
Use list comprehensions in your route functions where applicable.
50
34
51
-
### Route Helper Methods
52
-
53
-
If you have not already refactored your route files to use helper methods, do so now!
54
-
55
-
Consider code with complex or repetitive logic, and refactor it into helper methods. Watch your route files become cleaner and more readable!
56
-
57
35
### More Query Params
58
36
59
37
Create the tests and implementation so that the user may
60
38
61
39
- filter tasks by title
62
40
- sort tasks by id
63
41
- sort goals by title
42
+
43
+
Remember that Wave 2 already has a sorting feature for tasks by title, so we might practice creating another route helper method that can be used for sorting across multiple model types. Such a method could even be extended to perform the filtering as well!
0 commit comments