+ 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?!
3 ответов
+ 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
+ 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
0
it's not better to build a own class then to do caching?