Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A brief introduction of VB.NET refactoring

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the "brief introduction of the relevant content of VB.NET refactoring". In the daily operation, I believe that many people have doubts about the brief description of the relevant content of VB.NET refactoring. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "brief description of the relevant content of VB.NET refactoring"! Next, please follow the editor to study!

You are already familiar with the addition of built-in refactoring support in Clover 2005 to make it easier for users to quickly implement common refactorings of their code. Refactoring is a very important means of maintaining code, not only for C # users, but also for VB users. Because the code upgraded from VB6 has changed beyond recognition after the "ravages" of the upgrade wizard, and many of the old code styles are incompatible with the new. Net features. Therefore, it constitutes an important means to upgrade the old code and improve the old code. Unfortunately, apart from renaming, VB2005 doesn't add a refactoring feature, which is a wet blanket for VB programmers.

Refactor! Support for VisualStudio2005's unique smart tag, which places the VB.NET refactoring feature in a contextual smart tag, rather than providing a choice in a "refactoring" menu option. This makes it easier for users to know what to do with the current code, rather than choosing from a bunch of bewildered refactoring names. This type of smart tag usually does not appear until the user places the input cursor over a reconfigurable object, such as the subroutine or function name, variable name, and so on.

The rearrangement parameter is Refactor! One of several refactoring functions that can rearrange the parameters of a function or subroutine. More miraculously, he can convert the parameters passed by reference to the return value of the function, or vice versa. For example, there is a subroutine like this:

Public Sub Sub1 (ByVal an As Integer, ByVal b As String) 'caller Call Sub1 (10, "str")

The above program can be reconstructed by "rearranging parameters": software development network

Public Sub Sub1 (ByVal b As String, ByVal an As Integer) 'caller Call Sub1 ("str", 10)

For example, there are subroutines like this:

Public Sub Sub2 (ByRef x As Integer) 'caller Dim i As Integer Call Sub2 (I)

With rearrange parameters, you can move the parameters passed by reference to a return value:

Public Function Sub2 () As Integer 'caller Dim i As Integer i = Sub2 ()

You can also do the opposite of VB.NET refactoring, changing the return value of the function into parameters passed by reference. There are many VB programmers who are used to using parameters to pass out the parameters they need. Now you can use this refactoring function to turn the appropriate subroutine into a function, or vice versa.

Introduction to the powerful function of VB.NET operator overloading

VB.NET grammar, how does the sugar taste?

Analysis on the principle of Service implementation of VB.NET scanning system

Detailed explanation of the implementation steps of combining VB.NET and GDI

Implementation Scheme of VB.NET menu component

The steps to do this are:

1. Save and compile the project first.

2. Place the cursor over the definition of the function, click the smart tag that appears, and select "ReorderParameters".

3. Press the Tab key, select the parameter or return value to be moved, and then press the left and right key to move the parameter to the appropriate position.

4. Press the Enter key to determine the modification, and then follow the prompts to change all calls of the function to the new signature.

5. Do RenameLocal refactoring as needed, and change the variable name introduced by this refactoring to the appropriate name.

The following program demonstrates the process of "rearranging parameters" reconstruction, and the visual effect of exchanging parameters is really cool!

Renaming local variables is another very useful feature. In fact, VB2005 already contains a safe renaming function, but renaming local variables can limit the scope of renaming to current functions or subroutines, and obvious visual effects allow you to see the renamed variables at a glance. The steps are as follows:

1. Select the symbol you want to rename, click the smart tag, and select RenameLocal.

2. Enter a new name in the green replaceable area, and press the Tab key to jump between all the areas where the name appears, so as to observe the scope of influence of this VB.NET reconstruction.

3. When you are sure, press Enter. It's simple.

At this point, the study of "A brief introduction to VB.NET refactoring" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report