I see some code design like this
class my_class:
def __init__(self, arg1, arg2, arg3)
self.data = data(arg1, arg2, arg2)
# initialize some other attributes
# the only place data class is used is in my_class
class data:
def __init__(self, arg1, arg2, arg3)
self.arg1 = arg1
self.arg2 = arg2
self.arg3 = arg3
I don't see the point of doing that, when you can just do
class my_class:
def __init__(self, arg1, arg2, arg3)
self.arg1 = arg1
self.arg2 = arg2
self.arg3 = arg3
# initialize some other attributes
which gets rid of the seemingly unnecessary layer.
Is there some advantage of design standard that motivates the former design?
Aucun commentaire:
Enregistrer un commentaire