answersLogoWhite

0


Best Answer

"Linking" refers to providing a "reference" to the source data; if the source is deleted, the link no longer functions; many different types of files, programs, and programming interfaces refer to displaying externally located data as linking. Linking is advantageous when the data might later change and the program or file that contains the link would benefit from having the latest version of the data.

"Embedding" has a slightly different context depending on the context that you are using it. If you are referring to a file (such as a Flash file, Microsoft executable file, and so on), embedding refers to storing the data directly within the other data type. An executable can store Icon files, for example, which alter their presentation on the Desktop or Start Menu by showing an identifying image so users can tell programs apart visually. Embedding in a document file depends on the type of document file in question. Some document files store a copy of the data in the file, while other document formats simply imply that a plugin program is embedded into the document's data. Finally, applications can embed other applications within them during execution. For example, a program could be written to embed an internet Explorer web viewer into a larger program.

When embedding refers to "storing a copy", the benefit is that the source file can be deleted without affecting this dependent file. The disadvantage, of course, is that updates to the source data require updating the dependent file through whatever means available (applications have to be recompiled, documents have to be edited, etc).

When embedding refers to "running a copy of a program within another program", there are many advantages: less code has to be used each time a component is reused, the component can be upgraded independently of the main program, and a component can crash without crashing the entire application (possibly including recovering data from the failed component). The disadvantage of embedding is, of course, memory usage will be higher than having a single, unified program.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

7y ago

Linked and embedded objects are used when one object contains another. The containing object is known as the container. A container allows us to create a collection of one or more objects, treating them as a single object (the container). The contained objects may be of the same type or of different types, and may be embedded or linked to the container. As an example, a document (the container) may contain a mixture of text and image objects. We can edit the text and image objects independently of each other, thus updating the document.

When we embed an object within a container we create an independent copy of that object. Any changes made to the object are not reflected in any of its copies.

When a container links to an object, no copies are made. There is only one instance of the linked object and multiple containers may share the same linked object. so long as the link is maintained, any changes made to the linked object are reflected in all the containers that link to it.

Linked objects can be embedded if we later require an independent copy in our container. Transforming an embedded object into a linked object requires that we first export the object to create an independent copy (unless one already exists), then remove the embedded object and insert a link in its place.

A link is simply a reference. If the object we wish to link to is stored in a local or network file, we can link to it via the file's URL. So long as the object's URL does not change and the file is not deleted, the link is maintained. Object's linked through memory addresses are a little more tricky to deal with because the memory address might change each time we load the container. This is particularly problematic when the linked object is shared by multiple containers. When there is only one container, we can designate that container as being the "owner" of the object. But with shared objects, there is no owner. The simplest solution is to use an object manager (another container). Whenever we load an object that contains a linked object, we query the object manager to give us the object's reference. The object manager simply loads the object into memory (if it is not already loaded) and returns its reference to the calling object. The object manager should also maintain a reference count for each linked object. Whenever a container is loaded, the count is incremented for each linked object. When unloaded, the count is decremented for each linked object. When a linked object's reference count is zero, the object can be unloaded.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

All objects within a class are embedded objects. However, if the embedded object is a resource handle, smart pointer or raw pointer, the object itself is embedded but the object it references is not. The reference provides the link between the class and the object being referred to. This makes it possible for a class to maintain links to other instances of the same class, something which cannot be achieved by embedding alone.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between linking and embedding?
Write your answer...
Submit
Still have questions?
magnify glass
imp