+ 1

What's the purpose of access modifiers?

Will someone steal my code or something?

23rd Jan 2017, 2:55 AM
Paul Silvestri
Paul Silvestri - avatar
3 Answers
+ 3
Access modifiers become increasingly important the larger your project. if a method or variable is public, you must take extreme care editing it because many other programs could be using it. However when it's private, there are fewer dependencies when updating future code. Defining elements as private or public establishes clear boundaries between crucial internal processes and classes that are meant to be multipurpose. In general, a programmer only wants to expose those parts of the code that are meant to be for external users.
23rd Jan 2017, 4:44 AM
James McCoy
James McCoy - avatar
+ 2
Make the access public for all of class' methods and arguments can be danger, because, somebody can danificate the program if he access and modify a variable what he don't needs to access. In Oriented to Object Programmation, the only thing important is what you will do with the class in the future, doesn't matter how this works. So, if somebody uses your class and access a most important attribute or method, your class will not works how need. (sorry, my english is so bad)
5th Feb 2017, 4:45 AM
JoĂŁo Victor Oliveira Couto
JoĂŁo Victor Oliveira Couto - avatar
0
How would an external user access the wrong part of the code?
24th Jan 2017, 12:25 AM
Paul Silvestri
Paul Silvestri - avatar