Comments (6)
I think I like this idea. It's better than the this._patch internal method someone suggested, that reversed it by removing the ...args from the constructor.
from klasa.
Actually, have you...tested this? I'm not sure you can use methods from child classes.
from klasa.
@tech6hutch I have tested, and yes they are able to
https://jsbin.com/migiqinafe/edit?js,console
from klasa.
This is a terrible practice (limits the namespace of the class, just to store the same data on the class again later, and that's not even counting any resolved state such as usage. So the data is tripled via instance.config(), instance._internalConfig, and instance.things. As well as there are times you want to add your own state to your class instances, for which that should always be done in the constructor anyway, else you make V8 choke an re-compile your instances every time you add properties.)
Not that you can't do this in your own bot (extend Command or w/e to give yourself this way of setting config)... But this isn't something that will be done in the core framework.
from klasa.
@bdistin What my proposal was in reality is to eliminate the need of extending args when the user is not going to do anything with it.
config
method doesn't need to be a function, it can be just a simple object. This is how React handles their classes. I don't see bad practice in this compared forcing the user to be aware of arguments on constructor that their don't need to.
you make V8 choke an re-compile your instances every time you add properties.
I don't see how you would add properties to the class in runtime (?)
limits the namespace of the class, just to store the same data on the class again later, and that's not even counting any resolved state such as usage. So the data is tripled via instance.config(), instance._internalConfig, and instance.things. As well as there are times you want to add your own state to your class instances, for which that should always be done in the constructor anyway, else you make V8 choke an re-compile your instances every time you add properties.
Again, my demo was an example on what we may do. We can literally force config
to be an object and mention it directly.
The bigger picture is that the user doesn't need to be aware of the constructor if he is not responsible for it
from klasa.
That sentence is meant to be taken as a whole. As in, if you eliminate using constructor, when people want to add properties, they may be tempted to add them in any method, rather than in the constructor which really isn't as optional as it may appear to be.
from klasa.
Related Issues (20)
- docs do not works HOT 2
- build broken HOT 2
- Documentation is not opening HOT 1
- Rename extendables to mixins HOT 1
- Documentation not working HOT 1
- Incorrect Docs Link and subsequent GitHub Link HOT 2
- Settings#update() returns the wrong data
- Unable to see any page from the documentation. HOT 5
- SettingsGateway Type Role with Sqlite Provider returning the wrong id HOT 4
- Reaction handler does not check for DM, causes error
- Module '"discord.js"' has no exported member 'ClientApplication'. HOT 7
- NPM listing is out of date HOT 5
- Broadcast Eval bug
- Message#flags being incompatible
- i18n Friendly
- Klasa SQLProvider class does not check for instanceof MemberGateway in klasa-member-gateway
- Klasa ReactionHandler unstable behavior when messages are deleted HOT 2
- FS-NEXTRA error when interacting with settings. HOT 2
- RichDisplayRunOptions.jump - Allow jumping to info page.
- Bug: Concurrency is broken in Schedule
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 klasa.