Skip to main content
1 of 2
Nayrb
  • 2.5k
  • 1
  • 19
  • 22

If getters and setters violate encapsulation and true OO than I'm seriously in trouble.

I always felt an object represents what ever best comes to mind you need it to function as.

I just finished writing a program that generates Mazes in Java, I have class that represents "Maze Squares". I have data in this class that represents coordinates, walls and booleans ect.

I have to have some way to change/manipulate/access this data! What do I do without getters and setters? Java doesn't use properties and setting all my data that is local to this class to public is DEFINITELY a violation of encapsulation and OO.

Nayrb
  • 2.5k
  • 1
  • 19
  • 22