设计模式
2020-12-16 17:54:53 0 举报
设计模式
作者其他创作
大纲/内容
Laptop
+ laptopName():void
定义了BaoQiangStar和Proxy的共同接口,这样就在任何使用BaoQiangStar的地方都可以使用AgentProxy
ConcreteFanA
+ name:String
状态模式
继承
Client
Adaptee
adapteeRequest()
BarBecuerReceiver
+ barbecue():void+ cancelBarbecue():void
VIPFacade
+cardPhysician:CardPhysician +register:Register +triageTriage
+ vipService(pcp:String):void
职责链模式
Star<<interface>>
+ addFan(fan:Fan)+ deleteFan(fan:Fan)+ notifyFans(msg:String)
IPhoneBrand
+ phoneBrand():void
Director
+ constructProduct(concreteBuilder:ConcreteBuilder)
AbstractFactory
+produceLaptop():Laptop+producePhone:Phone
策略模式
通过在内部包装一个Adapter对象,把源接口转换成目标接口
Porsche
+ buyCar():void
RedColor
+ phoneColor():void
ConcreteIterator
+ attribute1:type = defaultValue+ attribute2:type- attribute3:type
+ first():T+ last():T+ curretItem():T
ConcreteClassA
+ primitiveOperation1():void+ primitiveOperation2():void+ primitiveOperation3():void+templateMthod():void
AbstractClass
空心三角形+实线
依赖
定义一个对象接口,可以给这些对象动态的添加职责
Student
+idcard:String
+searchIdCard(idcard:String):String
User
+ readBook(book:Book):Book
Component
void display() void add(component:Component ) void remove(component:Component)
Builder
+ setAddress()+ setPhone()+ getProduct() :Product
BaoQiangStar
+ movie():void
装饰抽象类,继承抽象构件角色(Car),从外类来扩展Car,但对于Car类来说,是无需知道CarDecorator的存在的
Command<<interface>>
+ execute():void+ undo():void
BlackColor
Memento
+ username:String+ passwd:String
AppleFactory
+produceLaptop:Laptop+producePhone:Phone
定义代理类所代表的的真实实体
SpeedUpState
WeiqiFlyweight
+ color:StringWeiqiFlyweight(color:String)
+ playGo(position:Position):void
ConcreteBuilder
+ operation1(params):returnType- operation2(params)- operation3()
ContextStrategy
cashSuper:CashSuper
+ contextInterface(money:double):double
Product
+ name:String+ explain:String+ phone:String...
具体的产品
WaiterRevoker
+ beginBarbecue():void+ cancelBarbecue():void
CashReturn
+ acceptCash(money:double):double
Builder是为了创建一个Product对象的各个部件指定的抽象类/接口
Iterator<<iterface>>
File
+void display()+ void add(component:Component )+ void remove(component:Component)
+ add():+ remove():+ createIterator():Iterator
Adapter
request()
Register
+ register()
Colleague
+ mediator:Mediator
+ send()+ receive()
实现
Context
MovieStar<<Interface>>
桥接模式
ConcreteColleague1
Flyweight<interface>>
+void playGo(position:Position)
适配器模式
HuaWeiPhone
+ phoneName():void
DepartmentManager
+ handlerRequest():String
装饰者模式
Car<<interface>>
空心三角形+虚线
ConcretePrototype1
+ createClone():Sheep
模板方法模式
Person
+ id:String+ name:String
+ setName(name:String):void- getId(id:String):String
让一个原型克隆自身从而创建一个新的对象
HuaWeiFactory
迭代器模式
Mediator
+ register(colleague:Colleague)+ relay(colleague:Colleague)
PorscheDecorator
+ keyless():void+ boss():void+ buyCar():void
CashNormal
ICashSuper<<interface>>
具体的构建这者,实现Builder接口,构造和装配各个部件
FlyweightFactory
getWeiqiFlyweight(color:String):Flyweight
ConcreteFanB
Target
中介者模式
备忘录模式
Brand
+ color:Color
+ setColor(color:Color):void- phoneBrand():void
Position
+ x:Integer+ y:Integer
Phone
Triage
+ triage()
Manager
+ next:Manager
MacLaptop
指挥者,是构建一个使用Builder接口的对象
Caretaker
+ memento:Memento
具体的装饰者,起到给Car添加职责的功能
CashRebate
+moneyRebate:double
Dog
+ eat():void+sleep():void
UserOriginator
+ createMemento();Memento+restoreMemento()
HuaWeiLaptop
命令模式
创建者模式
xxxCommand
+ barBecuerReceiver:BarBecuerReceiver
具体的构建者,也可以给这个对象添加职责
HeroState
Folder
IPhone
外观模式
代理模式
ConcreteClassB
VertigoState
观察者模式
<<interface>>Animal
+ eat():void
CardPhysician
+ cardPhysician(pcp:String):void
ConcreteColleague2
保存一个引用使用代理可以访问实体,并提供一个与MovieStar的接口相同的接口,这样代理就可以用来替代实体。
组合模式
LuoZhiXiang
+ name:String+ fanList:List
虚线箭头
SlowDownState
Singleton
ConcreteMediator
Book
DaNiaoCommand
已经存在的,需要适配的类
抽象工厂模式
Aggregate<<iterface>>
target是客户所期待的接口,目标可以使具体的或抽象的类,也可以是接口
MiPhoneBrand
Sheep
+ name:String+ color:String
Color<<interface>>
- phoneColor()
CarDecorator
+car:Car
ShaunTheSheep
+ sheepName:String+ sheepColor:String
享元模式
AgentProxy
baoQiangStar:BaoQiangStar
+ movie():void+contract():void
Fan<<interface>>
原型模式
0 条评论
下一页