From the course: Debugging in C#

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Side effects

Side effects

From the course: Debugging in C#

Start my 1-month free trial

Side effects

- [Narrator] Sometimes a function you create can have unintended side effects. Certain side effects can make your functions unreliable and can make certain bugs harder to find, so it's important to be aware of them when you have them. Not all side effects are bad, you just have to know about them. We say a function has a side effect when the given function changes something from outside its scope. An example of this might be when a function enables or disables a button. The function effected something that was outside its scope. Another side effect is writing to disc. The disc, outside of the scope of the function, is changed after the function is run. What you really want to avoid is unintended side effects. Let's take a look at some quick programmatic examples. Jumping into visual studio code, we have a program. In this first function, we have a function that has no side effects. It does not change anything outside of its scope. It simply returns the input doubled without changing…

Contents