g**********y 发帖数: 14569 | 1 In a sequential computing program, what is the best way to pass intermediate
result among classes?
For example, component A generates by-product O, which will be used by
component B and C.
Make by-product O global is one-way, but not good choice.
Pass O from A to B, C is another way, but I don't like that idea either. A
becomes depending on B and C. | g*****g 发帖数: 34805 | 2 How about keep 0 as a field of A, and make a getter for it.
Pass A to B and C.
【在 g**********y 的大作中提到】 : In a sequential computing program, what is the best way to pass intermediate : result among classes? : For example, component A generates by-product O, which will be used by : component B and C. : Make by-product O global is one-way, but not good choice. : Pass O from A to B, C is another way, but I don't like that idea either. A : becomes depending on B and C.
| g**********y 发帖数: 14569 | 3
That makes B and C depends on A. I really want to cut this dependency. Problem
is, B and C doesn't know A instance. My central controller is configured in
very general way, even controller doesn't know there is an A instance. It
generates objects from XML and execute method as specified.
【在 g*****g 的大作中提到】 : How about keep 0 as a field of A, and make a getter for it. : Pass A to B and C.
| c****r 发帖数: 185 | 4 Create a new component to interact with A, B, and C.
See mediator pattern.
Problem
【在 g**********y 的大作中提到】 : : That makes B and C depends on A. I really want to cut this dependency. Problem : is, B and C doesn't know A instance. My central controller is configured in : very general way, even controller doesn't know there is an A instance. It : generates objects from XML and execute method as specified.
|
|