Bloomberg LP Interview Question
Financial Software DevelopersI think Observer pattern is a typical design pattern for this problems. In Java or C++, we can also directly used delegate mechanism to implement this pattern. In other word, we can use different listeners for different groups of buttons. More detailed info can be acquired in the book <<Head First Design Patterns>>.
concept
system::button_pushed(int id) {
Button *button = getButton(id); //button is of type ButtonA
Theme *theme = getCurrTheme();
button->pushed(theme);
}
ButtonA::pushed(Theme* t) {
t->ButtonPushed(*this); //Now can use static overload binding, since type of *this
// is always ButtonA
// or simply t->ButtonAPushed(*this); to designate which function to call
}
Need a "Visitor_pattern" - see on wikipedia.
- Gopal June 28, 2010