Share an example of a bookstore iOS program

Source: Internet
Author: User

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:

  1. Modular, Vertical partitioning
  2. Hierarchical, Horizontal segmentation
  3. Abstraction and implementation separation
  4. Decoupling, how homogeneous components communicate, how heterogeneous components communicate
  5. 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

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.