Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Property Change Notifications

Property Change Notifications

Scheduled Pinned Locked Moved The Weird and The Wonderful
lounge
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rob Grainger
    wrote on last edited by
    #1

    I was a bit mystified why property change notifications (INotifyPropertyChanged) were being raised for non-existent properties in our project. Turns out some "bright spark" had the innovative idea of using them as a general event mechanism, presumably to save all the effort of declaring an event type. I may have to persuade the company to buy all developers a copy of "Clean Code".

    "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

    B P P L Sander RosselS 6 Replies Last reply
    0
    • R Rob Grainger

      I was a bit mystified why property change notifications (INotifyPropertyChanged) were being raised for non-existent properties in our project. Turns out some "bright spark" had the innovative idea of using them as a general event mechanism, presumably to save all the effort of declaring an event type. I may have to persuade the company to buy all developers a copy of "Clean Code".

      "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

      B Offline
      B Offline
      Brisingr Aerowing
      wrote on last edited by
      #2

      :doh: :wtf: :~ X| What an amadán.

      What do you get when you cross a joke with a rhetorical question? --- The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. --- Do questions with multiple question marks annoy you???

      1 Reply Last reply
      0
      • R Rob Grainger

        I was a bit mystified why property change notifications (INotifyPropertyChanged) were being raised for non-existent properties in our project. Turns out some "bright spark" had the innovative idea of using them as a general event mechanism, presumably to save all the effort of declaring an event type. I may have to persuade the company to buy all developers a copy of "Clean Code".

        "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        A property doesn't have to be a Property to be a property.

        1 Reply Last reply
        0
        • R Rob Grainger

          I was a bit mystified why property change notifications (INotifyPropertyChanged) were being raised for non-existent properties in our project. Turns out some "bright spark" had the innovative idea of using them as a general event mechanism, presumably to save all the effort of declaring an event type. I may have to persuade the company to buy all developers a copy of "Clean Code".

          "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

          P Offline
          P Offline
          phil o
          wrote on last edited by
          #4

          What's the problem, if it compiles? ;P -> [ ]

          There are two kinds of people in the world: those who can extrapolate from incomplete data.

          1 Reply Last reply
          0
          • R Rob Grainger

            I was a bit mystified why property change notifications (INotifyPropertyChanged) were being raised for non-existent properties in our project. Turns out some "bright spark" had the innovative idea of using them as a general event mechanism, presumably to save all the effort of declaring an event type. I may have to persuade the company to buy all developers a copy of "Clean Code".

            "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Rob Grainger wrote:

            presumably to save all the effort of declaring an event type

            ehr.. For me it is a code-snippet in VS. Four seconds, five tops, tada, event. How much effort does declaring an event take at your company?

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

            R 1 Reply Last reply
            0
            • R Rob Grainger

              I was a bit mystified why property change notifications (INotifyPropertyChanged) were being raised for non-existent properties in our project. Turns out some "bright spark" had the innovative idea of using them as a general event mechanism, presumably to save all the effort of declaring an event type. I may have to persuade the company to buy all developers a copy of "Clean Code".

              "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

              Sander RosselS Offline
              Sander RosselS Offline
              Sander Rossel
              wrote on last edited by
              #6

              At least it's consistent. Don't you hate all those inconsistencies? :rolleyes:

              Visit my blog at Sander's bits - Writing the code you need. Or read my articles at my CodeProject profile.

              Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

              Regards, Sander

              1 Reply Last reply
              0
              • L Lost User

                Rob Grainger wrote:

                presumably to save all the effort of declaring an event type

                ehr.. For me it is a code-snippet in VS. Four seconds, five tops, tada, event. How much effort does declaring an event take at your company?

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                R Offline
                R Offline
                Rob Grainger
                wrote on last edited by
                #7

                About the same, I'm still kinda mystified.

                "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                1 Reply Last reply
                0
                • R Rob Grainger

                  I was a bit mystified why property change notifications (INotifyPropertyChanged) were being raised for non-existent properties in our project. Turns out some "bright spark" had the innovative idea of using them as a general event mechanism, presumably to save all the effort of declaring an event type. I may have to persuade the company to buy all developers a copy of "Clean Code".

                  "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                  S Offline
                  S Offline
                  Slacker007
                  wrote on last edited by
                  #8

                  Rob Grainger wrote:

                  were being raised for non-existent properties

                  Exactly how is this being done? If the property doesn't exist, then where is this case being implemented? Can you show in a code snippet? I have never seen this done for something other than notifying the client, of a property value change. Wow.

                  R 1 Reply Last reply
                  0
                  • S Slacker007

                    Rob Grainger wrote:

                    were being raised for non-existent properties

                    Exactly how is this being done? If the property doesn't exist, then where is this case being implemented? Can you show in a code snippet? I have never seen this done for something other than notifying the client, of a property value change. Wow.

                    R Offline
                    R Offline
                    Rob Grainger
                    wrote on last edited by
                    #9

                    In our code, it is all done via our own MVVM framework. I have a SetProperty method defined on a base class, using a [CallerMemberName] argument to specify the property, which performs the following actions: 1. If the value has not changed, exit immediately. 2. Use Reflection to check the property specified actually exists. 3. Call a method RaisePropertyChange to raise the event. RaisePropertyChange is designed to allow firing notifications on derived properties when a base property or other change occurs that would affect their value (similar to most MVVM frameworks). Effectively this just triggers the PropertyChanged event, passing a property name as a string. Note however that (perhaps unwisely) I didn't use reflection in RaisePropertyChange to check the property exists. The dev in question simply called this method, passing a string that doesn't correspond to a property name. I guess I didn't consider the probability of someone being that daft. (I've now added the code to check - shame as it decreases the efficiency somewhat as it has to use Reflection to check each property access, but it costs to defend against stupidity. I'm just glad all this is in a managed language, I dread to think what would happen if these muppets were let loose on C++).

                    "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups