My class function alway need do something before like this (Python):
class X:
def f1():
####
if check() == False:
return;
set_A()
####
f1_do_something
def f2():
####
if check() == False:
return;
set_A()
####
f2_do_something
And I want to :
class X:
def f1():
# auto check-return-set_A()
f1_do_something
def f2():
# auto check-return-set_A()
f2_do_something
I've read about design patterns and I do not know how to apply design patterns in this case. If there is no any suitable design patterns, are there any other solution to this problem?