Science Fair Projects Ideas - Name binding

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Name binding

(Redirected from Dynamic binding)

In computer science, binding is associating objects and implementations with names in programming language so that those objects and implementations can be accessed by the names. An object's names are said to be "bound" to them.

Deep binding and shallow bindings are not kinds of binding, but ways to implement binding.

The simplest example is defining subprograms:

def sum (x, y)
  x + y
end

sum (2, 3)

In this Ruby code, an implementation returning the sum of given two inputs is bound to a name, sum.

Contents

Binding time

Because objects in computer programs are usually resident in the computer memory, binding time is almost the same as the time of allocation of memory space for objects. Bind can be done either at compile-time or link-time (static binding) or at run-time (dynamic binding). Also, scope rules might define binding time of objects. Local variables, for example, are usually bound at run-time while global variables at compile-time.

For example,

static int n;
int main ()
{
  n = 12;
  return n;
}

In this C code, a global variable n is bound to certain location in the memory of the computer.

Dynamic binding for polymorphism

In object-oriented programming, an object can respond to the same message with a different implementation. Dynamic binding, also called dynamic dispatch is a common solution for this problem.

For example there may be an object that contains the name (data) 'Socrates', and which is of the class (or type) Person.

Now suppose all Persons are mortal. In object oriented programming, we can say that the Person class must implement the Mortal interface, which contains the method die().

Persons and Plants die in different ways, for example Plants don't stop breathing. 'Dynamic binding' is the practice of figuring out which method to invoke at runtime. For example, if we write

void kill(Mortal m) {
  m.die();
}

it is not clear whether m is a Person or a Plant, and thus whether Plant.die() or Person.die() should be invoked on the object. With dynamic binding, the m object is examined at runtime, and the method corresponding to its actual class is invoked. (This implies that the actual representation of an object in memory is just its data and doesn't include the methods.)

Deep binding v.s. shallow binding

In computer science, deep binding is the most common implementation of bindings. Each environment consists of variables names and values. The environments are linked according to the scoping rules. When a name is used in a procedure the environments are searched from the inner to the outer nesting level.


In computer science, shallow binding associates bindings for each variable and then searches the bindings associated with the variable to find the binding for the current environment. The major advantage is that it reduces the search time for variables that are bound in the global environment.

In shallow binding, lexical variables mentioned in anonymous subroutines are whichever variables with the same names happen to be in scope when the subroutine is called. In deep binding, they are the same ones that were in scope when the subroutine was created.

The above contains the text from perlfaq7

See also

10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice