The view controller is not evil in nature, although it is common for them to turn into monolithic riots because they are so convenient for expansion.
... It seems a little extreme to create all of your views separately and use delegate methods to access actions.
Think about how to break your program into smaller units, whatever that is. A subclass of UIView in each case is not the best solution (as one example).
Each developer tolerance is slightly different and depends on the program / case, but it is quite easy to recognize and eliminate duplicate code and break your programs into smaller units.
I think most classes:
- must not exceed several Ivars (e.g. 2)
- no more than 100 lines required
- must maintain composition over inheritance. in many cases, when you think you need inheritance, protocols can be used.
Of course there will be exceptions.
I am wondering which design is most effective in terms of memory and application performance (which is clearly important when working with mobile applications)?
It is important that you get a lot by writing more reusable programs. Invest more time and effort in these reusable projects, reduce duplicate code, and focus on quality. Write performance and memory in your projects where this is a concern. As a rule, this will lead to a big victory compared to the terrible recently written, poorly tested monolithic VC.
Ultimately, I would like to know the right way to do something. So, the question is, should all kinds and any logic connected with it be completely separated from VK? Should I use delegates to communicate with the UIViewController?
Relief: No, you donβt have to go that far if you eliminate redundant code, focus on reuse where applicable, and make sure your units / classes support low complexity. Absolutely, eliminate these problems before they become monolithic classes, regardless of whether they are VC or another type.
justin
source share