开发者

Can You Decorate a Black Box?

开发者 https://www.devze.com 2023-03-14 00:07 出处:网络
I have a quick, very uninformed question about the Decorator pattern. If I have a class called BlackBox that I cannot edit in any 开发者_如何学JAVAway - can\'t add an interface, can\'t make any of the

I have a quick, very uninformed question about the Decorator pattern. If I have a class called BlackBox that I cannot edit in any 开发者_如何学JAVAway - can't add an interface, can't make any of the methods virtual, etc. - can this object be decorated using the Decorator pattern? If so, how?


You can create a wrapper for it (i.e., implement the Adapter pattern) and decorate the adapter.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号