This is a discussion on observer implementation within the Software Patterns forums, part of the Testing category; Hello chaps, wonder if anyone can help me out on how to implement the observer pattern. Scenario: I have a ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
observer implementation
Hello chaps, wonder if anyone can help me out on how to implement the
observer pattern. Scenario: I have a bunch of different products with different attributes and I want to update the values of the products attributes. I select the right class for the product using the Factory pattern, the product knows which attributes belongs to it (database fields) for updates and displaying etc... Ok so I want to give a means of inputting data to the products attributes depending on which product is selected - I only want to display certain text boxes that correspond to the correct products attributes. Now I thought an observer might do the trick with it looping through the products attributes container and calling "update" on the corresponding input (textbox), but a textbox has no input method so I would have to encapsulate the textbox and its "visible" method to give it the "update" fuctionality needed .. this seems awefuly long winded and overblown to me. Alternatively I could just set the visible property to either true or false from within the observer. Does anyone have a better way of dealing with this sort of setup? |