Ray's playground

 

随笔分类 -  Objective-C

1 2 3 下一页

Memento(Chapter 23 of Pro Objective-C Design Patterns for iOS)
摘要:You’d think about using the pattern when all of the following applies: 􀀁 You need to save the object’s state as a snapshot or a portion of it,which can be restored later. 􀀁 You need to hide the interface with which obtaining the state wouldexpose the implantation details. 阅读全文

posted @ 2012-05-18 13:44 Ray Z 阅读(304) 评论(0) 推荐(0)

Proxy(Chapter 22 of Pro Objective-C Design Patterns for iOS)
摘要:You’d naturally think about using the pattern when 􀀁 You need a remote proxy that provides a local representative for anobject in a different address space or in the network. 􀀁 You need a virtual proxy to create heavy-weighted objects on demand.We will implement that kind of proxy in a code examp. 阅读全文

posted @ 2012-05-18 11:13 Ray Z 阅读(235) 评论(0) 推荐(0)

Flyweight(Chapter 21 of Pro Objective-C Design Patterns for iOS)
摘要:You’d naturally think about using it when all of the following are true: 􀀁 Your app uses a lot of objects. 􀀁 Keeping objects in memory can affect memory performance. 􀀁 Most of the object’s unique state (extrinsic state) can be externalizedand lightweight. 􀀁 Relatively few shared objects can rep. 阅读全文

posted @ 2012-05-18 11:03 Ray Z 阅读(270) 评论(0) 推荐(0)

Command(Chapter 20 of Pro Objective-C Design Patterns for iOS)
摘要:You’d naturally think about using the pattern when 􀀁 You want your application to support undo/redo. 􀀁 You want to parameterize an action as an object to perform operationsand replace callbacks with different command objects 􀀁 You want to specify, queue, and execute requests at different times. . 阅读全文

posted @ 2012-05-17 14:11 Ray Z 阅读(298) 评论(0) 推荐(0)

Strategy(Chapter 19 of Pro Objective-C Design Patterns for iOS)
摘要:A class uses multiple conditional statements in its operations to definemany behaviors. You can move related conditional branches into theirown strategy class. You need different variants of an algorithm. You need to avoid exposing complex and algorithm-specific datastructures to clients. 阅读全文

posted @ 2012-05-14 14:39 Ray Z 阅读(280) 评论(0) 推荐(0)

Template Method(Chapter 18 of Pro Objective-C Design Patterns for iOS)
摘要:Define the skeleton of an algorithm in an operation,deferring some steps to subclasses. Template Method lets subclasses redefine certain steps ofan algorithm without changing the algorithm's structure. 阅读全文

posted @ 2012-05-10 13:55 Ray Z 阅读(285) 评论(0) 推荐(1)

Chain of Responsibility(Chapter 17 of Pro Objective-C Design Patterns for iOS)
摘要:You’d naturally think about using the pattern when 􀀁 There is more than one object that may handle a request and thehandler is known only at runtime. 􀀁 You want to issue a request to a group of objects without specifying aparticular receiver that will handle the request explicitly. 阅读全文

posted @ 2012-05-08 14:35 Ray Z 阅读(244) 评论(0) 推荐(0)

Decorator(Chapter 16 of Pro Objective-C Design Patterns for iOS)
摘要:We have introduced the Decorator pattern with its concepts and different approaches toimplement it in Objective-C. A true subclass implementation uses a more structuredapproach to connect different decorators. A categories approach is simpler and morelightweight than its counterpart. It’s suitable . 阅读全文

posted @ 2012-05-04 09:32 Ray Z 阅读(305) 评论(0) 推荐(0)

Visitor(Chapter 15 of Pro Objective-C Design Patterns for iOS)
摘要:The Visitor pattern represents an operation to be performed on the elements of an objectstructure. Visitor lets you define a new operation without changing the classes of the elements onwhich it operates. 阅读全文

posted @ 2012-05-03 13:48 Ray Z 阅读(299) 评论(0) 推荐(0)

Iterator(Chapter 14 of Pro Objective-C Design Patterns for iOS)
摘要:Provide a way to access to the elements of an aggregate object sequentially withoutexposing its underlying representation. 阅读全文

posted @ 2012-05-02 16:10 Ray Z 阅读(252) 评论(0) 推荐(0)

Composite(Chapter 13 of Pro Objective-C Design Patterns for iOS)
摘要:When Would You Use the Composite Pattern? You would naturally think about using the pattern whenYou want to have abstract tree representation of objects (part-wholehierarchies). You want clients to treat all objects in the composite structure andindividual objects uniformly. 阅读全文

posted @ 2012-04-25 14:21 Ray Z 阅读(244) 评论(0) 推荐(0)

Observer(Chapter 12 of Pro Objective-C Design Patterns for iOS)
摘要:Defines a one-to-many dependency between objects so that whenone object changes state, all its dependents are notified and updated automatically. 阅读全文

posted @ 2012-04-24 17:04 Ray Z 阅读(284) 评论(0) 推荐(0)

Mediator(Chapter 11 of Pro Objective-C Design Patterns for iOS)
摘要:The Mediator pattern is used to define a centralized place where interactions amongobjects can be handled in one mediator object. Other objects don’t need to interact witheach other directly, so it reduces dependency among them. 阅读全文

posted @ 2012-04-23 16:59 Ray Z 阅读(265) 评论(0) 推荐(0)

Façade(Chapter 10 of Pro Objective-C Design Patterns for iOS)
摘要:There are three common situations in which you would consider using this pattern: Your subsystem is getting complex. A lot of classes are evolved fromapplying patterns. You can use a façade to provide a simpler interfacefor the subsystem classes. You can use façades to layer your subsystem 阅读全文

posted @ 2012-04-20 16:27 Ray Z 阅读(205) 评论(0) 推荐(0)

Bridge(Chapter 9 of Pro Objective-C Design Patterns for iOS)
摘要:Abstraction is the parent interface that defines the high-level abstraction interface usedby clients. It has a reference to an instance of Implementor, which defines the interfacefor implementation classes. This interface doesn’t need to correspond to Abstraction’sinterface; in fact, they can be qu. 阅读全文

posted @ 2012-04-20 15:28 Ray Z 阅读(251) 评论(0) 推荐(0)

Adapter(Chapter 8 of Pro Objective-C Design Patterns for iOS)
摘要: 阅读全文

posted @ 2012-04-17 18:14 Ray Z 阅读(238) 评论(0) 推荐(0)

Singleton(Chapter 7 of Pro Objective-C Design Patterns for iOS)
摘要:#import"Singleton.h"@implementationSingletonstaticSingleton*sharedSingleton=nil;+(Singleton*)sharedInstance{if(sharedSingleton_==nil){sharedSingleton_=[[superallocWithZone:NULL]init];}returnsharedSingleton_;}+(id)allocWithZone:(NSZone*)zone{return[[selfsharedInstance]retain];}-(id)copyWith 阅读全文

posted @ 2012-04-10 12:47 Ray Z 阅读(294) 评论(0) 推荐(0)

Builder(Chapter 6 of Pro Objective-C Design Patterns for iOS)
摘要:We discussed Abstract Factory in the last chapter. You might have realized that both the Abstract Factoryand Builder patterns are similar in many ways in terms of being used for abstract object creation. However,they are very different. Builder focuses on constructing a complex object step-by-step,. 阅读全文

posted @ 2012-04-03 15:08 Ray Z 阅读(408) 评论(0) 推荐(0)

Abstract Factory(Chapter 5 of Pro Objective-C Design Patterns for iOS)
摘要:The Abstract Factory and Factory Method patterns are very similar in many ways. It’s very confusing tomany people when to use which one of them. Both of them can be used for the same purposes of creatingobjects without letting clients know what exact concrete objects are being returned. The followi. 阅读全文

posted @ 2012-03-27 11:22 Ray Z 阅读(303) 评论(0) 推荐(0)

Factory Method(Chapter 4 of Pro Objective-C Design Patterns for iOS)
摘要:The abstract Product defines the interface of objects the factory method creates. TheConcreteProduct implements the Product interface. The Creator defines the factorymethod that returns an object of Product. It may also define a default implementation ofthe factory method that returns a default Con. 阅读全文

posted @ 2012-03-26 15:04 Ray Z 阅读(294) 评论(0) 推荐(0)

1 2 3 下一页

导航