DiamondLightSource / cssgen

Python to generate CS-Studio OPI files
Other
0 stars 4 forks source link

Clean up API #22

Open nickbattam opened 7 years ago

nickbattam commented 7 years ago

The API contains a lot of repetition of words: e.g. in cssgen.borders.OpiBorderRenderer self._text_renderer = text_renderer self._text_renderer.render(...) and in cssgen.render.get_opi_renderer() tr = OpiTextRenderer() wr = OpiWidgetRenderer(tr) cr = colors.OpiColorRenderer() wr.add_renderer('background_color', cr) This makes the API unnecessarily verbose.

The class, module and package names are not always self explanatory.

Renaming some classes, methods and package could simplify this, e.g. <renderer>.add_renderer() to <renderer>.add() and make it simpler to understand.

mfurseman commented 7 years ago

I also found adding actions to be verbose and repetitive. We have

class ActionWidget
    def add_something_command(<something command args>)
        self.actions.append(actions.SomethingCommandAction(<something command args>)

Do we need to have 'Action' in the class name as well as the module name. If we're going to add actions to widgets, and there is a class that represents that action, why not pass an instance of that class to represent the action, instead of some bunch of arguments?

willrogers commented 7 years ago

Other proposed changes: