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

  • SEARCH
  • Home
  • 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 6032807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:23:22+00:00 2026-05-23T05:23:22+00:00

I wasn’t able to find a discussion on this topic but I think its

  • 0

I wasn’t able to find a discussion on this topic but I think its pretty important so theres a big chance it exists, so Ill be gladful to read.

In our viewmodel setters for properties we can check if provided value is equal to current value and only notify in that case, or we can ignore the check and set & notify right away.

While this check appears pleasing as it saves some resources when “refresh” on VM doesn’t cause View redraw it can also present some bad effects when View is a little more complicated and has some code behind which either can’t be put in VM or when putting it in VM is too difficult compared to leaving it in View.

So generally from my experience with MVVM I can think of scenario when this check prevented some code from working as expected. So currently I am thinking that this check is a dangerous thing and generally not worth the benefit of a saving redraw sometimes.

Also sometimes this check can be used as a substitute for better program logic when for example there are 2 properties on VM that actually are closely connected like, say string & object representation of some entity. So when one is set for example string, inside it calls an object setter too if validated correctly, and this equality check saves situation from infinite loop of object <-> string setters, but in that case I think its much better to introduce a flag that is checked in setter and doesn’t call another if it is not needed, when call to say object setter came from call to string setter.

I think that this check is mostly used for scenario I just described which I think isn’t exactly a good reason to perform the check.

So how should we code our setters?

Edit: well just to give a scenario, the simplest and most stupid one would be this: if we have a OneWay binding to View from VM and for some reason there exists some handler in View codebehind that changes View directly, causing it to become unsynchronized with VM, refreshing VM wont help. Of course its obvious that in that case we should be calling VM setter that is bound , but I think in some cases scenario can be more complicated and advanced where resolution becomes less transparent. So scenario is stupid but having a check would prevent from correct behavior. Ill think more on a real world example where its not so easy to resolve but probably will require some time..

  • 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-23T05:23:23+00:00Added an answer on May 23, 2026 at 5:23 am

    In my personal experience I have found this check very useful and I always put the equality check in the setter to make sure that if there is no need to refresh the binding value then I should not call the property change and should not force view to refresh the value when it is not required at all.

    Talking about your scenario where equality check is causing you trouble, I think there must be something odd in the scenario or most probably you might be approaching something incorrectly otherwise I have used MVVM a lot and haven’t find such a scenario in my case. Even if there exists a scenario where it may might make sense to not to do equality check, I won’t stop using equality checking because of a small minor issue I am facing in some few cases. I will try to do some workaround in that particular problematic case to avoid the problem rather then not using the equality check in the setters

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

Sidebar

Related Questions

I wasn't able to find documentation for this. It looks like the R source
It is a recurrent question but I wasn't able to find a complete enough
Already checked the Internet but I wasn't able to find it out :-
hope this wasn't asked already, but I can't find an answer. I got a
I wasn't able to find a question/answer that covers this fully hence why I
Wasn't quite sure how to word this but let's say I've used ssh to
I wasn't able to find out (googling, reading mysql reference manual) how to get
Okay I wasn't really sure how to word this question, but basically what I
This wasn't the question I was going to ask but I have unexpectedly run
I wasn't sure what the title should be but its s simple concept but

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.