Is it a good programming practice to not use getters and setters in trivial parts of code?
artur7
0
Newbie Poster
Recommended Answers
Jump to PostThat depends on your definition of "trivial". It also depends on how you intend to use the class and how much control you want over the data that is contained within an instance of the class. Care to provide some sort of example for discussion purposes?
Jump to PostIMO the greatest advantage of getters and setters is that there is only one place in the entire program that accesses the class variable. If something has to be changed than you can change is in only one spot instead of hundres of places throught the program. Make the variables …
All 7 Replies
Fbody
682
Posting Maven
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
artur7
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
mrnutty
761
Senior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
mrnutty
761
Senior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.