New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LineParserPlugin base class or LineDecoder bridge for Ruby #231

frsyuki opened this Issue Jul 7, 2015 · 0 comments


None yet
1 participant

frsyuki commented Jul 7, 2015

There are no simple way to initialize LineDecoder in Ruby. However, a lot of parser plugin (especially simple plugins) are based on lines. Plugins should not have these lines:

A discussion point is the design of bridge or mixin. This design can be reused when we want to have many other utilities for each domains.

Design options:

  • Utility class: add LineDecoder class. Plugins needs to get configuration parameters from config, and pass them to the constructor of LineDecoder class.
    • Pros: Loosely-coupled. Easy to test. Less likely to break backward compatibility when changed.
    • Cons: Getting config parameters from config in plugin code is very verbose.
  • Base class: add LineParserPlugin class. Plugins extend the class and override `run(line_decoder)@ method.
    • Pros: Minimum amount of code (in plugin).
    • Cons: Difficult to use with other base classes because Ruby uses single inheritance. We often miss to call super because we need to call super in some cases but we must not call super in the other cases (inconsistent).
  • Mixin: add LineParserPluginMixin module. Plugins include the module.
    • Pros: small amount of code (in plugin), and no need of super call.
    • Cons: Difficult to design consistent API. Avoid mess of many mixins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment