In OOP, it seems that if an object cross-references another object in its property, ultimately, if such objects are used a lot, the software at the end will be slow because of this.

Is this true? If yes, can we intentionally not do this by getting things done?

  • What language? In JavaScript it could get costly depending on circumstances or core object used. I wouldn't expect a significant cost in pre-compiled languages but if most objects are tangled webs of calls to other objects, that may be a symptom of an architectural problem. May 23, 2012 at 4:08
  • What the heck makes you suspect this?
    – user7043
    May 23, 2012 at 12:28

2 Answers 2


I'm not entirely sure I understand the question, but if an object contains another object by reference, then the cost of this is a pointer dereference every time you use the contained object. That's a trivial cost.


The performance difference is minor compared to having cleaner and more maintainable code. Take a look at the provided API's for your language and see how common it is for objects to be nested. Classes that only deal with primitives are probably in the minority.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.