Appearance mode (facade), which provides a consistent interface for a set of interfaces in a subsystem, defines a high-level interface that makes this subsystem easier to use.
You can consider using the appearance mode in the following cases: (1) The initial stage of the design should be conscious of separating the different layers and establishing the appearance pattern between the layers and the layers. (2) During the development stage, the subsystem becomes more and more complex, and the appearance mode is added to provide a simple calling interface. (3) When maintaining a large legacy system, it is possible that the system is very difficult to maintain and extend, but it also contains very important features for it to develop an appearance class so that the new system interacts with it. A little: (1) The loosely coupled relationship between the subsystem and the client is realized. (2) The client shields the subsystem components, reduces the number of objects that the client needs to process, and makes the subsystem easier to use. Simple code example: Create a new group containing ' SHAPE.H/SHAPE.M/RECTSHAPE.H/RECTSHAPE.M/CIRCLESHAPE.H/CIRCLESHAPE.M Shape.h
1 #import <Foundation/Foundation.h>23@interface shape:nsobject 4 5 -(void) draw; 6 7 @end
RectShape.h
1 #import " Shape.h " 2 3 @interface Rectshape:shape 4 5 -(void) draw; 6 7 @end
CircleShape.h
1 #import " Shape.h " 2 3 @interface Rectshape:shape 4 5 -(void) draw; 6 7 @end
Create another DRAWSHAPE.H/DRAWSHAPE.M to use as a controller
1 #import<Foundation/Foundation.h>2 #import "RectShape.h"3 #import "CircleShape.h"4 5 @interfaceDrawshape:nsobject6 7+ (void) Drawrectshape;8+ (void) Drawcircleshape;9 Ten @end
Used in controller
1 #import "ViewController.h"2 #import "DrawShape.h"3 4 @interfaceViewcontroller ()5 6 @end7 8 @implementationViewcontroller9 Ten- (void) Viewdidload { One [Super Viewdidload]; A - //Invoke Draw Interface - [Drawshape Drawrectshape]; the [Drawshape Drawcircleshape]; - - } - + - @end
Objective-c appearance Mode--Simple introduction and use