After four days of development, the IOS online bookstore has basically completed:
- Login Registration
- Book list, pull-down and refresh, drop-down to view more, asynchronous image loading
- My information, view Order Change Password
- View book details
- Add to shopping cart
- Submit order
- Sqllite stores browsing logs and submits them regularly
- Plist file storage cart
The most important elements in the architecture:
- Modular, vertical segmentation
- Hierarchical and horizontal segmentation
- Abstraction and implementation Separation
- Decoupling, how homogeneous components communicate, and how heterogeneous components communicate
- Separation of duties
Refactoring: eliminating duplicatesCodeTo eliminate the magic number
Although the bookstore application is simple, it contains a lot of content
- Layered Architecture
- Communication Control Between Layers
- Demonstration of various data access
The layered architecture is as follows:
- Resources is used for various resources, such as slice, icon, and multi-language text.
- Core is the business logic layer used to manage the data access layer and as a data container.
- The Controller is the business logic controller. It can also be named as a Service. Each business logic corresponds to a controller.
- Entity is the data entity. It is also used for description generation and serialization control.
- Data is the data access layer.
- Local data access (including userdefaults, plist files, and local sqllite)
- And Remote Data Access (HTTP + JSON)
- UI is the frontend
- Including viewcontroller
- View
- Encapsulated tableviewcell
- Communication protocol between viewcontrollers
- Utility includes extensions, constants, and gadgets.
Communication Control between layers is as follows:
- Viewcontroller acts as the front-end portal and communicates directly with the Controller. Among them, VC-> C is the method call, while C-> VC is the Message notification of noficationcenter, and the Controller uses the method call.
- Communication between viewcontrollers uses protocols, which are efficient and decoupled.
- As the entry to the business logic, the Controller calls the local data access service and remote data access service. For the latter, bookcontroller calls the bookservice method and calls the callback block.
- The service network layer uses asynchronous operationqueue. After asynchronous completion, the Controller registration callback method is called. The callback method sends a notification to the viewcontroller layer.
- At the service network layer, baseservice encapsulates common network processing and interacts directly with baseviewcontroller for common waiting and error handling.
The C-layer uses notifications to the VC layer, the VC layer uses the protocol, the VC-C layer uses the method call, the C-S layer uses the method call, and the s-c layer uses the block callback.
Download Code: here
ServerProgram(Based on ASP. net mvc) download: here
Database Backup (ms SQL based) download: here
Hope you don't mislead new users. The experts will pass by and help you to see what can be improved, especially in architecture.