_
_
_umr2017-02-12 13:25:43
Java
_umr, 2017-02-12 13:25:43

Should you always use encapsulation?

Some say it's not necessary and it's confusing. Someone says you should do it and everyone will expect you to do it in every class. The book says what you need. How to properly use encapsulation? Set variables via setters, get them via getters? Anytime and anywhere?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2017-02-12
@Umr001

I think it all depends on the project. If the project grows, then in the future some kind of logic in setters and getters may be required, and if there is no logic, then such setters and getters are no different from an open variable

D
Danil Sapegin, 2017-10-02
@ynblpb_spb

If you need a console solution, then look towards casperjs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question