Hi everybody,
I am a beginner developer and in my Shopping List application I faced a problem of a massive controller. I have read several articles on this topic. They helped me to understand some things, but they don't solve this problem completely. Therefore, I decided myself to try to organize the structure of the view controller in terms of the tasks to be solved. For example, my application has a table view controller (screen) for list of items. This TVC should perform the following main tasks:
1. Show list of Items.
2. Select items for Shopping.
In turn, the first main task includes the following actions:
Show data in a table
Supporting Edit Actions - Add, Delete, and Change Data.
Supporting Usability Action - Sort (reorder, rearrange) Data.
The second main task includes the following actions:
Mark Items with a Checkmarks
In addition, this TVC should to save and load data.
Common / General Supporting Tasks for Both Main Tasks:
When I implemented all the functions of the controller, I got the following real structure:
Supporting Common / General Task: Load data
Load data from database
Load/Update data after changing in other View Controllers
Main Task 1: Show data in a table.
numberOfSections
numberOfRowsInSection
cellForRowAt
Supporting Edit Task for Main Task 1: Add a new item.
Calling a method from an Extension
Supporting Edit Tasks for Main Task 1: Delete and Change actions
leadingSwipeActions
deleteAction
changeAction
Unwind Action - Return from Change Screen for Cancel button
Supporting Usability Task for Main Task 1: Sort list of items.
Show sort/reorder/rearrange button and its title
Which rows can be reordered (Allow to reorder)
Reorder items in list
Remove Delete button from screen
Main Task 2: Select items (mark them with checkmarks)
didSelectRowAt
Supporting Usability Task for Main Task 2: Clear all Checkmarks.
Uncheck all items button
Supporting Common / General Task: Persist Data (Save data to the archive file)
Save/persist data before View will disappear
viewWillDisappear
Could you tell me is this approach optimal? May I have some other problems later which I do not know about yet?
Any ideas are appreciated.
I am a beginner developer and in my Shopping List application I faced a problem of a massive controller. I have read several articles on this topic. They helped me to understand some things, but they don't solve this problem completely. Therefore, I decided myself to try to organize the structure of the view controller in terms of the tasks to be solved. For example, my application has a table view controller (screen) for list of items. This TVC should perform the following main tasks:
1. Show list of Items.
2. Select items for Shopping.
In turn, the first main task includes the following actions:
Show data in a table
Supporting Edit Actions - Add, Delete, and Change Data.
Supporting Usability Action - Sort (reorder, rearrange) Data.
The second main task includes the following actions:
Mark Items with a Checkmarks
In addition, this TVC should to save and load data.
Common / General Supporting Tasks for Both Main Tasks:
Save data to the archive file
Load Data from the archive file
When I implemented all the functions of the controller, I got the following real structure:
Supporting Common / General Task: Load data
Load data from database
Load/Update data after changing in other View Controllers
Main Task 1: Show data in a table.
numberOfSections
numberOfRowsInSection
cellForRowAt
Supporting Edit Task for Main Task 1: Add a new item.
Calling a method from an Extension
Supporting Edit Tasks for Main Task 1: Delete and Change actions
leadingSwipeActions
deleteAction
changeAction
Unwind Action - Return from Change Screen for Cancel button
Supporting Usability Task for Main Task 1: Sort list of items.
Show sort/reorder/rearrange button and its title
Which rows can be reordered (Allow to reorder)
Reorder items in list
Remove Delete button from screen
Main Task 2: Select items (mark them with checkmarks)
didSelectRowAt
Supporting Usability Task for Main Task 2: Clear all Checkmarks.
Uncheck all items button
Supporting Common / General Task: Persist Data (Save data to the archive file)
Save/persist data before View will disappear
viewWillDisappear
Could you tell me is this approach optimal? May I have some other problems later which I do not know about yet?
Any ideas are appreciated.