Coding Properties
Code in the Getter
Check the user‘s credentials
Check application state
Format the returned value
Log
Lazy Loading related data/object
Code in the Setter
Check the user‘s credentials
Check application state
Validate the incoming value
Log or change tracking
Format, convert, clean up
Best Practices
Do:
Add code in the getter to protect, format, initialize,...
Add code in the setter to protect, format, validate,...
Avoid:
Single character name
Abbreviations
Easy Way to Create
prop
propfull
时间: 2024-11-08 14:42:42