3 ms·
Having worked with large codebase written in jQuery here are some of my thoughts, There were a ton of times where the complexity of the situation made it so ha
by darepublic 8y ago
Having worked with large codebase written in jQuery here are some of my thoughts,
There were a ton of times where the complexity of the situation made it so hard to know how to debug something. I mean you had to keep track in your head in a given piece of code what the UI state was, what classes or event handlers were toggled on or off, what the value of various variables were etc. In order to keep my sanity I would have to create functions that basically do what React or other frameworks give you out of the box so it would be easy to reason about everything.
There was so much code like this:
var $snippet = $(<div></div>).append(...).addClass().on('click', handler => {
if (alienState) {
$snippet.off('click')
} else {
$snippet.on('click', handler2)
}
})
$(".parentClass > ").remove() /clear any dom framents in there //before a fresh injection! fingers crossed!*/
$(".parentClass").append($snippet)...
etc etc
I'm sure there is a way to do disciplined excellent jquery code. I'm always quick to say its the coder(s) that make a piece of software code good or bad. But if you were to make a well made jquery application you would need to implement some kind of design pattern, and exercise some kind of conventions and discipline that you could really get for free with a framework.
- gkya 8y agoThat sounds like an issue caused by an indecent debugger to me. I havent had to debug JS, but indeed the browser debuggers can use some sophistication and customisability, IMHO.
- hajile 8y agoJS debuggers are generally very good. The level of interactiveness of JS also puts them ahead of most non-lisp languages. Debugging async code isn't like debugging other code. Once you cross that async barrier, all stack traces disappear (I understand Google's doing some work on making that better). In this particular case, debugging is harder because the UI is also holding all the data, so in order to reset to known good data, you have to reset the page itself. One of the biggest benefits to moving to React (or similar) is that you start keeping all that data in a central place.