File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes What is the difference between 'deep' and 'shallow' binding? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What is the difference between Watch "What is the difference between New topic
Author

What is the difference between 'deep' and 'shallow' binding?

chad stevens
Ranch Hand

Joined: Aug 20, 2002
Posts: 88
Hello.
I would like to know the difference between what is deep binding and shallowing binding. There is also dynamic binding.
CHAD
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I have never heard of deep and shallow binding. Where do you have these terms from?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
I have heard of deep and shallow copying...
do u want that?
thanks,
Chinmay........


The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
The way that I understand it is that in some languages you are allowed to have methods imbedded in other methods or method used as a parameter to a method call. In such cases if the "inner method" or function uses the same variable values as the calling method, then you have deep binding, if the outer methods scope does not encompase the inner method then you have shallow binding.
Since Java does not allow this is it not an issue.
However, if you COULD do that and your outer method had a variable that hides a static variable, when you are in your inner method a language with deep binding would use the outer classes understanding of the variable. A language with shallow binding would use the static variable itself.
(This is based on a rather sketchy understanding).
Found a quote from [url=http://xarch.tu-graz.ac.at/autocad/lisp/FAQ-link/msg00644.html[/url]
>There is a tradeoff between shallow and deep binding. Shallow binding
>makes dynamically bound variables faster at the expense of making
>stack switching slower, deep binding makes stack switching faster, but
>slows down lookup of dynamic variables.

[ January 16, 2003: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Cindy,
you are right. i tried to Google on this topic and found that this binding stuff is mainly related to LISP etc (and little to Perl)...
its confusing. its so confusing.
i am still unclear but i don't want to know exactly as most languages like C , java doesnt have it...and i 'm not seeing myself doing LISP
regards
maulin
chad stevens
Ranch Hand

Joined: Aug 20, 2002
Posts: 88
Wow. Cindy that was a hell of a response that did confuse me too, but very informative I must say. It was an phone interview question and they also did ask about shallow copy and deep copy which I imagine are not the same thing.
Thanks to all for the explanation.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well shallow copying is much more simple.
If you copy an array (or whatever) and just copy the references, but both the new array and the original actually point to the SAME objects - then that is a shallow copy.
If you copy the array AND make copies of all of the objects that are being referenced - then that is a deep copy.
chad stevens
Ranch Hand

Joined: Aug 20, 2002
Posts: 88
Cindy, thanks again for the short and to the point definition, I suppose it's the same as in C++. That makes sense, the binding question was another thing, they had asked me on a phone interview and I just said I didn't know. I guess that was the best thing!
Igor Ko
Ranch Hand

Joined: Jun 24, 2002
Posts: 90
Probably it's about class loading.
In C/C++ if somethere exists call of some
function, in the linkage the
code of the function (obj) must exists.
In Java it depends of JVM, as I know in Sun JVM
the JVM doesn't load all classes at the begins
(before any executing), so it can be that at the
middle of execution - JVM found that program
use some class, that doesn't exist at all...
Probably deep binding should check that all
classes exists (and probably load they all before
execution.
(really in the Java can't be
full deep binding - loader can check all, but not
dynamic class loading - Class.forName( ))
boyet silverio
Ranch Hand

Joined: Aug 28, 2002
Posts: 173
encountered a term called 'binding' in some java-corba reference (whose name i am still trying to remember and look for)
anyway, it sort of refers to the 'binding' of an object reference with a 'name' (which could be a String) in a corba naming service. this service stores object references and when objects are stored, a name must be provided that is unique within the naming service. So when a an app (e.g. java app) wants to get such an object from the naming service, it could just submit the 'name' and it will be given the object (if such a 'name' is 'binding' to an object). I don't know however, how this 'binding' could be made shallower or deeper.
hope this relates somehow.
chad stevens
Ranch Hand

Joined: Aug 20, 2002
Posts: 88
Boyet.
The only time I came across strings and binding was using JNDI, contexts and lookups. Frankly, I don't know if they do have anything to do with binding, but I will try to look up some stuff. Thanks.
Igor Ko
Ranch Hand

Joined: Jun 24, 2002
Posts: 90
In the Java spec no used word "bind" in the
part about I wrote recently - used word "resolve"
(12.1.2 Link Test: Verify, Prepare, (Optionally) Resolve)
So I don't know means of "binding" in the context.
;-)
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
If Java would have had deep binding implemented, the following code snippet would have printed "deep"; of course what it actually does is printing "shallow".

kind regards
 
 
subject: What is the difference between 'deep' and 'shallow' binding?
 
Similar Threads
shallow copy and deep copy
binding styles in webservices
UML History
shallow cloning and deep cloning
shallow cloning and deep cloning