Property Change Notifications
-
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.
-
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.
: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???
-
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.
A property doesn't have to be a Property to be a
property
. -
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.
-
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.
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)
-
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.
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
-
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)
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.
-
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.
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.
-
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.
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 methodRaisePropertyChange
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 thePropertyChanged
event, passing a property name as a string. Note however that (perhaps unwisely) I didn't use reflection inRaisePropertyChange
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.