+ 1

OOP and decorators

are decorators obsolete or not a good practice in object oriented programming? think this will end up in not maintainable code?!

14th Jan 2017, 4:24 PM
Andy
Andy - avatar
3 odpowiedzi
+ 1
Oh, well used decorators are very useful as they can isolate business logic for administrative logic (e.g. caching a web page when fetching it). Makes the code more maintainable. And I quite dislike OOP for the sake of OOP, so I don't use it when there is no use
22nd Jan 2017, 1:51 AM
Amaras A
Amaras A - avatar
+ 1
A class can be a decorator, actually. Decorators increase code reusability : e.g. @caching def fetch(url): pass that would cache your page, if you did it right. Plain and simple, helps reusability. They are NOT obsolete, actually more useful now than ever
22nd Jan 2017, 12:18 PM
Amaras A
Amaras A - avatar
0
it's not better to build a own class then to do caching?
22nd Jan 2017, 12:08 PM
Andy
Andy - avatar