Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • jake williamson 207 posts 872 karma points
    May 02, 2018 @ 10:18
    jake williamson
    0

    is there any overhead when using the 'DittoLazy' attribute?

    hey there,

    i've started a new project and've been experimenting with the [DittoLazy] attribute.

    at the moment, i'm only using it on properties that are used occasionally or require some kind of additional processing - and it works really well!

    however, i wondered if there's any overhead to using it? part of my brain is telling me why not use it on all properties as it'd make the processing time really lightweight - but if that was the case, it feels like ditto would work that way out of the box...

    thought i'd pop the question before i got to carried away and used the attribute incorrectly!

    cheers,

    jake

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    May 02, 2018 @ 10:32
    Lee Kelleher
    100

    Hi Jake,

    From a technical perspective, there'll be a tiny overhead in that Ditto is using Reflection to check for certain attributes. On it's own it's hardly noticeable, but if applied to all properties on a class, and depending how many properties you have, then it may not be ideal.

    That aside, there are two chains of thought with lazy-loading values with Ditto. One is that lazy-loading is good, only retrieving the values when they are needed. The other is that Ditto is intended for view-models, if you have values that aren't being used, then why are they on your view-model at all? (So there's no reason to lazy-load anything)

    I'm in the latter camp. I try to keep my view-models as lean as they can be.

    Not sure if this helps answer your question? :-)

    Cheers,
    - Lee

  • jake williamson 207 posts 872 karma points
    May 02, 2018 @ 11:40
    jake williamson
    0

    hi lee,

    that sure does help and answer my question, thank you for taking the time to reply ;)

    i had a feeling that it'd be using reflection and therefore would introduce an overhead. but as you say, it's negligible and if used where needed rather than via a blanket approach, you'd not notice (i certainly haven't while developing the site).

    i hear where you're going with view specific models. i've a feeling that i've begun using ditto with models that are bloated and complicated and should maybe made skinnier...

    at the moment, i'm experimenting generics with a base model that has all the common properties and then other models that have the view specific properties.

    thanks again for the reply,

    jake

Please Sign in or register to post replies

Write your reply to:

Draft