467,926 Members | 1,485 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

Using getters setters inside a object / constructor?

Bit
What do you guys think about this? I use getters and setters in private methods inside a object instead of the property. I don't think it's useful in constructors but I use it always in private methods even though I have direct access, I just find it better due to setter | mutator validation. My professor thinks it's a bad pratice. What do you guys think about this?
3 Weeks Ago #1
  • viewed: 1197
Share:
2 Replies
Expert 256MB
I use getters and setters in private methods inside a object instead of the property. I don't think it's useful in constructors but I use it always in private methods even though I have direct access, I just find it better due to setter | mutator validation.
Show an example.   ⠀⠀⠀⠀              ⠀⠀⠀⠀           
3 Weeks Ago #2
Dormilich
Expert Mod 8TB
I just find it better due to setter | mutator validation.
Is there any possibility (except for code errors) that you run into validation problems in your own class?
2 Weeks Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Boogie El Aceitoso | last post: by
4 posts views Thread by Ioannis Vranos | last post: by
14 posts views Thread by gurry | last post: by
2 posts views Thread by Nigel Molesworth | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.