Tamilnadu Samacheer Kalvi 12th Computer Science Notes Chapter 3 Scoping Notes
Scope:
- Scope refers to the visibility of variables, parameters and functions in one part of a program to another part of the same program.
- The scope of a variable is that part of the code where it is visible.
- The LEGB rule is used to decide the order in which the scopes are to be searched for scope resolution
Mapping:
- The process of binding a variable name with an object is called mapping.
- = (equal to sign) is used in programming languages to map the variable and object.
Namespaces:
Namespaces are containers for mapping names of variables to objects.
Local scope:
Local scope refers to variables defined in current function.
Global variable:
A variable which is declared outside of all the functions in a program is known as global variable.
Nested function:
A function (method) with in another function is called nested function.
Enclosed Scope:
A variable which function which contains another function definition with in it, the inner function can also access the variable of the outer function. This scope is called enclosed scope.
Built-in scope:
Built-in scope has all the names that are pre-loaded into program scope when we start the compiler or interpreter.
Module:
- A module is a part of a program.
- Programs are composed of one or more independently developed modules.
Modular programming:
The process of subdividing a computer program into separate sub-programs is called Modular programming.
Access control:
Access control is a security technique that regulates who or what can view or use resources in a computing environment. It is a fundamental concept in security that minimizes risk to the object.
Public members:
Public members (generally methods declared in a class) are accessible from outside the class.
Protected members:
Protected members of a class are accessible from within the class and are also available to its sub-classes.
Private members:
Private members of a class are denied access from the outside the class: They can be handled only from within the class.They can be handled only from within the class.
Access Specifiers in Python and C++ and Java:
- Python prescribes a convention of prefixing the name of the variable/method with single or double underscore to emulate the behaviour of protected and private access specifiers.
- C++ and Java, control the access to class members by public, private and protected keywords
- All members in a Python class are public by default whereas by default in C++ and java all members are private.