Share an example of a bookstore IOS Program

Source: Internet
Author: User

 

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:

    1. Modular, vertical segmentation
    2. Hierarchical and horizontal segmentation
    3. Abstraction and implementation Separation
    4. Decoupling, how homogeneous components communicate, and how heterogeneous components communicate
    5. 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.