Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1030307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:40:46+00:00 2026-05-16T12:40:46+00:00

Given an object that has a variable which it doesn’t own; that is, the

  • 0

Given an object that has a variable which it doesn’t own; that is, the variable is composed by aggregation instead of composition. Will a deep copy operation copy the variable or only the link to it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:40:47+00:00Added an answer on May 16, 2026 at 12:40 pm

    I like the distinction that you are making here between the role of composition and aggregation in the context of a deep copy.

    I am going to go against the other answer and say: no, an object should not deep-copy another object that it doesn’t own.

    One would expect a deep copy of an object to be (at least initially) identical to the original. If a deep copy were made of a reference that the original didn’t own, then this leaves open the question of what owns the new copy. If the clone owns it, then it would not be identical to the original object. It would be an object like the original, except it owns the reference to one of its aggregated members. This would surely lead to chaos. If the clone doesn’t own it, then who does?

    This problem of ownership is especially important in non-garbage-collected languages, but it also creates problems even with a garbage collector. For example, if the clone is made to allow uncommitted changes to an object, are changes to be allowed on this other object that it references? If changes are not allowed, then there was no reason to deep-copy it. If changes are allowed, then how are those changes to be committed, since the object being modified doesn’t control this referenced object? Sure, a mechanism for this could be contrived, but it would surly mean that the cloned object is overstepping its responsibilities, and the program would be a maintenance nightmare.

    A deep copy operation that includes unowned objects also leads to problems of infinite (or at least excessive) copy operations. Suppose an object is part of a collection, and further suppose the object requires a reference to the collection. A naive deep-copy operation on that object would then create a new copy of the collection and each of its members. Even assuming that we avoid the problem of infinite recursion, and keep all the references consistent among this new set of objects, it is still excessive for most purposes, and for those cases where a new collection is desired, wouldn’t it make more sense to deep-copy the collection itself, rather than one of its members, for this purpose?

    I think a deep-copy that only includes owned objects, as you suggest, is the only sane approach for most purposes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to use a column alias, with AS keyword:… May 16, 2026 at 9:43 pm
  • Editorial Team
    Editorial Team added an answer Have you considered making your second DropDownList that is filled… May 16, 2026 at 9:43 pm
  • Editorial Team
    Editorial Team added an answer It has to do with the implicit conversion of a… May 16, 2026 at 9:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

is there a python ORM (object relational mapper) that has a tool for automatically
There's a bit of code which writes data to a MemoryStream object directly into
I have certain initializing functions that I use to set up audit logging on
So .... There are obviously many questions that all have been asked about Singletons,
I like how Java has a Map where you can define the types of
From the examples that I have read and from the documentation on MysqlConnectionPoolDataSource at
How can I unmarshal a message that was marshalled using a QName local part
I am trying to debug some C/Java bindings that use some custom refcounting/locking. I
Intro I am doing a kind of OCR application that should recognize characters based
I'm engaged in a debate over XML representations of groups of objects. Given an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.