LinkedIn principal author Doug Winnie explains the basics of how variable scope works in programming. With variable scope, the location of where your variable is defined determines where and for how long you can access its value. Variable scope is an important part of knowing how to work with variables as you build more complex programs and code.
- When we create variables, we need them…to hold values during our program.…But, how long do we need them to stick around?…As we build programs, we can define…how long we want to use variables, using Scope.…Scope defines how long a variable,…and the memory that is used to store it, is kept.…And how it's available for the program.…One obvious instance when the variable…isn't available any more, is when the program closes.…When the program stops, it releases…all the memory that it used and frees it…for other programs or systems to use.…
Inside of our program, if we create a variable,…we can access it using the name.…In our code, if we create a variable…and then call a function or method,…the variable is available to that method…since it was already created.…But if we enter into a function or method,…and then create a variable there,…as soon as that function or method is complete,…the variable is thrown away.…Including the variable name, and the value.…It's like walking down a hallway.…
If I enter a room in the hallway,…
Join Doug Winnie as he explains the principles of programming and helps you connect to core concepts by exploring three ways that programmers perform their jobs. Doug starts by sharing the history of coding and then dives into functions, values, variables, and parameters used to define actions. He covers capturing input from users, creating conditional tests, using loops with arrays, and object-oriented programming basics. He also takes you beyond programming, into processes like debugging, refactoring, and building iteratively.
- Working with values and variables
- Breaking down tasks
- Customizing functions and parameters
- Building conditional tests
- Creating and changing arrays
- Working with objects and classes
- Debugging and refactoring code
- Going beyond the code as a programmer
Skill Level Beginner
1. Control Computers with Code
2. Define Actions Using Code
3. Repeat Actions and Test for Conditions
4. Objects and OOP
5. Beyond Programming
Debug problems2m 50s
Next steps1m 19s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.