Lets say I need to compare the x position of a ball with the x position of a rectangle to see if they have collided. Wouldn't it be easier to just declare x in ball as public so I can use ball.x instead of ball.getX()?
Kuroshi
0
Light Poster
Recommended Answers
Jump to PostThe amount of CPU power it takes to call and return a simplistic get function is almost completely negligible. That said, traditional object-oriented programming usually involves hiding all data members, and accessing them purely through get/set functions. I always thought that "rule" was kind of silly though. There are definitely …
All 4 Replies
Reply to this topic
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.