Giter VIP home page Giter VIP logo

Comments (7)

triplem avatar triplem commented on August 27, 2024

Hi, there a more modules supporting this kind of OOP stuff. The standard JS way (used in this bot right now) is not as nice. But I just looked at https://github.com/a2labs/riveter - a quite young project - and I do like it. Compose JS looks nice as well, but somehow I dislike the used Bracket style. Makes the code not look as nice.

from nodejs-irc-bot.

ktiedt avatar ktiedt commented on August 27, 2024

I do not understand your argument about Bracket style.... their patterns are identical except Compose provides a clear means of:

  1. marking a method override as required
  2. AOP functionality... to run an override method before/after the original (or a fancier around() method if needed)

Also it has the added benefits of:

  1. older project, extremely well tested and proven despite its low version num.
  2. it's not a "trial" that may go away:

"riveter is currently an 'appendTo Labs' effort. This means that we're excited about it enough to make it a micro-library - and we invite you to try it out with us and give us your feedback. However, being that it's experimental, we may also decide it's the worst idea since the 8-track cassette player. As long as it continues to prove promising, it stands the chance of becoming a more 'officially supported' appendTo project. In short - we may pull the plug or change the name at any moment."

from nodejs-irc-bot.

triplem avatar triplem commented on August 27, 2024

You are right about the two last points, riveter seems to be a little too "cutting edge".

Basically both seem to provide the same kind of functionality, but IMHO it is cleaner to say

var Employee = function( name, title, salary ) {
    Employee.__super.call( this, name );
    this.title = title;
    this.salary = salary;
};

riveter.inherits( Employee, Person );

then the compose style:

    HelloWidget = Compose(Widget, {
        message: "Hello, World",
        render: function(){
            this.node.innerHTML = "
" + this.message + "
";
        }
    });
    var widget = new HelloWidget();
    widget.render(node);

Probably I am mistaken. For me there are too much brackets in there.

from nodejs-irc-bot.

ktiedt avatar ktiedt commented on August 27, 2024

What the equivalent example would be:

var Employee = Compose(function(name, title, salary) {
          // not seeing a good example for the super call in this case but
          this.title = tile,
          this.salary = salary;
};
Employee.extend(Person);

from nodejs-irc-bot.

triplem avatar triplem commented on August 27, 2024

Ah, I see, it is pretty much the same. First impression was that I do need more brackets and that I need to put everything in this Compose(-Bracket stuff. Anyway, me is not really a JS expert. So, I guess, the Plugins should definitly adopt this, since then we could use clean inheritance for those ;-)

from nodejs-irc-bot.

triplem avatar triplem commented on August 27, 2024

I have now found a quite easy solution, without the necessity to load another component. We could basically just use util.inherits and everything is fine. See my branch "inheritance" and the plugins/BasePluginStandard.js and plugins/freenode.js.

All tests run fine ;-) I am going to use this one in the future and remove the pluginHelper.js again, which right now encapsulates some fundamental functionality for all plugins.

from nodejs-irc-bot.

ktiedt avatar ktiedt commented on August 27, 2024

This is fine for very basic functionality, but I still see Compose.before/after/around being very useful methods for Plugin writing -- which util.inherits can achieve, but not in a convenient way...

from nodejs-irc-bot.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.