Mobile App Architecture Design

Source: Internet
Author: User
mobile app Architecture design

This article mainly summarizes several commonly used architectural patterns, basically is layer by layer progressive Reprint please note name Source Http://blog.csdn.net/uxyheaven, good typesetting in https://github.com/uxyheaven/reading

If you think this article is good, please give a top in csdn, GitHub to a star.

The development of the Native app is much shorter than the traditional project iteration cycle, the demand change is also frequent, in the development of different life cycle using different architectural patterns can effectively save development time, improve development efficiency, this article introduces several common architectural patterns: performance Layer The basic MVC

Mobile apps are typically based on a classic MVC architecture

level function Design Principles
Model Layer (models) Encapsulates the application of a series of data, defines the operations, and processes the logic and calculation rules for the data. Feedback to the controller via NOTIFICATION,KVO
View Layer A View object is an application in which the user can see the object. The View object knows how to draw itself, and can respond to the user's actions. One of the primary purposes of the View object is to display the data from the application model object and allow the user to edit the data Views can be fed through target-action, delegate, DataSource, and controllers by not directly manipulating the model layer
Controller layer (Controller) The controller layer is a middleman between the view layer and several model layers C can directly manipulate model and view layers

Summary: C to m:apic on V:outletv to C:target-action, Delegate,datasourcem to C:notification,kvo MVC's improved version MVVM

MVVM is a view model based on MVC: The logic that converts the model's data into what view can render. App for a large number of display classes

Hmvc

Hierarchical MVC, which breaks down client applications into hierarchical, parent-child relationships, applies this pattern over and over again to form a structured client architecture. Suitable for heavy duty B/S structure webapp.

An MVC module is abstracted from one module of the application. One of the most important concepts is Parent MVC, which can correspond to an entity on the interface, or it can be an abstract object. Imagine an app with tabs, toolbars, navigation bars, main workspaces, corresponding to HMVC. The bottom tab of this app is Layer1, Layer2 navigation bar, main workspace, toolbar. If you think Layer2 is too complicated, you can put the main workspace in the Layer3, and so on.

Controller is the general control room of the functional module, which is responsible for communicating with the child Controller or parent Controller, and informs it that the View processing changes the interface display, Model handles some business logic or database access operations. For example, click on a toolbar button, the toolbar controller response to this event, found that to switch the main workspace, the toolbar can not do, pass his father controller processing (if the Father Controller also can not handle, continue to pass on) Then the tab bar's controller processing toggles the main workspace.

Advantages: Divide the program into several parts, reduce dependency support and encourage reuse of code, components or modules. In the future maintenance, increased scalability. Layered Design three-tier architecture

We're looking at the classic three-tier architecture.

From top to bottom is the presentation layer (UI) business logic layer or the domain layer (BLL) data access Layer (DAL)

level function Design Principles
Presentation Layer (UI) Presenting specific business data to the user, capturing user input information and operations User first, take care of simplicity; does not contain any business-related logical processing
Business Logic Layer (BLL) Fetching data from the Dal in the UI display; Obtain user directives and data from the UI, perform business logic, or write data sources through the DAL As a bridge between the U-layer and D-layer, the purpose is to show clear function structure, which is only responsible for data transfer, not SQL statements and ado.net
Data access Layer (DAL) Direct operation of the database, in response to the addition of data delete modify search; Provide data services specifically for the business logic layer or presentation layer. Specialized in database operation, regardless of data legality. Database error returned-1, logic error returned 0, and told the cause of the error, successfully returned 1

And then, our present structure is


four-tier architecture

With a layer of business rules based on a three-tier architecture, the usual three-tier is to combine business logic and business rules into one layer, collectively known as the business layer. The proposal of the business rule layer can not only deal with the illegal information entered by users in time, but also deal with the database errors in time, increase the structure definition of the business logic layer, Let business logic people concentrate on making logic

Top to bottom for presentation layer Business Rule Layer Business Logic layer or domain Layer data access layer

level function Design Principles
Business Rule layer (ECL) For the parameters passed down by the UI layer, check the legality. User first, take care of simplicity; does not contain any business-related logical processing
Five-tier architecture

Under normal circumstances, our business logic is placed in the middle tier, then to the internal of these large variety, the use of different kinds of classes of the call task, completely fell to the presentation layer. This is bound to increase the amount of code in the presentation layer, complicating the presentation layer's tasks, and the presentation layer is only responsible for accepting user input and returning results that are not commensurate with the task and increasing the degree of coupling between layers. Therefore, we need to increase the interface to the unified management of these services, is the design pattern of the façade model of the idea.

From top to bottom for presentation layer Business Facade Layer business rule layer Business Logic layer or domain Layer data access layer

level function Design Principles
Business Facade Layer Provides a consistent and simple interface for a set of interfaces in the subsystem.
Introducing Service Layer

The difference between the architecture that introduces the service layer and the normal layered architecture is that there is data inside the service layer that can be run separately.

From top to bottom, the service layer of the presentation layer (services) data access Layer business logic layer

level function Design Principles
Performance Layer Show mutual exchange with the user
Service Layer The service layer provides the business logic portal of the presentation layer, which is accomplished through interface invocation by defining the form of the interface service.
Business Logic Layer 1 The DTO from the receiving service layer, then processes the incoming DTO according to the business rules, returns the processed information 2 needs to provide business behavior for each object, and the interactions between these objects are separate 3 business objects through the service layer to organize
Data Access Layer Access interface for local data remote data
Rookie Viper

Viper here not much to say, please want to know the self search




Turn from: http://blog.csdn.net/uxyheaven/article/details/38041091

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.