3 ms·
Programming is mostly creating functions and interfaces to decompose problems into reusable parts where reuse makes sense. Nothing wrong with creating a simple
by megous 9y ago
Programming is mostly creating functions and interfaces to decompose problems into reusable parts where reuse makes sense. Nothing wrong with creating a simple function for making XMLHttpRequests or for fetch API. Most of the time there's no need for the level of generality of jQuery interfaces.
Just by making a function you're not creating a library. Sometimes I find DOM API verbose too. Nevertheless the fix does not need to be a interface like jQuery to completely hide DOM API under another interface. It may be enough to extend the HTMLElement prototype a bit or write a function to "compress" the code a bit and make it more readable.
- forgottenpass 9y agoJust by making a function you're not creating a library. Have you seen what passes for a library on npm?
- megous 9y agoGood point. :D
- sametmax 9y ago> it may be enough to extend the HTMLElement prototype a bit You lost me here. Anybody extending standard objects cannot be taken seriously.
- megous 9y agoDo you realize JavaScript is a prototype based programming language? It is a major and very useful feature of the language. There's no reason not to use it. There are some things to be careful about with interop if you need it, but that's it.
- jamiepenney 9y agoWe've already learned from our past mistakes changing the prototype of the standard library - the Ruby community learned the same thing with monkey patching their standard lib too. The maintenance overhead far outweighs any immediate benefits.
- megous 9y agoWhat maintenance overhead? Current and future costs are reduced by making code simpler and cleaner in the first place by using prototypes efficiently. Also, to be clear, I'm suggesting adding new methods to DOM object prototypes, not changing behavior of existing methods.
- ehsanu1 9y agoApplications may be able to do this in a controlled manner. Library authors never should.