After 4 days of development, iOS's online bookstore has basically completed:
- Login Registration
- Book list, drop-down refresh, drop down to see more, picture asynchronous load
- My information, view the order change password
- View book details
- Add to Shopping Cart
- Submit Order
- Sqllite Store browsing log, timed submission
- plist File Store Shopping Cart
- 5 years of well-developed UI front-end framework!
The most important element in the architecture:
- Modular, Vertical partitioning
- Hierarchical, Horizontal segmentation
- Abstraction and implementation separation
- Decoupling, how homogeneous components communicate, how heterogeneous components communicate
- Separation of duties
Refactoring: Eliminate duplicate code, eliminate magic number
Bookstore application is simple, but contains a lot of content
- Layered architecture
- Communication control between the layers
- A demonstration of various data access
- 5 years of well-developed UI front-end framework!
The layered schema is as follows:
- Resources for a variety of assets, compared to slices, icon and multi-lingual text
- core is the business logic layer used to manage the data access layer, and as a container for data
- controller is the business logic controller, can also be named service, each business logic corresponds to a controller
- entity is a data entity and is also used for description generation and serialization control
- Data is the access layer
- There are local data access (including Userdefaults, plist files, and local sqllite)
- and remote Data access (Http+json)
- The UI is the front end
- includes Viewcontroller
- corresponding view
- encapsulated Tableviewcell
- viewcontroller
- Utility includes extensions, constants, and gadgets
- 5 years of well-developed UI front-end framework!
The communication between the layers is controlled as follows:
- Viewcontroller, as the front-end portal, communicates directly with the controller, where Vc->c is a method call, and C->VC is a noficationcenter message notification, and the controller uses a method call
- The communication between the Viewcontroller is protocol-efficient and can be decoupled
- The controller, as the gateway to the business logic, invokes the local data access service and the Remote Data Access service, and for the latter bookcontroller to Bookservice takes a method call and returns a callback block
- The Service Network layer adopts asynchronous Operationqueue, calls the controller registration callback method after the asynchronous completion, and notifies the Viewcontroller layer with the callback method.
- The service network layer has baseservice encapsulates the general processing of the network, interacting directly with the Baseviewcontroller for some common wait and error handling
C Layer to the VC layer using the notification, VC layer between the use of Protocol, VC to C layer using method calls, C to s layer using method calls, S to C layer using block callback. 5 years of well-developed UI front-end framework!
Hope not to mislead the novice, the master passing help to see what can be improved, especially the architecture.
Share an example of a bookstore iOS program