Last active
November 21, 2017 15:05
-
-
Save kidap/18ad864b17ae793f83c80db9f3636ad5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Recommendations | |
| 1. In FormOrderTableViewCell, move logic that changes color and font to awakeFromNib() | |
| 2. In OrderPickerView | |
| 2.1 Use the reset method of NSManagedObjectContext when OrderPickerView is not displayed | |
| 2.2 Change data structure of bills from [Date: [Bill]] to either [[(headerText, rows)]] or split it into 2 - headerTexts [String] and bills[[Bill]] | |
| 2.3 Instead of passing the Bill managed object to the UITableViewCell, map the values to an intermediary struct and pass that instead | |
| 2.4 Use UITableView directly and take out falcon | |
| 2.4.1 Option 1: | |
| 1. Start 2 fetches: <Fetch#1> to fetch initial objects to display(maybe the bills in the last 7 days), <Fetch#2> Fetch all bills (in the background) | |
| 2. Display <Fetch#1> right away. | |
| 3. When the user scrolls down close to the end of the table view(check scroll view delegate scrollViewDidScroll and check contentSize and contentOffset), copy/move objects from <Fetch#2> to <Fetch#1>. | |
| 4. Memory usage is not good but will be easier to implement search and filter | |
| 2.4.2 Option 2: | |
| 1. Set fetch limit to 50 | |
| 2. When the user scrolls down close to the end of the table view(check scroll view delegate scrollViewDidScroll and check contentSize and contentOffset), make a subsequent fetch and set fetchOffset | |
| 3. Better performance than option 1 but implementing search and filter will not be as straight-forward | |
| 4. Search and filter and be implemented by doing another fetch and adding predicates to filter the result | |
| 2.4.3 Option 3: | |
| 1. Same as Option 2 but instead of using fetch limit to control the amount of data, use dates instead (ex initial fetch will get all the last in the last 7 days. subsequent fetch will get the next 7 days) | |
| 2.4.4 In all three options, it would be nice if we can show a spinner at the end of the table view and only insert the new rows when the user is not scrolling to improve UX | |
| 2.4.5 My recommendation is Option3 for now. | |
| Notes: | |
| 1. Hard to improve performance without making major changes | |
| 2. We can’t use NSFetchedResultsController because the field refundedBill used to filter the list is a computed property and we can’t use computed properties in predicates | |
| Core Data Performance by Apple | |
| https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreData/Performance.html | |
| 1. Set fetchLimit then use fetchOffset for subsequent fetches (when use reaches the end of the table view’s scroll view, start another fetch) | |
| 2. Identify fields needed to be displayed right away and pass in those to NSFetchRequest.relationshipKeyPathsForPrefetching | |
| 3. Set context’s undo manager to nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment