h****4 发帖数: 39 | 1 本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位.
Using C++ write a solution to solve the following:
Class Foo performs an action that Class Bar needs to respond to. Class Foo
and Class Bar have no knowledge of each other. Write a system that will
allow Class Bar to respond to actions from Class Foo while preserving the
decoupled nature of both classes. The solution needs to be scalable and
extensible so that other classes can produce and respond to actions from any
other class.
· Must be written in C++
· |
a****l 发帖数: 8211 | 2 出这种问题的人太搞笑了.你就这么回答:你是Bar,我是Foo,如果Bar能知道Foo做了什么
action大家又是完全隔离的no knowledge of each other,那么你不用我说就应该知道
我什么时候回答出了你的这个问题还知道我的答案是怎么样的.
any
【在 h****4 的大作中提到】 : 本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位. : Using C++ write a solution to solve the following: : Class Foo performs an action that Class Bar needs to respond to. Class Foo : and Class Bar have no knowledge of each other. Write a system that will : allow Class Bar to respond to actions from Class Foo while preserving the : decoupled nature of both classes. The solution needs to be scalable and : extensible so that other classes can produce and respond to actions from any : other class. : · Must be written in C++ : ·
|
m*****e 发帖数: 4193 | 3 You just need an adaptor class A that links the two.
A registers with Foo and responds to its action
Bar registers with A and responds to its action
In A's responder, it calls Bar's responder
any
【在 h****4 的大作中提到】 : 本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位. : Using C++ write a solution to solve the following: : Class Foo performs an action that Class Bar needs to respond to. Class Foo : and Class Bar have no knowledge of each other. Write a system that will : allow Class Bar to respond to actions from Class Foo while preserving the : decoupled nature of both classes. The solution needs to be scalable and : extensible so that other classes can produce and respond to actions from any : other class. : · Must be written in C++ : ·
|
c*****t 发帖数: 1879 | 4 For pure OO method, google "Inversion of Control" and
"Dependency Injection". Usually that's what people asks.
It is also possible to use C++ template, which is based on template
pattern, which is helped by the C++ compiler.
any
【在 h****4 的大作中提到】 : 本人水平有限,不得要领.请版上的牛人给些建议.谢谢各位. : Using C++ write a solution to solve the following: : Class Foo performs an action that Class Bar needs to respond to. Class Foo : and Class Bar have no knowledge of each other. Write a system that will : allow Class Bar to respond to actions from Class Foo while preserving the : decoupled nature of both classes. The solution needs to be scalable and : extensible so that other classes can produce and respond to actions from any : other class. : · Must be written in C++ : ·
|
S*********g 发帖数: 5298 | 5 I think proxy/adaptor + observer can do the job too
【在 c*****t 的大作中提到】 : For pure OO method, google "Inversion of Control" and : "Dependency Injection". Usually that's what people asks. : It is also possible to use C++ template, which is based on template : pattern, which is helped by the C++ compiler. : : any
|