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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:19:53+00:00 2026-05-14T08:19:53+00:00

In classes that implement INotifyPropertyChanged I often see this pattern : public string FirstName

  • 0

In classes that implement INotifyPropertyChanged I often see this pattern :

    public string FirstName
    {
        get { return _customer.FirstName; }
        set
        {
            if (value == _customer.FirstName)
                return;

            _customer.FirstName = value;

            base.OnPropertyChanged("FirstName");
        }
    }

Precisely the lines

            if (value == _customer.FirstName)
                return;

are bothering me. I’ve often did this but I am not that sure it’s needed nor good. After all if a caller assigns the very same value I don’t want to reassign the field and, especially, notify my subscribers that the property has changed when, semantically it didn’t.

Except saving some CPU/RAM/etc by freeing the UI from updating something that will probably look the same on the screen/whatever_medium what do we obtain?

Could some people force a refresh by reassigning the same value on a property (NOT THAT THIS WOULD BE A GOOD PRACTICE HOWEVER)?

1. Should we do it or shouldn’t we?

2. Why?

  • 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-14T08:19:54+00:00Added an answer on May 14, 2026 at 8:19 am

    Yes, you should return immediately when the consumer is setting a property value that is equal to the value which is already being persisted.

    First of all, there is no reason to waste any time or resources in the setter of the property – the value is already set so no further action is needed. Also you should never call OnPropertyChanged if the value stored in the property’s backing field hasn’t changed – the method is intended to be raised when the value has changed not when the property’s setter has been called.

    All that being said, however – if the setter didn’t have a call to OnPropertyChanged I wouldn’t have bothered to check the value first. In the case of a simple setter that only sets the backing field’s value and nothing else it is actually going to be faster to always the set the value rather than checking first then setting the value. Only use this pattern when the property’s setter has additional logic that either shouldn’t fire or may incur an unnecessary performance penalty.

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

Sidebar

Ask A Question

Stats

  • Questions 514k
  • Answers 514k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The above code throws an instance of boost::bad_expression with "Invalid… May 16, 2026 at 6:06 pm
  • Editorial Team
    Editorial Team added an answer > a <- c(1,2, 3.2, 4, 5) > x <-… May 16, 2026 at 6:06 pm
  • Editorial Team
    Editorial Team added an answer Well, That was a very long process of diving into… May 16, 2026 at 6:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

If I have a base class that implement INotifyPropertyChanged public class ResourceWrapperBase : INotifyPropertyChanged
Is there some way to avoid this. I have a lot of classes that
Working with the MVVM pattern, I have a pair of view model classes that
I have setup a property and implement INotifyPropertyChanged like so... public event PropertyChangedEventHandler PropertyChanged;
If I have some classes that implement the same interface, so they all contain
I'm having trouble finding any classes that implement Microsoft.Office.Interop.Outlook.TimeZone. Do any such classes exist?
I've got a number of classes that implement a specific interface ( ISearchable )
I'm currently designing/reworking the databinding part of an application that makes heavy use of
I apologize for the newbie question, but I am struggling with this problem. I
I'm continuing to struggle with the MVVM pattern and, in attempting to create a

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.