<span id="Label3"></p><p><p>iOS design mode, A lot of development this is to listen to much, but sometimes you use it is not very concerned about, developers in writing code will not pay attention to it.</p></p><p><p>In the field of software design, The design pattern is a reusable solution to the Problem. Design patterns are a series of templates that help you write understandable and reusable patterns that help you create loosely coupled code that you don't have to spend too much on to change or replace components in your Code.</p></p><p><p>(1) Proxy Mode</p></p><p><p>Scenario: when some functionality of a class needs to be implemented by another category, it is not sure which class</p></p><p><p>Advantage: Loose coupling</p></p><p><p>Example: tableview Data source delegate, through the coordination with protocol, complete the Delegation.</p></p><p><p>Delegate of List row number</p></p><p><p>Custom delegate</p></p><p><p></p></p><p><p>(2) Viewer Mode</p></p><p><p>Application scenario: generally the model layer, controller and view of the notification method, do not care who to receive, only responsible for publishing Information.</p></p><p><p>Advantage: Loose coupling</p></p><p><p>Agile Principles: The principle of interface isolation</p></p><p><p>Example: Notification Notification center, registration notification center, Any location can send a message, registered Observer object can be Received.<br>kvo, the key value to change the notice of the observer, usually basically useless.</p></p><p><p>(3) MVC pattern</p></p><p><p>Application Scenario: is an ancient design pattern that, through the data model, controls its logic, and the view shows that the application is logically Partitioned.</p></p><p><p>Advantages: make the system level clear, responsibility clear, easy to maintain</p></p><p><p>Agile Principles: Open to extensions-closed for modifications</p></p><p><p>Example: model-is The data model, View-view display, controller for UI presentation and data interaction logic Control.</p></p><p><p>(4) Single case mode</p></p><p><p>Scenario: ensure that a class has only one instance of the program during its run, and is used for shared control of Resources.</p></p><p><p>Advantages: easy to use, camouflage evaluation, easy to cross module</p></p><p><p>Example: [uiapplication sharedapplication].<br>Note: Make sure that the user is only available through the getinstance method, only instances of the singleton class.</p></p><p><p>(5) Factory mode</p></p><p><p>Scenario: Factory Way to create an instance of a class</p></p><p><p>Advantages: easy to replace, oriented to abstract programming, application only with abstract factory and variable class common abstract class has a call Relationship.<br>Agile Principle: Dip Dependency Inversion principle<br>Example: when a project deployment environment relies on several different types of databases, you need to use the factory Mate proxy to complete the ease of replacement<br>Note: This mode is not recommended when the software structure and requirements are not stabilized at the beginning of the project, because its disadvantage is also obvious,<br>Increases the complexity of the code, increases the call level, and increases the memory Load. So pay attention to preventing patterns from Abusing.</p></p><p><p></p></p><p><p>iOS design mode</p></p></span>
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