Seite 1 von 1

Decorator Pattern

Verfasst: 2. Jul 2015 12:03
von ayushmaan_jain
Hi,

Could anyone please explain the late binding problem described in slides ?
I tried but could not understand.

Thanks
SJ

Re: Decorator Pattern

Verfasst: 2. Jul 2015 16:03
von jonasmolina
Hey,

although we spent some time, we still have the same problem. Could you shortly explain the problem again in tomorrow's lecture?

Thanks in advance!

Jonas & Manuel

Re: Decorator Pattern

Verfasst: 2. Jul 2015 17:03
von ayushmaan_jain
It will be pretty helpful if Prof. Eichberg could arrange a problem discussion on design patters.
It will help us to deepen knowledge about same and clearing the doubts.

Re: Decorator Pattern

Verfasst: 19. Jul 2015 15:07
von phopner
I think the problem is, that OnlineAccount is not a subclass of CheckingsAccount or SavingsAccount and printHistory just forwards the call of printHistory to one of those objects, so it will still print the type of the decorated account, not of the online account. We can not just change that call of getType() so it will call the getType() of the OnlineAccount, since we only want to decorate objects, we can not change their source code.
If their was only the call to getType, we could just call the getType in OnlineAccount, but we can not just do that, if getType is called in a bigger method.