Skip to content
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

Code could benefit from polymorphism #135

Open
vrza opened this issue Mar 10, 2020 · 0 comments
Open

Code could benefit from polymorphism #135

vrza opened this issue Mar 10, 2020 · 0 comments

Comments

@vrza
Copy link
Contributor

vrza commented Mar 10, 2020

Problem

All transport variants are implemented under a single class (Syslog extends Transport). Behaviour for different transport variants is driven by conditional if/else blocks (see, for example, sendDgram() and connectDgram()). This kind of approach makes the code hard to read and maintain.

Proposed solution

Leverage JavaScript object polymorphism! More specifically, code could be refactored into multiple internal classes implementing the common logging interface, e.g. at least UnixSocketSyslog, UDPSyslog and TCPSyslog. The Syslog constructor could parse the options and instantiate the appropriate subclass, so that existing consumers don't need to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant