- It doesn't matter how many of your attributes you expose through getters/setters and how carefully youyou're doing that. Being more selective will not mademake your code OOP with encapsulation. Every attribute you expose will lead to some procedure working with that naked data in imperative procedural way. You will just spread your code less slowly with being more selective. That doesn't change the core.
- Yes, in boundaries within the system you get naked data from other systems or database. But this data is just another encapsulation point.
- Objects should be reliable. The whole idea of objects is being resposinbleresponsible so that you don't need to give orders that are straight and imperative. Instead youyou're asking an object to do what heit does well through the contract. You safely delegate acting part to the object. ObjectObjects encapsulate state and implementation details.
So if we return to the question why should we should do this. Consider this simple example:
Here we have Document exposing internal detail by getter and have external procedural code in printDocument function which works with that otsideoutside of the object. Why this is this bad? Because now you just have C style code. Yes it is structured by whatbut what's really the difference? You can structure C functions in different files and with names. And thatthose so called layers are doing exactly that. Service class is just a bunch of procedures that's worksthat work with data. That code is less maintanablemaintainable and havehas many drawbacks.
Compare with this one. Now we have a contract and the implemantation details of thatthis contract is hidehidden inside of the object. Now you can truly test that class and that class is encapsulating some data. How it works with that data is an object concerns. In order to talk with object now you need to ask him to print itself. That's encapsulation and that is an object. You will gain the full power of dependency injection, mocking, testing, single responsibilities and a lot bunch of benefits with OOP.
Hope this helps.