Method VS Property

RBCC

Member
Joined
Jan 23, 2004
Messages
14
I am trying to learn when I should use a method and when should I use property? I am trying to write a one line routine that multiplies 2 denominators of a fraction together. Should I use a method or property I have a class that has the numerator and denominator in it and I would like to know it is good programming practice to do calculations in a property?

JOHN
:confused: :confused: :confused:
 
Use a method for calculations. Think of properties as you would the properties of a button or a textbox.
 
A "side effect" would be changing the value that the user passed
into a function without them expecting it, which is not usually
done in a property accessor. Like Robby said, functions should be
used to change and return values.

For example, its more advisable to have a Disconnect() method
than to have the user set the Connected property to false.
 
So if had to calculate and output a common denominator in a textbox. ie: Switch the value to the common denominator calcultion I should use a property?
 
Back
Top