What is modularity
Modularization is to disassemble a complex App according to different functional modules and refine it into independent sub-functional modules. Complex business processes are then implemented through assembly.
Why modularity
Boss 1: We're opening a new project tomorrow. The project is very simple, which is to separate the hot items in our App into a new project. You have one day. Boss 2: Our friend in an app recommended it. I'm going to be on another B-app. Boss 3: Our company will prepare a version for the Double 11 activity, and we need to develop it now. The current pace should not be disturbed, and two people should be assigned to do other new requirements for the app. Developer A: I just wrote a really cool algorithm, in "path", you see if you can use it. Developer B: Why did you create a file called GoodsModel? I wrote one, too. Rely on. Change your name. .....................Copy the code
Advantages of modularity
- To reduce the coupling
- Reduce code interaction when developing in collaboration
- Improve code reuse across projects and modules
- The module is easy to maintain and conduct unit test
How to modularity
In the actual development process of iOS, we generally divide the business into basic functional modules and business modules.
Basic functional modules generally include:
- Foundation: Generally holds common methods, functions, project environment configurations, etc.
- Widget: UI layer,
- Service: indicates the network layer
- “Navigation” : indicates the route forward
And so on.
Functional modules: Take general shopping apps as an example:
- Log in to register
- List of goods
- Goods details
- search
- The shopping cart
- User information, etc.
In iOS we manage it through Cocoapods