Book Image

Python Tools for Visual Studio

Book Image

Python Tools for Visual Studio

Overview of this book

Table of Contents (13 chapters)

Refactoring


Refactoring is one of the biggest advancements in modern IDEs. It significantly cuts down on time and reduces the margin of error by the way in which it handles changes in the code and automated operations. Visual Studio comes with great out-of-the-box refactoring functionalities such as renaming and the creating method from a selected piece of code.

The renaming functionality can really help with potential errors in code, such as when changing the name of an element. There might be instances in the codebase where the old name is still used. Let's have a look at the following code:

class foo:
    """
    Documentation of the class.
    It can be multiline and contain any amount of text
    """
    @classmethod
    def bar(self, first=0, second=0):
        """This is the documentation for the method"""
        return first + second

print(foo.bar())

In this code, there's a class, foo, that has a method called bar. If bar is renamed, it will create an error by referencing to a nonexistent...