Use the rgreatex plug-in to quickly refactor hardcoded characters to resource files

Source: Internet
Author: User

An extreme saying in software development is that "all hard-coded strings should be placed in resource files". I personally agree with this opinion, but sometimes it is limited to the project progress or other reasons, still habituallyCodeWrite some hard-coded strings, such as the following code:

Public void testmethod ()
{
String S = "this is a test string ";
}

If the Code contains a large number of hard-coded strings, you need to re-compile and generate each time the value of the string changes at the end of the project.ProgramThis is undoubtedly very unreasonable. Some may have said that you can solve the problem by placing the string directly in the resource file. Well, this is a good solution, but think about the hundreds of hard-coded strings in the code, it will undoubtedly give you a headache.

Let's take a look at rgreatex, the plug-in of resharper, which is a tool that can quickly refactor hard-coded strings in code to resource files. Let's just look at how to use it:

Select the string to be reconstructed, for example, "This is a string" in the previous example, and right-click and select "refactor-> localization-> move string to resource ".

If no special settings are available, click "Next". Then rgreatex will automatically search for the same strings in the Code. If yes, it will be reconstructed, if not, only the selected string is reconstructed. After reconstruction, our method will look like the following:

Public void testmethod ()
{
String S = resources. S;
}

How can we use rgreatex to reconstruct hard-coded strings? Does it save some time. If you think rgreatex is useful, download it from here.

PS: There are still a lot of software that can improve productivity. Please pay attention to it.

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.