Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I've found myself from the monstrous JavaScript-project. I haven't seen any references to known design patterns and code files consists of 5000+ rows of messy code. Usual length of the function is about 100 lines. Also namespaces are messy. Any ideas how to get any sense for this project?
I've been trying to read the source code, but there are no comments whatsoever. Also there are no tests, so making changes is a matter of luck.
Abandoning the project is not a choice.
Are there any nice tools for helping? At the moment I'm using sublime & Chrome.
If you have the specs you could write tests then refactor safely. Your tests will tell you if you break anything.
On the other hand if you don't have specs, you can write your tests by generating a bunch of random values and record the associated results. With your current code, you know (by definition) that they are correct.
I have seen the latter approach at a conference about refactoring ugly, legacy code. The speaker generated lots of random value/result pairs, turned them into unit tests, and started refactoring ultra-quickly. The results were quite amazing and you knew for sure that nothing had broken in the process.
Of course, if your application is more complex than the "give me an input, i'll tell you the output" style, this is trickier. But maybe it will get you started !
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have an idea of a cool tool for pretty much any text editor. To implement my idea I need to be able to:
Find the beginning and the end of the block of code where a statement is located. The number of lines for the declaration of the function and the corresponding closing bracket in JavaScript would be the dream.
Find every occurrence of the specified variable in a file.
This requires some syntax analysis of the target language. I really don't have much preference for the language of the API and the language being examined. Is there an easy-to-use tool for this?
I've been Googling this question for some time, and haven't found an obvious answer for the easiest way to do what I want. I only have opening code for Eclipse's editor to find the solution in mind right now. Atom's scope Descriptors seem unwilling to return numbers of lines for scope declarations.
I found out that I needed a proper parser for the target language to build a syntax tree of a file. I ended up using the esprima parser for JavaScript in combination with the Atom text editor, both of which are easy to delve into.
Also, it seems that the Python compiler provides an easy way to build an AST for Python code.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Have written a large system in ColdFusion/Javascript/MySQL. There is lots of Javascript. The few functions which are long are separated into cases. Currently I have all the js in 3 files, depending on the section of the application to which they refer.
Every now and again, some function which tested okay before turns out not to be working (I might have changed something elsewhere to cause that problem, without realizing I had to retest).
Okay, I deserve that, but when one js function in the file stops working, sometimes others do as well. So unexpectedly something I was counting on to validate things, or prevent a submit in the presence of errors does not work.
I've thought of breaking up the js so that any javascript function which is used by just one program will be resident there, and I would use the files with several js functions only for those that several programs have to access. That would insulate my functions somewhat from problems occurring elsewhere.
Is this approach recommended? Could someone offer good reasons for or against it? Or is there a way to "firewall" my functions so that problems with one do not spill over into another?
I'm feeling that the js is a weak link in my system -- that I can't trust it; yet I need it, so I have to find a way to make things more stable. Any and all suggestions to help would be much appreciated.
The suggestion "get better at Javascript" has already occurred to me. I am trying. Meanwhile, my needs are not very demanding. All my functions do simple things and are written in a pretty straightforward way. Yet I am having all this trouble.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Basically, I need to convert existing JavaScript code to flowcharts, I've tried using Code Visual to Flowchart but it doesnt produce the flow charts how I would like them to (just shows links to the different functions...
Whereas Visustin actually separates each function automatically.
Is there any free alternative or even a lesser expensive software?
I think converting the code unedited results is useless due to too much detail. I would suggest a different approach that yields very readable flowcharts. http://code2flow.com creates flowcharts from C-like (or Javascript-like) pseudo-code which can contain arbitrary natural language. Please note that I am directly involved with this solution. You should probably create a different flowchart for each important function in your code.
Sample flowchart (you may click to edit)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I've just recently started looking into the details of which events fire when in what browsers when an html page is loaded, and at how to use JavaScript, especially jQuery, to leverage those events to make a page do exactly what I want, when I want.
It seems like knowledge of when and how browsers set off events and how to access them in JavaScript is a pretty big deal, but there isn't really one, good place to go and learn about it. There are thousands upon thousands of juicy tidbits which contain all the information, many of which are even grouped on certain sites (like this one), but you generally have to know what you're looking for, which prevents a lot of the "stumble upon" effect when learning about a topic.
So is there a good place to learn about all the intricacies of something like the order of events when a page is loaded, or what exactly browsers do during an AJAX call, or just about how browsers deal with an general JavaScript event?
Haven't had time to read it myself but looks quite promising:
How Browsers Work
The holy grail of Javascript (events): quirksmode.
You could try Sitepoint.com http://www.sitepoint.com/javascript-from-scratch/ They do some very good and easy to read books and online guides for every skill level.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I'm aware of timing issues in Javascript, how its not exact/off by milliseconds etc, but I need something to at least attempt to do browser-based scheduling.
In terms of features, I'm thinking something along the lines of scheduling patterns described here: http://www.sauronsoftware.it/projects/cron4j/manual.php#p02
Anything out there? I've done google searches and haven't found any implementation worth nothing.
I thought I'd give it a quick go -- obviously this isn't production-code-worthy yet. Have a look.
Pimping my own code here, but I'm busy developing cron.js and its ready for general use.
As long as js engines live inside a browser, I don
t think there's much drive for such a feature. Now.. if one made a server js engine...
Take a look at scheduler.codeeffects.com. I don't know how it works but it has a js-based interface, so may be their scheduling engine is js-based, too. Just trying to help :)