locked
best practice for child.parent property RRS feed

  • Question

  • User-1312778766 posted

    asp.net.4.2 web form proj

    hello

    Q:

    to let siblings to know their parent - how expensive is it?

    so in a month, week and day obj, month.weekArr and week.dayArr object - 

    to have a day.Parent,

    month class{
       public week weekArr;
    }
    week class{
       public day dayArr;
    }
    
    day class{
      public week parent; //<-- ???
    }

    i dont know how and what really happened there in the CLR- 

    but i assume the parent in day.parant.daysArr will be just pointers to an existing objects..

    and not a new object - or new memory allocation.. 

    yet i dont know what will be the best practice - for example:

    - dont use stringBuilder unless you have more than 5 strings to add..

    else - use string s += "xx";

     dose somebody know about any performance test?

     

    thanks

    Friday, September 11, 2015 4:26 AM

Answers

  • User1070236303 posted

    Just pointers, but you need to initialize the properties pointing to parents in the child constructors. There is no auto parent in clr.

    Testing the performance is pointless, this won't be ever a performance problem for your app.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 11, 2015 4:37 AM