In Python, I have a class C which embeds objects from classes A and B. Is it considered good practice to creates shortcuts from the properties of embedded objects of classes A and B as attributes of container class C?
The goal is to create a simpler interface in class C, abstracting the implementation details of classes A and B:
A minimal example:
class A:
def __init__(self):
self._a = 1
@property
def a(self): # Read-only property
return self._a
class B:
def init(self):
self._b = 2
@property
def b(self): # Read-write property
return self._b
@b.setter
def b(self, value):
self._b = max([value, 0])
class C:
def init(self):
self.a = A()
self.b = B()
# The following attributes provide "shortcuts"
# to the properties of the contained objects
self.a_val = self.a.a
self.b_val = self.b.b