Extract a base class for shapes to handle similar features #4
Open
Description
There should be some sort of base class or decorator that handles the noise
and ambient
options for each shape. These options are the same for all shapes.
One method would be a base class and then expose the shape names as the __call__
function so they appear to be functions:
class Shape:
def __call__(self, <params>):
shape = self.build(<params>)
<apply noise>
<apply ambient>
return shape
class Sphere(Shape):
def build(self, <params>):
<sphere building code>
sphere = Sphere().__call__
Or decorator:
def shape(shape_builder):
def wrapper(<params>):
s = shape_builder(<params>)
<apply noise>
<apply ambient>
return s
return wrapper
@shape
def sphere(<params>):
<sphere building code>
- Decorators looks easier to understand what's going on.
- Will either of these mess with the introspection abilities? What docstrings show up? How can we get proper docstrings?
Metadata
Assignees
Labels
No labels