From the course: Visual Basic Essential Training

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Use parameters with procedures

Use parameters with procedures - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Use parameters with procedures

- [Instructor] Let's take a closer look at these two functions. They're mostly duplicate codes, so it's time to refactor. Refactoring is the process of restructuring existing code without changing its behavior to improve readability, helps reduce redundancy, and makes it easier to maintain. As part of this process, we'll explore how adding parameters in Visual Basic Functions can make our code cleaner and more reusable. This allows our functions to work dynamically with different inputs, and we'll get to see some of the Visual Studio refactoring tools. First thing we need to decide is what code to refactor. Now if I'm looking at these two methods, I see that the top three lines are identical between both functions, so that looks like a good refactoring to make into a new function. Now when you're thinking about refactoring, you want to look at the single responsibility principle. A function should focus on a single task and it should also be easy to understand, so anyone reading the…

Contents