Decorator Pattern

ayushmaan_jain
Mausschubser
Mausschubser
Beiträge: 64
Registriert: 18. Okt 2014 11:11

Decorator Pattern

Beitrag von ayushmaan_jain »

Hi,

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

Thanks
SJ

jonasmolina
Neuling
Neuling
Beiträge: 5
Registriert: 7. Feb 2015 09:19

Re: Decorator Pattern

Beitrag 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

ayushmaan_jain
Mausschubser
Mausschubser
Beiträge: 64
Registriert: 18. Okt 2014 11:11

Re: Decorator Pattern

Beitrag 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.

phopner
Mausschubser
Mausschubser
Beiträge: 45
Registriert: 26. Apr 2012 02:11

Re: Decorator Pattern

Beitrag 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.

Antworten

Zurück zu „Archiv“