JavaScript-Automated refactoring solutions and practices

Source: Internet
Author: User
How to "automate refactoring" of code
For example: How to modify the method name of the code and its invocation?

#!/usr/bin/env pythondef test():    test = 'test()'    print test[:-2]test()

Note:
1. The IDE generally has such a function, it is hoped that the automated completion of the batch operation.
2. Methods such as regular are not considered here, such as strings in the code with the same name can easily be replaced.
3. The practice of the master is to make use of Python-rope [Https://github.com/python-rope/rope]
To refactor, but only to find a way to modify the variable. Is there any experience in providing methods or other similar tools?
4. Tools that are not necessarily limited to Python refactoring other languages can also be shared.
5. The "automated refactoring" here means that I do not need to do it manually. When I write the refactoring rules, I can refactor some projects in batches. Similar Python-rope

Reply content:

How to "automate refactoring" of code
For example: How to modify the method name of the code and its invocation?

#!/usr/bin/env pythondef test():    test = 'test()'    print test[:-2]test()

Note:
1. The IDE generally has such a function, it is hoped that the automated completion of the batch operation.
2. Methods such as regular are not considered here, such as strings in the code with the same name can easily be replaced.
3. The practice of the master is to make use of Python-rope [Https://github.com/python-rope/rope]
To refactor, but only to find a way to modify the variable. Is there any experience in providing methods or other similar tools?
4. Tools that are not necessarily limited to Python refactoring other languages can also be shared.
5. The "automated refactoring" here means that I do not need to do it manually. When I write the refactoring rules, I can refactor some projects in batches. Similar Python-rope

    1. Using Automated refactoring Classes
      Python-rope [Https://github.com/python-rope/rope]

    2. Using the Headless IDE
      Eclim
      Https://github.com/ervandew/eclim

We usually use JetBrains a series of Ides, which have a series of IDE WebStorm (JavaScript), ( Intellij Java), Pycharm (Python), and so on, these tools have their own refactoring capabilities. As in IntelliJ, there are some refactoring options that can be found in Martin's "refactoring" book.

Then, the function you need should be Rename , the shortcut key is Shift +F6

1. Check Test ()
2. Press SHIFT + F6 to pop up the dialog box
3. Enter a new method name
4. Select a section, or all the content that needs to be modified.

During the internship, I wrote a series of articles about how to use IDE refactoring: ThoughtWorks Practice--a tentative study of reconstruction and IntelliJ idea

Reply to the comments in the picture.

Refactoring automation is a pseudo proposition, to do automation, need to have a clear input, clear output, the desired output, so that you can compare the output of automation and you expect the output is consistent

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.