What are the conventions for writing a properties | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What are the conventions for writing a properties

When should I use automatic generated and when the long ones.

23rd Oct 2019, 5:38 AM
Miroslav Nikolov
Miroslav Nikolov - avatar
4 Answers
+ 2
A convention is a contract with yourself, the company or the group you are in. Yes it is right to do it in the get/set. However, I usally check nu input before assigning it to the properties. So most of the time I do it, when the user leaves the control (Read textbox) or when ok-button is pressed.
23rd Oct 2019, 12:50 PM
sneeze
sneeze - avatar
+ 1
I always start with a automatically generated. If I need to write code in the get/set, I do that afterwards. Private variables of the properties are always lower case For Public variables I use camel case
23rd Oct 2019, 12:40 PM
sneeze
sneeze - avatar
+ 1
sneeze Is it right to make the validation in the property ? Or where else could be done right if we follow the conventions ?
23rd Oct 2019, 12:46 PM
Miroslav Nikolov
Miroslav Nikolov - avatar
+ 1
Thanks
23rd Oct 2019, 12:51 PM
Miroslav Nikolov
Miroslav Nikolov - avatar