Performance scope variable impact? (FROM#)

Suppose we have 3 classes:

Location, Contact, PhoneNumber Classes.

In the Place class, I want to have the Contact class, but it's better to keep the PhoneNumber class in the Contact class. Thus, in the Place class it is more logical to reach PhoneNumber, first getting the Contact object, then PhoneNumber in the Contact object.

If I often need to get the PhoneNumber object from a place object, does it save the PhoneNumber class in the Contact class (Place.Contact.PhoneNumber) instead of directly inserting this object into the Place class (Place.Contact) to cause performance issues?

Why I ask this question is that such coverage problems have many performance effects in JavaScript. Is it worth it being so paranoid about variable capabilities - performance relationships in C #?

Thanks.

+3
source share
3 answers

In C #, you won’t see many performance issues around the trivial * properties of getters and seters like this. However, without profiling, it is impossible to say whether this will be a problem for you.

In most cases, object graph structures never create performance problems in C # like they can in JavaScript.


* Properties that simply return a link to an existing object and do not have additional logic.

+4
source

, . " " ( ), #, JavaScript.

+2

, , , "" "" , .

, , . , ref.ref.prop, , ref.prop, .

, , 2 , 1 2 , .

, , , , , .

- , , , , , , , .

+1
source

Source: https://habr.com/ru/post/1719231/


All Articles