Http://www.cnblogs.com/loying/p/4801194.html then the previous version of the schema. Question 1:model do you want to listen to events? At present, the model needs to be changed when: 1, viewcontroller request data, 2, when the message changes, (such as landing, logout, store switching) The current disadvantage: message, there are various model code; [Self lYPos Tnotification:notify_index_data]; [[Cartmodel instance] Onshopchange];
[[Categorydetailmodel instance] Onshopchange]; [[ServiceModel instance] Onshopchange];For example, after switching stores, there are these transformations;[Self lypostnotification:notify_user_logout]; [[Cartmodel instance] ClearCache];
[[Addressmodel instance] ClearCache];
[[Usermodel instance] ClearCache]; [[Ordermodel instance] ClearCache]; When you log out, you need to empty the model, and if new model such as the newly added servicemodel, you need to add the appropriate logic code to the message, and the question is, The model's clearcache and other functions are called by the message, and the coupling is particularly strong; it's the equivalent of doing something a (logout), then doing the thing B (emptying the data) immediately, and it's a direct call, which makes it easy to make mistakes later. Imagine: If the model listens to events, then the model simply listens to each event and then writes the processing function; The model's logic is aggregated in itself;The consequence is that the model becomes slightly larger. Multiple events, and multiple processing functions. However, if this is a message to invoke, the processing function is the same as to write, but more than the event-handling listening code. The logic of the model is aggregated, but the logic of the logoff is scattered, and can not see what is done after the logoff. This problem does not seem to be a problem, because you can view the listener of the event and see the model that listens for the logoff event. There is a code that sets up all the model instance. All model must be initialized first. Otherwise, the event cannot be monitored. Question 2: When the message is called, the message gets the data from each model, so who does the parameter check? 1, who calls (between different levels), who is responsible for checking the parameters, such as ordermessage requires the user to log in, then call Ordermessage, you must ensure that the login. (because the message and model are not at the same level) 2, if the content of the inspection is its own content, then be responsible for themselves. Question 3: Jump from Page A (controllera) to page B (controllerb), the user's operation data (such as a message), how to properly from a to B?
IOS e-commerce App first edition architecture improvements