Skip to content

mixin-ization Puppet Abstract Class #156

@huan

Description

@huan

What is Mixin

Along with traditional OO hierarchies, another popular way of building up classes from reusable components is to build them by combining simpler partial classes. You may be familiar with the idea of mixins or traits for languages like Scala, and the pattern has also reached some popularity in the JavaScript community.
https://www.typescriptlang.org/docs/handbook/mixins.html

Mixin is a great decouple and design pattern to split the puppet class logic into different files.

Wechaty Puppet Mixins

  1. We will have a PuppetSkelton as the base abstract class for all Mixins, it
    1. extends the PuppetEventEmitter for adding the listener typings
    2. has the least components to support other mixins
  2. All functionalities will be added by mixin, for example:
    1. CacheMixin for puppet.cache related codes
    2. WatchdogMixin for puppet.watchdog related codes
    3. MemoryMixin for puppet.memory related codes
    4. MessageMixin, ContactMixin, RoomMixin, etc to add related puppet abstract APIs
  3. All mixins need to implement a start() and stop() and call super.start() and super.stop() inside them, to make sure the start/stop chains can work as expected.

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions