1 Preface
We have learned so many design patterns before, all of which are used to improve the "reusability" and "scalability" of software systems. Today, let's take a look at the architecture design of IOS applications.
Reprinted please indicate the source: http://blog.csdn.net/developer_zhang
2. Details
The system architecture we designed should adopt the hierarchical division method, and each layer should be coupled and the layers should be highly cohesive. Is a general low-coupling enterprise-level system architecture:
Presentation Layer: a set of components for user-system interaction. The user submits a request or sends a command to the system through this layer. The system accepts the user's command through this layer, calls the next layer, and then displays the result to this layer. The presentation layer should be lightweight and should not have business logic.
Business logic layer: the core business processing layer of the system. Receives instructions and data from the presentation layer. After the instructions and data are digested and absorbed, processes the business logic of the Organization and returns the results to the presentation layer. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + yv2 + records + 8 records/b7dv + K78tXfzsS8/rLZ1/records + records/b7ds9a + records + 0 MXPos + records + 3cC01LSjrL/records/4qOszsS8/ qOs0sXB9M + weight + CjxwPiAgyOe5 + weight/L7f09DU9sm + uMSy6bG4zfzCvLXEuabE3KGj08PA/Weight = "http://www.2cto.com/uploadfile/Collfiles/20140228/20140228083232290.jpg" width = "700" height = "500" alt = "\">
After the hierarchical design, the presentation layer can be divided into iPhone and iPad versions, while the business logic layer, data persistence layer and information system layer can be shared, which greatly reduces our workload.
On the IOS platform, the layered architecture is designed in multiple modes: based on the hierarchy of the same project, based on the hierarchy of different projects in a workspace and the layer of static link libraries. Here we will briefly introduce the layering based on the unified project.
In this application, we are divided into three groups: PresentationLayer, BusinessLogicLayer, and PersistenceLayer. PresentationLayer is used to place identification-related classes, and BusinessLogicLayer is used to place logical layer-related classes, persistenceLayer is used to place classes related to the persistent layer. At each layer, we can either divide by business module or by component function. The PersistenceLayer layer is also divided into two groups: dao and domain. Dao is used to place a data access object, which contains four types of CRUD methods for accessing data. To reduce coupling, dao is generally designed as a protocol (or Java Interface), and then implemented in different ways based on different data sources. Domain groups are Entity classes, and entities are people, things, and things in applications.
Code example:
Note entity class:
# Import
/*! * Note object class ** @ since V1.0 */@ interface Note: NSObject @ property (nonatomic, strong) NSDate * date; @ property (nonatomic, strong) NSString * content; @ end
Data Persistence operation class:
# Import
# Import "Note. h "/*! * Data Persistence operation class (using listData to simulate sqlLite) ** @ since V1.0 */@ interface NoteDAO: NSObject // Save the data list @ property (nonatomic, strong) NSMutableArray * listData; // instantiate your object + (NoteDAO *) using the singleton method; // add the memo method-(int) add :( Note *) model; // Delete the memo method-(int) remove :( Note *) model; // modify the memo method-(int) update :( Note *) model; // query all-(NSMutableArray *) findAll; // Method for querying data based on the primary key-(Note *) findById :( Note *) model; @ end
Memorandum business logic:
# Import
# Import "NoteDAO. h "/*! * Memorandum business logic ** @ since V1.0 */@ interface NoteBL: NSObject // insert memorandum method-(NSMutableArray *) addNote :( Note *) model; // Method for deleting a memo-(NSMutableArray *) removeNote :( Note *) model; // query all methods-(NSMutableArray *) findAll; @ end
3 conclusion
The above is all content and I hope it will help you.
Code instance: http://download.csdn.net/detail/u010013695/6968053