Comments (7)
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.
I do not understand your argument about Bracket style.... their patterns are identical except Compose provides a clear means of:
- marking a method override as required
- 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:
- older project, extremely well tested and proven despite its low version num.
- 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.
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.
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.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-irc-bot.